new mutations wip
This commit is contained in:
@@ -123,8 +123,13 @@ func calculate_plant_score(
|
||||
return data.get_score(with_state)
|
||||
|
||||
func harvest():
|
||||
for i in range(data.get_seed_number()):
|
||||
await produce_seed()
|
||||
var do_produce_seeds := true
|
||||
for m in data.mutations:
|
||||
do_produce_seeds = do_produce_seeds && m.produce_seeds()
|
||||
|
||||
if do_produce_seeds:
|
||||
for i in range(data.get_seed_number()):
|
||||
await produce_seed()
|
||||
|
||||
if data.get_state() == PlantData.State.MATURE:
|
||||
for m in data.mutations:
|
||||
@@ -151,8 +156,15 @@ func mature():
|
||||
func die():
|
||||
for m in data.mutations:
|
||||
m._start_dead_effect(self)
|
||||
for i in range(data.get_seed_number()):
|
||||
await produce_seed()
|
||||
|
||||
var do_produce_seeds := true
|
||||
for m in data.mutations:
|
||||
do_produce_seeds = do_produce_seeds && m.produce_seeds_on_maturation()
|
||||
|
||||
if do_produce_seeds:
|
||||
for i in range(data.get_seed_number()):
|
||||
await produce_seed()
|
||||
|
||||
AudioManager.play_sfx("Harvest")
|
||||
disappear()
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ func get_mutation_name() -> String:
|
||||
func mutate_plant_data(_plant_data: PlantData):
|
||||
pass
|
||||
|
||||
func has_score(_plant_data: PlantData) -> bool:
|
||||
return true
|
||||
|
||||
func mutate_score(_plant_data: PlantData, score: int) -> int:
|
||||
return score
|
||||
|
||||
@@ -38,6 +41,9 @@ func mutate_lifetime(_plant_data: PlantData, lifetime: int) -> int:
|
||||
func mutate_growing_time(_plant_data: PlantData, growing_time: int) -> int:
|
||||
return growing_time
|
||||
|
||||
func produce_seeds() -> bool:
|
||||
return true
|
||||
|
||||
func mutate_seed_number(_plant_data: PlantData, seed_number: int) -> int:
|
||||
return seed_number
|
||||
|
||||
|
||||
25
entities/plants/scripts/plant_mutation/cleaning_mutation.gd
Normal file
25
entities/plants/scripts/plant_mutation/cleaning_mutation.gd
Normal file
@@ -0,0 +1,25 @@
|
||||
extends PlantMutation
|
||||
class_name CleaningMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/alert-triangle.svg")
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "CLEANING"
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("CLEANING")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("CLEANING_EFFECT_TEXT").format({
|
||||
"purification_radius": get_purification_radius()
|
||||
})
|
||||
|
||||
func _start_dead_effect(plant: Plant):
|
||||
plant.region.decontaminate(Math.get_tiles_in_circle(
|
||||
plant.global_position,
|
||||
get_purification_radius() * (Region.TILE_SIZE + Region.TILE_SIZE / 2.)
|
||||
))
|
||||
|
||||
func get_purification_radius() -> int:
|
||||
return level + 1 # one more than purification
|
||||
@@ -0,0 +1 @@
|
||||
uid://coh8clft5bs1j
|
||||
@@ -0,0 +1,29 @@
|
||||
extends PlantMutation
|
||||
class_name CuttingMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/alert-triangle.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 1
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "CUTTING"
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("CUTTING")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("CUTTING_EFFECT_TEXT").format({
|
||||
"cutable_per_day": get_cutable_per_day()
|
||||
})
|
||||
|
||||
func _start_day_effect(plant: Plant):
|
||||
var cut_left := get_cutable_per_day()
|
||||
for p in plant.data.nearby_plants:
|
||||
if cut_left > 0 && p.is_mature():
|
||||
p.harvest()
|
||||
cut_left -= 1
|
||||
|
||||
func get_cutable_per_day() -> int:
|
||||
return level
|
||||
@@ -0,0 +1 @@
|
||||
uid://j2f1ogpead8d
|
||||
@@ -0,0 +1,25 @@
|
||||
extends PlantMutation
|
||||
class_name EnergizingMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/alert-triangle.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 1
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "ENERGIZING"
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("ENERGIZING")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("ENERGIZING_EFFECT_TEXT").format({
|
||||
"bonus_energy": get_bonus_energy()
|
||||
})
|
||||
|
||||
func _start_dead_effect(plant: Plant):
|
||||
plant.region.player.data.energy += get_bonus_energy()
|
||||
|
||||
func get_bonus_energy() -> int:
|
||||
return level
|
||||
@@ -0,0 +1 @@
|
||||
uid://byj1hq1w42i7
|
||||
27
entities/plants/scripts/plant_mutation/ermit_mutation.gd
Normal file
27
entities/plants/scripts/plant_mutation/ermit_mutation.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
extends PlantMutation
|
||||
class_name ErmitMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/alert-triangle.svg")
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "ERMIT"
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("ERMIT")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("ERMIT_EFFECT_TEXT").format(
|
||||
{
|
||||
"score_increase": get_score_increase(),
|
||||
}
|
||||
)
|
||||
|
||||
func has_score(plant_data: PlantData) -> bool:
|
||||
return false if plant_data.nearby_plants.size() > 0 else true
|
||||
|
||||
func mutate_score(plant_data: PlantData, score: int) -> int:
|
||||
return score + get_score_increase() if plant_data.nearby_plants.size() == 0 else 0
|
||||
|
||||
func get_score_increase():
|
||||
return 2 * level
|
||||
@@ -0,0 +1 @@
|
||||
uid://5pfa2y03wvlt
|
||||
31
entities/plants/scripts/plant_mutation/solar_mutation.gd
Normal file
31
entities/plants/scripts/plant_mutation/solar_mutation.gd
Normal file
@@ -0,0 +1,31 @@
|
||||
extends PlantMutation
|
||||
class_name SolarMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/alert-triangle.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 1
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "SOLAR"
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("SOLAR")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("SOLAR_EFFECT_TEXT").format({
|
||||
"bonus_chance": get_bonus_chance(),
|
||||
"bonus_energy": get_bonus_energy()
|
||||
})
|
||||
|
||||
func _start_day_effect(plant: Plant):
|
||||
var rng := RandomNumberGenerator.new()
|
||||
if rng.randf() < get_bonus_chance():
|
||||
plant.region.player.data.energy += get_bonus_energy()
|
||||
|
||||
func get_bonus_chance() -> float:
|
||||
return 1 / (6 - min(level, 5))
|
||||
|
||||
func get_bonus_energy() -> int:
|
||||
return 1
|
||||
@@ -0,0 +1 @@
|
||||
uid://bhmlq1ke803rc
|
||||
@@ -0,0 +1,32 @@
|
||||
extends PlantMutation
|
||||
class_name SpontaneousMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/droplet.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 1
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "SPONTANEOUS"
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("SPONTANEOUS")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("SPONTANEOUS_EFFECT_TEXT").format({
|
||||
"bonus_seed": get_bonus_seed()
|
||||
})
|
||||
|
||||
func produce_seeds() -> bool:
|
||||
return false
|
||||
|
||||
func mutate_seed_number(_plant_data: PlantData, seed_number: int) -> int:
|
||||
return seed_number + get_bonus_seed()
|
||||
|
||||
func _start_maturation_effect(plant: Plant):
|
||||
for i in range(plant.data.get_seed_number()):
|
||||
await plant.produce_seed()
|
||||
|
||||
func get_bonus_seed() -> int:
|
||||
return level - 1
|
||||
@@ -0,0 +1 @@
|
||||
uid://cvrw2rf8p82rd
|
||||
Reference in New Issue
Block a user