ajout des graines procédurales et des cinamatiques
This commit is contained in:
@@ -11,6 +11,7 @@ const SCORE_ICON = preload("res://common/icons/growth.svg")
|
||||
@export var plant_archetype: PlantArchetype
|
||||
@export var plant_mutations: Array[PlantMutation]
|
||||
@export var random_seed : int
|
||||
var stored_icon : Texture
|
||||
|
||||
func _init(
|
||||
_plant_name : String = "",
|
||||
@@ -23,7 +24,7 @@ func _init(
|
||||
random_seed = randi()
|
||||
|
||||
static func generate_from_parent(plant_data : PlantData) -> Seed:
|
||||
if randf() > MUTATION_PROBABILITY:
|
||||
if randf() < MUTATION_PROBABILITY:
|
||||
return Seed.new(
|
||||
plant_data.plant_name,
|
||||
plant_data.archetype,
|
||||
@@ -37,10 +38,14 @@ static func generate_from_parent(plant_data : PlantData) -> Seed:
|
||||
)
|
||||
|
||||
static func generate_random() -> Seed:
|
||||
var archetype = PlantArchetype.get_random()
|
||||
var random_mutations : Array[PlantMutation] = []
|
||||
if randf() < MUTATION_PROBABILITY:
|
||||
random_mutations = ([archetype.available_mutations.pick_random().duplicate_deep()] as Array[PlantMutation])
|
||||
var new_seed = Seed.new(
|
||||
Random.generate_random_word(),
|
||||
PlantArchetype.get_random(),
|
||||
[]
|
||||
random_mutations
|
||||
)
|
||||
|
||||
return new_seed
|
||||
@@ -54,7 +59,9 @@ func get_description() -> String:
|
||||
return tr("PLANT_%s_MUST_BE_USED_IN_DECONTAMINATED_ZONE") % plant_name
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return PlantTextureBuilder.build_seed_texture(random_seed)
|
||||
if stored_icon == null:
|
||||
stored_icon = PlantTextureBuilder.build_seed_texture(plant_name.hash())
|
||||
return stored_icon
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user