Ajout de l'impact des plantes proche pour le mutations et réparation du travel screen dans le mode infini
This commit is contained in:
@@ -17,13 +17,17 @@ func _init(
|
||||
plant_mutations = _plant_mutations
|
||||
random_seed = randi()
|
||||
|
||||
static func generate_from_parent(plant_data : PlantData) -> Seed:
|
||||
static func generate_from_parent(plant_data : PlantData, nearby_plants : Array[PlantData] = []) -> Seed:
|
||||
var mutations : Array[PlantMutation] = plant_data.mutations
|
||||
var mutation_probability = GameInfo.game_data.current_run.plant_info.get_mutation_probability()
|
||||
|
||||
var nearby_mutations : Array[PlantMutation] = []
|
||||
for pd in nearby_plants:
|
||||
nearby_mutations.append_array(pd.mutations)
|
||||
|
||||
# Mutate for every time mutation probability exceed 1
|
||||
while mutation_probability > 1:
|
||||
mutations = mutate_mutations(plant_data.mutations)
|
||||
mutations = mutate_mutations(plant_data.mutations, nearby_mutations)
|
||||
mutation_probability -= 1
|
||||
|
||||
mutations.sort_custom(
|
||||
@@ -36,7 +40,7 @@ static func generate_from_parent(plant_data : PlantData) -> Seed:
|
||||
):
|
||||
return Seed.new(
|
||||
plant_data.plant_name,
|
||||
mutate_mutations(mutations)
|
||||
mutate_mutations(mutations, nearby_mutations)
|
||||
)
|
||||
else :
|
||||
return Seed.new(
|
||||
@@ -184,7 +188,7 @@ static func generate_first_mutations(rarity := 0) -> Array[PlantMutation]:
|
||||
|
||||
return [possible_mutation]
|
||||
|
||||
static func mutate_mutations(mutations : Array[PlantMutation]) -> Array[PlantMutation]:
|
||||
static func mutate_mutations(mutations : Array[PlantMutation], nearby_mutations : Array[PlantMutation]) -> Array[PlantMutation]:
|
||||
|
||||
var mutation_possibility : Array[MutationPossibility] = []
|
||||
|
||||
@@ -205,18 +209,26 @@ static func mutate_mutations(mutations : Array[PlantMutation]) -> Array[PlantMut
|
||||
return chosen_mutation_possibility.mutate(mutations)
|
||||
|
||||
class MutationPossibility:
|
||||
func mutate(_mutations : Array[PlantMutation])-> Array[PlantMutation]:
|
||||
func mutate(_mutations : Array[PlantMutation], _nearby_mutations : Array[PlantMutation])-> Array[PlantMutation]:
|
||||
return []
|
||||
|
||||
class AddMutation extends MutationPossibility:
|
||||
func mutate(mutations : Array[PlantMutation])-> Array[PlantMutation]:
|
||||
func mutate(
|
||||
mutations : Array[PlantMutation],
|
||||
nearby_mutations : Array[PlantMutation]
|
||||
)-> Array[PlantMutation]:
|
||||
var new_mutations = mutations.duplicate_deep()
|
||||
var possible_new_mutations = GameInfo.game_data.progression_data.get_available_mutations().duplicate_deep()
|
||||
|
||||
possible_new_mutations = possible_new_mutations.filter(
|
||||
func (m : PlantMutation):
|
||||
return mutations.find_custom(func(m2: PlantMutation): return m2.name == m.name) == -1
|
||||
return mutations.find_custom(func(m2: PlantMutation): return m2.id == m.id) == -1
|
||||
)
|
||||
|
||||
for m1 in possible_new_mutations:
|
||||
for m2 in nearby_mutations:
|
||||
if m1.id == m2.id:
|
||||
possible_new_mutations.append(m1) # Double les chances d'avoir la mutation si elle est présente dans les voisins
|
||||
|
||||
if len(possible_new_mutations):
|
||||
new_mutations.append(possible_new_mutations.pick_random())
|
||||
@@ -225,7 +237,8 @@ class AddMutation extends MutationPossibility:
|
||||
|
||||
class UpgradeMutation extends MutationPossibility:
|
||||
func mutate(
|
||||
mutations : Array[PlantMutation]
|
||||
mutations : Array[PlantMutation],
|
||||
_nearby_mutations : Array[PlantMutation]
|
||||
) -> Array[PlantMutation]:
|
||||
var new_mutations = mutations.duplicate_deep()
|
||||
|
||||
@@ -242,7 +255,10 @@ class UpgradeMutation extends MutationPossibility:
|
||||
return new_mutations
|
||||
|
||||
class RemoveMutation extends MutationPossibility:
|
||||
func mutate(mutations : Array[PlantMutation])-> Array[PlantMutation]:
|
||||
func mutate(
|
||||
mutations : Array[PlantMutation],
|
||||
_nearby_mutations : Array[PlantMutation]
|
||||
)-> Array[PlantMutation]:
|
||||
var new_mutations = mutations.duplicate_deep()
|
||||
|
||||
var mut_to_remove = new_mutations.pick_random()
|
||||
|
||||
Reference in New Issue
Block a user