Now when mutating plants have their name mutating as well (if not twitch)

This commit is contained in:
Victor
2026-08-23 16:37:22 +02:00
parent da91433135
commit 5c13bcea23
5 changed files with 134 additions and 36 deletions
+17 -11
View File
@@ -18,7 +18,7 @@ func _init(
random_seed = randi()
static func generate_from_parent(plant_data : PlantData, nearby_plants : Array[PlantData] = []) -> Seed:
var mutations : Array[PlantMutation] = plant_data.mutations
var mutations : Array[PlantMutation] = plant_data.mutations.duplicate_deep()
var mutation_probability = (
GameInfo.game_data.current_run.plant_info.get_mutation_probability()
+ plant_data.get_mutation_probability_boost()
@@ -28,9 +28,15 @@ static func generate_from_parent(plant_data : PlantData, nearby_plants : Array[P
for pd in nearby_plants:
nearby_mutations.append_array(pd.mutations)
var child_name := plant_data.plant_name
# Mutate for every time mutation probability exceed 1
while mutation_probability > 1:
mutations = mutate_mutations(plant_data.mutations, nearby_mutations)
if len(mutations) != len(plant_data.mutations):
child_name = Random.big_mutate_plant_name(child_name)
else:
child_name = Random.small_mutate_plant_name(child_name)
mutation_probability -= 1
mutations.sort_custom(
@@ -41,19 +47,19 @@ static func generate_from_parent(plant_data : PlantData, nearby_plants : Array[P
plant_data.get_state() == PlantData.State.MATURE
and randf() < GameInfo.game_data.current_run.plant_info.get_mutation_probability()
):
return Seed.new(
plant_data.plant_name,
mutate_mutations(mutations, nearby_mutations)
)
else :
return Seed.new(
plant_data.plant_name,
plant_data.mutations.duplicate_deep()
)
mutations = mutate_mutations(mutations, nearby_mutations)
if len(mutations) != len(plant_data.mutations):
child_name = Random.big_mutate_plant_name(child_name)
else:
child_name = Random.small_mutate_plant_name(child_name)
return Seed.new(child_name, mutations)
else:
return Seed.new(child_name, mutations)
static func generate_random(rarity := 0) -> Seed:
var new_seed = Seed.new(
Random.generate_random_word(),
Random.generate_random_plant_name(),
generate_first_mutations(rarity),
)