plant builder

This commit is contained in:
Altaezio
2026-02-10 20:09:34 +01:00
parent 4b8e59ee56
commit ab5089ad6c
129 changed files with 2377 additions and 21 deletions

View File

@@ -0,0 +1,30 @@
@tool
extends Sprite2D
class_name PlantPartScene
@export var root: Node2D
@export var attaches: Array[Node2D]
@export var bottom_attaches: Array[Node2D]
@export var type: PlantPart.PartType
@export var is_back: bool
@export var base_attachable: bool
@export var bottom_attachable: bool
@export var branch_attachable: bool
@export_tool_button("Save as resource") var save_as_resource_button = save_as_resource
func save_as_resource():
var destination := "res://entities/plants/resources/plant_parts/" + name + ".tres"
print("Saving: ", name, " at: ", destination)
var attaches_vec2: Array[Vector2]
for attach in attaches:
attaches_vec2.append(attach.position)
var bottom_attaches_vec2: Array[Vector2]
for bottom_attach in bottom_attaches:
bottom_attaches_vec2.append(bottom_attach.position)
var plant_part = PlantPart.new(texture, root.position, attaches_vec2, bottom_attaches_vec2, type, is_back, base_attachable, bottom_attachable, branch_attachable)
var err := ResourceSaver.save(plant_part, destination)
if err != OK:
printerr("Error saving resource: ", error_string(err))