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:
2026-06-26 18:29:40 +02:00
parent 53c86e9cc7
commit 39630ce2ca
7 changed files with 31 additions and 16 deletions

View File

@@ -143,7 +143,7 @@ func harvest():
func produce_seed():
region.drop_item(
Seed.generate_from_parent(data),
Seed.generate_from_parent(data, data.nearby_plants),
global_position,
HARVESTED_SEED_DISPLACEMENT_FACTOR,
)

View File

@@ -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()

View File

@@ -35,14 +35,14 @@ func _ready():
%EnergyInfo3d.energy = GameInfo.game_data.player_data.energy
%EnergyInfo3d.max_energy = GameInfo.game_data.player_data.max_energy
func update_travel_screen(with_animation = true):
func update_travel_screen(with_animation = true, recreate_map = false):
if is_node_ready():
var current_position = run_data.level + (0.5 if in_space else 0.)
%TravelScreenContent.story_step = run_data.story_step
%TravelScreenContent.current_position = current_position
%TravelScreenContent.update(with_animation)
%TravelScreenContent.update(with_animation, recreate_map)
%TopologyContent.texture.noise.seed = run_data.run_seed

View File

@@ -33,6 +33,7 @@ var ship_icon : Sprite2D
func update(with_animation := true, recreate_map = false):
if is_node_ready() and story_step:
print(current_position)
if recreate_map or not ship_icon:
if story_step and get_step_number() < story_step.get_region_sequence_length():

View File

@@ -10,9 +10,7 @@ metadata/_custom_type_script = "uid://bdonub7t01xmi"
[node name="TravelScreenContent" type="Node2D" unique_id=1386845472]
position = Vector2(500, 256)
script = ExtResource("1_u6tks")
current_position = 3.0
story_step = SubResource("Resource_iergx")
start = 2
[node name="Icons" type="Node2D" parent="." unique_id=1787603855]
unique_name_in_owner = true

View File

@@ -146,7 +146,7 @@ func update_dashboard(with_animation := true):
dashboard.run_data = current_run
dashboard.in_space = GameInfo.game_data.ship_in_space
dashboard.update_travel_screen(with_animation)
dashboard.update_travel_screen(with_animation, not with_animation)
var can_take_off : bool = (
not current_run.is_finished()

View File

@@ -14,7 +14,7 @@ OK,Ok,Ok
GARDEN,Garden,Jardin
COMMA,", ",","
OR," or "," ou "
PAUSE,Pause,Pause&
PAUSE,Pause,Pause
CONTROLS,Controls,Contrôles
RESUME_GAME,Resume,Reprendre
RESTART,Restart,Recommencer
1 keys en fr
14 GARDEN Garden Jardin
15 COMMA , ,
16 OR or ou
17 PAUSE Pause Pause& Pause
18 CONTROLS Controls Contrôles
19 RESUME_GAME Resume Reprendre
20 RESTART Restart Recommencer