plant builder
This commit is contained in:
30
entities/plants/scripts/texture_builder/plant_part_scene.gd
Normal file
30
entities/plants/scripts/texture_builder/plant_part_scene.gd
Normal 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))
|
||||
Reference in New Issue
Block a user