seeding-planets/entities/plants/scripts/plant_mutation/elitist_mutation.gd

26 lines
767 B
GDScript

extends PlantMutation
class_name ElitistMutation
func get_icon() -> Texture:
return preload("res://common/icons/copy.svg")
func get_base_rarity() -> int:
return 0
func get_mutation_name() -> String:
return "Intolerant"
func get_mutation_description() -> String:
return "Add [b]%d[/b] to the score for each plant of the same species around, but score become 0 if none is around." % level
func mutate_score(plant : Plant, score) -> int:
var plant_count = 0
for area in plant.influence_zone.get_overlapping_areas():
if area is Plant and area != plant and area.plant_type.name == plant.plant_type.name:
plant_count += 1
if plant_count == 0:
return 0
else :
return score + level * plant_count