Now when mutating plants have their name mutating as well (if not twitch)
This commit is contained in:
@@ -21,7 +21,7 @@ var region_data : RegionData
|
||||
|
||||
func _init(
|
||||
_position: Vector2 = Vector2.ZERO,
|
||||
_plant_name: String = Random.generate_random_word(),
|
||||
_plant_name: String = Random.generate_random_plant_name(),
|
||||
_mutations: Array[PlantMutation] = [],
|
||||
_day: int = 0,
|
||||
_random_seed = randi()
|
||||
|
||||
@@ -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),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user