plant tester + shado assets

This commit is contained in:
Altaezio
2026-02-21 18:40:00 +01:00
parent 35004684f4
commit 4ca102966b
74 changed files with 1203 additions and 308 deletions

View File

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