Files
seeding-planets/entities/plants/scripts/plant_mutation/social_mutation.gd

34 lines
918 B
GDScript

extends PlantMutation
class_name SocialMutation
const DEFAULT_PLANT_BY_POINT = 4
func get_icon() -> Texture:
return preload("res://common/icons/users-group.svg")
func get_mutation_id() -> String:
return "SOCIABLE"
func get_mutation_name() -> String:
return tr("SOCIABLE")
func get_mutation_description() -> String:
return tr("SOCIABLE_EFFECT_TEXT_LEVEL").format(
{
"near_amount": get_near_plants_around(),
"score_increase": get_score_increase()
}
)
func mutate_score(plant_data: PlantData, score: int) -> int:
if plant_data.get_state() != PlantData.State.MATURE:
return score
return score + get_score_increase() * floori(len(plant_data.nearby_plants)/get_near_plants_around())
func get_near_plants_around():
return max(DEFAULT_PLANT_BY_POINT - level,1)
func get_score_increase():
return max(level - DEFAULT_PLANT_BY_POINT,1)