plant tester + shado assets
This commit is contained in:
@@ -47,7 +47,7 @@ func generate_sprite() -> PlantSprite:
|
||||
var sprite_object : PlantSprite = SPRITE_SCENE.instantiate()
|
||||
|
||||
add_child(sprite_object)
|
||||
sprite_object.generate_mutation_effects(self)
|
||||
# sprite_object.generate_mutation_effects(self)
|
||||
|
||||
return sprite_object
|
||||
|
||||
|
||||
@@ -11,9 +11,12 @@ class_name PlantArchetype
|
||||
@export var seed_random_loose = 1
|
||||
@export var available_mutations: Array[PlantMutation] = [
|
||||
AncientMutation.new(),
|
||||
PrecociousMutation.new(),
|
||||
QualityMutation.new(),
|
||||
QuickMutation.new()
|
||||
EphemeralMutation.new(),
|
||||
FertileMutation.new(),
|
||||
PurificationMutation.new(),
|
||||
QuickMutation.new(),
|
||||
SocialMutation.new(),
|
||||
ToughMutation.new()
|
||||
]
|
||||
|
||||
static func get_all() -> Array[PlantArchetype]:
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
extends EntityData
|
||||
class_name PlantData
|
||||
|
||||
signal updated(p : PlantData)
|
||||
signal disappeared(p : PlantData)
|
||||
signal updated(p: PlantData)
|
||||
signal disappeared(p: PlantData)
|
||||
|
||||
enum State {PLANTED, GROWING, MATURE, DEAD}
|
||||
|
||||
@export var archetype: PlantArchetype
|
||||
@export var plant_name : String
|
||||
@export var mutations : Array[PlantMutation]
|
||||
@export var day : int :
|
||||
set(v):
|
||||
@export var plant_name: String
|
||||
@export var mutations: Array[PlantMutation]
|
||||
@export var day: int:
|
||||
set(v):
|
||||
day = v
|
||||
updated.emit(self)
|
||||
@export var random_seed : int
|
||||
updated.emit(self )
|
||||
@export var random_seed: int
|
||||
|
||||
@export var leafs = 0 # +1 score
|
||||
@export var roots = 0 # +1 lifetime
|
||||
@@ -21,11 +21,11 @@ enum State {PLANTED, GROWING, MATURE, DEAD}
|
||||
# var texture_builder: TextureBuilder = preload("res://entities/plants/scripts/texture_builder/texture_builder.tres")
|
||||
|
||||
func _init(
|
||||
_position : Vector2 = Vector2.ZERO,
|
||||
_archetype : PlantArchetype = PlantArchetype.get_random(),
|
||||
_plant_name : String = Random.generate_random_word(),
|
||||
_mutations : Array[PlantMutation] = [],
|
||||
_day : int = 0,
|
||||
_position: Vector2 = Vector2.ZERO,
|
||||
_archetype: PlantArchetype = PlantArchetype.get_random(),
|
||||
_plant_name: String = Random.generate_random_word(),
|
||||
_mutations: Array[PlantMutation] = [],
|
||||
_day: int = 0,
|
||||
_random_seed = randi()
|
||||
):
|
||||
position = _position
|
||||
@@ -36,9 +36,9 @@ func _init(
|
||||
random_seed = _random_seed
|
||||
|
||||
for m in mutations:
|
||||
m.mutate_plant_data(self)
|
||||
m.mutate_plant_data(self )
|
||||
|
||||
static func generate_from_seed(plant_seed : Seed, plant_position : Vector2) -> PlantData:
|
||||
static func generate_from_seed(plant_seed: Seed, plant_position: Vector2) -> PlantData:
|
||||
return PlantData.new(
|
||||
plant_position,
|
||||
plant_seed.plant_archetype,
|
||||
@@ -56,7 +56,7 @@ func get_lifetime() -> int:
|
||||
var lifetime = archetype.lifetime + roots
|
||||
|
||||
for m in mutations:
|
||||
lifetime = m.mutate_lifetime(self, lifetime)
|
||||
lifetime = m.mutate_lifetime(self , lifetime)
|
||||
|
||||
return lifetime
|
||||
|
||||
@@ -64,15 +64,18 @@ func get_growing_time() -> int:
|
||||
var growing_time = archetype.growing_time
|
||||
|
||||
for m in mutations:
|
||||
growing_time = m.mutate_growing_time(self, growing_time)
|
||||
growing_time = m.mutate_growing_time(self , growing_time)
|
||||
|
||||
return growing_time
|
||||
|
||||
func get_score(state : State = get_state()) -> int:
|
||||
func get_score(state: State = get_state()) -> int:
|
||||
var score = archetype.base_score + leafs if state == State.MATURE else 0
|
||||
|
||||
var mult := 1
|
||||
|
||||
for m in mutations:
|
||||
score = m.mutate_score(self, score)
|
||||
score = m.mutate_score(self , score)
|
||||
mult = m.mutate_score_multiplier(self , mult)
|
||||
|
||||
return score
|
||||
|
||||
@@ -89,14 +92,14 @@ func get_seed_number(state = get_state()):
|
||||
var seed_number = archetype.seed_number if (state == State.MATURE or state == State.DEAD) else 0
|
||||
|
||||
for m in mutations:
|
||||
seed_number = m.mutate_seed_number(self, seed_number)
|
||||
seed_number = m.mutate_seed_number(self , seed_number)
|
||||
|
||||
return seed_number
|
||||
|
||||
func get_seed_random_loose():
|
||||
var seed_random_loose = archetype.seed_random_loose
|
||||
for m in mutations:
|
||||
seed_random_loose = m.mutate_seed_random_loose(self, seed_random_loose)
|
||||
seed_random_loose = m.mutate_seed_random_loose(self , seed_random_loose)
|
||||
|
||||
return seed_random_loose
|
||||
|
||||
@@ -107,4 +110,4 @@ func get_random_seed_income():
|
||||
)
|
||||
|
||||
func disappear():
|
||||
disappeared.emit(self)
|
||||
disappeared.emit(self )
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
extends Resource
|
||||
class_name PlantMutation
|
||||
|
||||
@export var level : int = 1
|
||||
@export var level: int = 1
|
||||
|
||||
var id : String : get = get_mutation_id
|
||||
var name : String : get = get_mutation_name
|
||||
var id: String: get = get_mutation_id
|
||||
var name: String: get = get_mutation_name
|
||||
|
||||
func _init(_level : int = 1):
|
||||
func _init(_level: int = 1):
|
||||
level = _level
|
||||
|
||||
func get_icon() -> Texture:
|
||||
@@ -27,40 +27,43 @@ func get_mutation_description() -> String:
|
||||
printerr("Classe abstraite PlantMutation appelée")
|
||||
return ""
|
||||
|
||||
func mutate_plant_data(_plant_data : PlantData):
|
||||
func mutate_plant_data(_plant_data: PlantData):
|
||||
pass
|
||||
|
||||
func mutate_score(_plant_data : PlantData, score : int) -> int:
|
||||
func mutate_score(_plant_data: PlantData, score: int) -> int:
|
||||
return score
|
||||
|
||||
func mutate_lifetime(_plant_data : PlantData, lifetime : int) -> int:
|
||||
func mutate_score_multiplier(_plant_data: PlantData, multiplier: int) -> int:
|
||||
return multiplier
|
||||
|
||||
func mutate_lifetime(_plant_data: PlantData, lifetime: int) -> int:
|
||||
return lifetime
|
||||
|
||||
func mutate_growing_time(_plant_data : PlantData, growing_time : int) -> int:
|
||||
func mutate_growing_time(_plant_data: PlantData, growing_time: int) -> int:
|
||||
return growing_time
|
||||
|
||||
func mutate_seed_number(_plant_data, seed_number):
|
||||
func mutate_seed_number(_plant_data: PlantData, seed_number: int):
|
||||
return seed_number
|
||||
|
||||
func mutate_seed_random_loose(_plant_data, seed_random_loose):
|
||||
func mutate_seed_random_loose(_plant_data: PlantData, seed_random_loose):
|
||||
return seed_random_loose
|
||||
|
||||
func _start_planted_effect(_plant : Plant):
|
||||
func _start_planted_effect(_plant: Plant):
|
||||
pass
|
||||
|
||||
func _start_day_effect(_plant : Plant):
|
||||
func _start_day_effect(_plant: Plant):
|
||||
pass
|
||||
|
||||
func _start_maturation_effect(_plant : Plant):
|
||||
func _start_maturation_effect(_plant: Plant):
|
||||
pass
|
||||
|
||||
func _start_dead_effect(_plant : Plant):
|
||||
func _start_dead_effect(_plant: Plant):
|
||||
pass
|
||||
|
||||
func _start_harvested_effect(_plant : Plant):
|
||||
func _start_harvested_effect(_plant: Plant):
|
||||
pass
|
||||
|
||||
func get_level_for_rarity(rarity : int) -> int :
|
||||
func get_level_for_rarity(rarity: int) -> int:
|
||||
return rarity - get_base_rarity() + 1
|
||||
|
||||
func get_rarity() -> int:
|
||||
@@ -78,7 +81,7 @@ func card_section() -> CardSectionInfo:
|
||||
return section
|
||||
|
||||
static func get_rarity_text(rarity) -> String:
|
||||
var rarity_text : Array[String] = [
|
||||
var rarity_text: Array[String] = [
|
||||
"COMMON",
|
||||
"RARE",
|
||||
"VERY_RARE",
|
||||
@@ -88,11 +91,11 @@ static func get_rarity_text(rarity) -> String:
|
||||
|
||||
if rarity < len(rarity_text):
|
||||
return rarity_text[rarity]
|
||||
else :
|
||||
else:
|
||||
return rarity_text[len(rarity_text) - 1]
|
||||
|
||||
static func get_rarity_color(rarity : int) -> Color:
|
||||
var rarity_colors : Array[Color] = [
|
||||
static func get_rarity_color(rarity: int) -> Color:
|
||||
var rarity_colors: Array[Color] = [
|
||||
Color("25C147"),
|
||||
Color("8B2DFF"),
|
||||
Color("FF006E"),
|
||||
|
||||
23
entities/plants/scripts/plant_mutation/ephemeral_mutation.gd
Normal file
23
entities/plants/scripts/plant_mutation/ephemeral_mutation.gd
Normal file
@@ -0,0 +1,23 @@
|
||||
extends PlantMutation
|
||||
class_name EphemeralMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/chevrons-up.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "EPHEMERAL"
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("EPHEMERAL")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("EPHEMERAL_EFFECT_TEXT_LEVEL_%d") % level
|
||||
|
||||
func mutate_lifetime(_plant_data: PlantData, lifetime: int) -> int:
|
||||
return lifetime - ceil(0.5 * level)
|
||||
|
||||
func mutate_seed_number(_plant_data: PlantData, seed_number: int):
|
||||
return seed_number + level
|
||||
@@ -0,0 +1 @@
|
||||
uid://bmo42h1p554nv
|
||||
21
entities/plants/scripts/plant_mutation/fertile_mutation.gd
Normal file
21
entities/plants/scripts/plant_mutation/fertile_mutation.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
extends PlantMutation
|
||||
class_name FertileMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/chevrons-up.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "FERTILE"
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("FERTILE")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("FERTILE_EFFECT_TEXT_LEVEL_%d") % level
|
||||
|
||||
func mutate_lifetime(_plant_data : PlantData, lifetime : int) -> int:
|
||||
print("TODO:: Implemnt FERTILE lifetime based on plants around")
|
||||
return lifetime + level
|
||||
@@ -0,0 +1 @@
|
||||
uid://eslsw42a0ylv
|
||||
@@ -0,0 +1,21 @@
|
||||
extends PlantMutation
|
||||
class_name PurificationMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/chevrons-up.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "PURIFICATION"
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("PURIFICATION")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("PURIFICATION_EFFECT_TEXT_LEVEL_%d") % level
|
||||
|
||||
func _start_maturation_effect(_plant : Plant):
|
||||
print("Implement purification maturation effect")
|
||||
pass
|
||||
@@ -0,0 +1 @@
|
||||
uid://buwy5v4yi3piv
|
||||
@@ -16,5 +16,8 @@ func get_mutation_name() -> String:
|
||||
func get_mutation_description() -> String:
|
||||
return tr("QUICK_EFFECT_TEXT_LEVEL_%d") % level
|
||||
|
||||
func mutate_score(_plant_data : PlantData, score : int) -> int:
|
||||
return score + level
|
||||
|
||||
func mutate_growing_time(_data : PlantData, grow_time : int) -> int:
|
||||
return max(grow_time - level, 0)
|
||||
return max(grow_time - level, 1)
|
||||
|
||||
21
entities/plants/scripts/plant_mutation/social_mutation.gd
Normal file
21
entities/plants/scripts/plant_mutation/social_mutation.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
extends PlantMutation
|
||||
class_name SocialMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/chevrons-up.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "SOCIAL"
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("SOCIAL")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("SOCIAL_EFFECT_TEXT_LEVEL_%d") % level
|
||||
|
||||
func mutate_score(_plant_data : PlantData, score : int) -> int:
|
||||
printerr("TODO:: implement SOCIAL score based on plants around")
|
||||
return score + level
|
||||
@@ -0,0 +1 @@
|
||||
uid://bhej2wpdfveu5
|
||||
23
entities/plants/scripts/plant_mutation/tough_mutation.gd
Normal file
23
entities/plants/scripts/plant_mutation/tough_mutation.gd
Normal file
@@ -0,0 +1,23 @@
|
||||
extends PlantMutation
|
||||
class_name ToughMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/chevrons-up.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
|
||||
func get_mutation_id() -> String:
|
||||
return "TOUGH"
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("TOUGH")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("TOUGH_EFFECT_TEXT_LEVEL_%d") % level
|
||||
|
||||
func mutate_score_multiplier(_plant_data: PlantData, multiplier: int) -> int:
|
||||
return multiplier + 2
|
||||
|
||||
func mutate_growing_time(_plant_data: PlantData, growing_time: int) -> int:
|
||||
return growing_time + maxi(0, 3 - level)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bwsnyirytbnqj
|
||||
@@ -1,20 +1,71 @@
|
||||
extends Node
|
||||
|
||||
@export var n_plants_to_generate: int
|
||||
@export var n_plants_to_generate: int = 1
|
||||
@export var n_plants_per_row: int = 0
|
||||
@export var n_mutation_per_plant: int
|
||||
@export var space_between_plants: float
|
||||
@export var randomize_pos: bool
|
||||
@export var random_pos_offset: float
|
||||
|
||||
func _ready():
|
||||
%ZoomLevel.value = %Camera2D.zoom.x
|
||||
%NPlants.value = n_plants_to_generate
|
||||
%NMutationsPerPlant.value = n_mutation_per_plant
|
||||
%RandomizePos.button_pressed = randomize_pos
|
||||
%RandomizeOffset.value = random_pos_offset
|
||||
generate_plants();
|
||||
|
||||
func _input(_event) -> void:
|
||||
var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||
%Camera2D.position += 1 / %Camera2D.zoom.x * 10 * input_dir
|
||||
|
||||
|
||||
func generate_plants():
|
||||
for child in %Plants.get_children():
|
||||
child.free()
|
||||
|
||||
for i in n_plants_to_generate:
|
||||
print("Generate plant")
|
||||
var plant_position := Vector2(i * space_between_plants, 0)
|
||||
var plant_pos_x = (i % n_plants_per_row) * space_between_plants
|
||||
@warning_ignore("integer_division")
|
||||
var plant_pos_y = (i / n_plants_per_row) * space_between_plants
|
||||
var plant_position := Vector2(plant_pos_x, plant_pos_y)
|
||||
if randomize_pos:
|
||||
plant_position += randf_range(0, random_pos_offset) * Vector2.ONE.rotated(randf_range(0, 2 * PI))
|
||||
var plant_data: PlantData = PlantData.new(plant_position)
|
||||
plant_data.day = plant_data.get_growing_time()
|
||||
plant_data.mutations.append(plant_data.archetype.available_mutations.pick_random())
|
||||
plant_data.mutations.append(plant_data.archetype.available_mutations.pick_random())
|
||||
plant_data.mutations.append(plant_data.archetype.available_mutations.pick_random())
|
||||
for j in n_mutation_per_plant:
|
||||
plant_data.mutations.append(plant_data.archetype.available_mutations.pick_random())
|
||||
var plant: Plant = Plant.new(plant_data)
|
||||
add_child(plant)
|
||||
%Plants.add_child(plant)
|
||||
plant.set_owner(self )
|
||||
plant.global_position = plant_position
|
||||
|
||||
|
||||
func _on_generate_plants_pressed() -> void:
|
||||
generate_plants()
|
||||
|
||||
|
||||
func _on_zoom_level_value_changed(value: float) -> void:
|
||||
%Camera2D.zoom = Vector2.ONE * value
|
||||
|
||||
|
||||
func _on_reset_zoom_pressed() -> void:
|
||||
%Camera2D.zoom = Vector2.ONE
|
||||
%ZoomLevel.value = 1
|
||||
|
||||
|
||||
func _on_n_plants_value_changed(value: float) -> void:
|
||||
n_plants_to_generate = int(value)
|
||||
|
||||
func _on_n_plants_per_row_value_changed(value: float) -> void:
|
||||
n_plants_per_row = int(value)
|
||||
|
||||
func _on_n_mutations_per_plant_value_changed(value: float) -> void:
|
||||
n_mutation_per_plant = int(value)
|
||||
|
||||
func _on_randomize_pos_toggled(toggled_on: bool) -> void:
|
||||
randomize_pos = toggled_on
|
||||
|
||||
func _on_randomize_offset_value_changed(value: float) -> void:
|
||||
random_pos_offset = value
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extends Resource
|
||||
class_name PlantAttach
|
||||
|
||||
enum AttachType {ORANGE_ATTACH, BLUE_ATTACH, PINK_ATTACH}
|
||||
enum AttachType {ORANGE_ATTACH, PURPLE_ATTACH, BLUE_ATTACH, PINK_ATTACH}
|
||||
|
||||
@export var position: Vector2
|
||||
@export var attach_types: Array[AttachType]
|
||||
|
||||
@@ -27,6 +27,7 @@ func load_resource():
|
||||
for i in maxi(attaches_children.size(), plant_part.attaches.size()):
|
||||
if i < attaches_children.size() && i < plant_part.attaches.size():
|
||||
attaches_children[i].position = plant_part.attaches[i].position
|
||||
attaches_children[i].attach_types = plant_part.attaches[i].attach_types
|
||||
elif i >= attaches_children.size():
|
||||
var new_child = PlantAttachBuilder.new()
|
||||
new_child.name = "attach" + str(i)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extends Node
|
||||
|
||||
const IMAGE_WIDTH := 1000
|
||||
const IMAGE_HEIGHT := 2000
|
||||
const IMAGE_WIDTH := 1024
|
||||
const IMAGE_HEIGHT := 2048
|
||||
|
||||
const PLACEHOLDER_SEED_TEXTURE: Texture = preload("res://entities/plants/assets/sprites/default/seed.png")
|
||||
const PLACEHOLDER_MATURE_TEXTURE: Texture = preload("res://entities/plants/assets/sprites/default/mature.png")
|
||||
@@ -12,6 +12,7 @@ const PLACEHOLDER_GROWING_TEXTURE: Texture = preload("res://entities/plants/asse
|
||||
@export var baby_bases: Array[PlantPart]
|
||||
@export var branches: Array[PlantPart]
|
||||
@export var n_branches: int = 2
|
||||
@export var base_leaves: Array[PlantPart]
|
||||
@export var parts_mutation_associations: Dictionary[String, PartMutationAssociation]
|
||||
|
||||
var rng := RandomNumberGenerator.new()
|
||||
@@ -47,7 +48,7 @@ func build_plant_texture(plant_data: PlantData) -> Texture:
|
||||
|
||||
match plant_data.get_state():
|
||||
PlantData.State.MATURE:
|
||||
print("Build mature texture")
|
||||
# print("Build mature texture")
|
||||
# var plant_archetype := plant_data.archetype
|
||||
if bases.size() == 0:
|
||||
printerr("No base in archetype")
|
||||
@@ -67,7 +68,7 @@ func build_plant_texture(plant_data: PlantData) -> Texture:
|
||||
parts_to_place.append(pick_random(branches))
|
||||
|
||||
for m in plant_data.mutations:
|
||||
print("mutations: ", m.id)
|
||||
# print("mutations: ", m.id)
|
||||
var association: PartMutationAssociation = parts_mutation_associations[m.id]
|
||||
var mutation_possible_parts := association.parts
|
||||
for p in association.part_amount:
|
||||
@@ -75,7 +76,7 @@ func build_plant_texture(plant_data: PlantData) -> Texture:
|
||||
|
||||
|
||||
PlantData.State.GROWING:
|
||||
print("Build growing texture")
|
||||
# print("Build growing texture")
|
||||
# var plant_archetype := plant_data.archetype
|
||||
if baby_bases.size() == 0:
|
||||
printerr("No baby base in archetype")
|
||||
@@ -89,7 +90,7 @@ func build_plant_texture(plant_data: PlantData) -> Texture:
|
||||
mature_image.blend_rect(base_image, Rect2i(Vector2i.ZERO, base_image.get_size()), base_image_coord - base_image_center)
|
||||
|
||||
for m in plant_data.mutations:
|
||||
print("mutations: ", m.id)
|
||||
# print("mutations: ", m.id)
|
||||
var association: PartMutationAssociation = parts_mutation_associations[m.id]
|
||||
var mutation_possible_parts := association.parts
|
||||
for p in ceil(0.5 * association.part_amount):
|
||||
@@ -103,13 +104,14 @@ func build_plant_texture(plant_data: PlantData) -> Texture:
|
||||
parent_image_coords.fill(base_image_coord)
|
||||
|
||||
for part: PlantPart in parts_to_place:
|
||||
print("Add part : ", part.resource_name)
|
||||
# print("Add part : ", part.resource_name)
|
||||
var ind := find_random_matching_attach_ind(part.root, available_attaches)
|
||||
if ind == -1:
|
||||
printerr("No attach found")
|
||||
continue
|
||||
|
||||
var attach: PlantAttach = available_attaches.pop_at(ind)
|
||||
|
||||
var parent_image_coord: Vector2i = parent_image_coords.pop_at(ind)
|
||||
|
||||
var part_image: Image = part.texture.get_image()
|
||||
@@ -128,4 +130,7 @@ func build_plant_texture(plant_data: PlantData) -> Texture:
|
||||
func find_random_matching_attach_ind(attach_to_match: PlantAttach, array: Array[PlantAttach]) -> int:
|
||||
var indices: Array = range(array.size())
|
||||
shuffle(indices)
|
||||
return indices.find_custom(func(i): return array[i].attach_types.any(func(type): return attach_to_match.attach_types.has(type)))
|
||||
for i in indices:
|
||||
if array[i].attach_types.any(func(type): return attach_to_match.attach_types.has(type)):
|
||||
return i
|
||||
return -1
|
||||
|
||||
Reference in New Issue
Block a user