## Add to any node that has data we need to save
##  Each node type, such as TileMapLayer, will need a resource created for it
##  See `res://save_load/resources/node_types/`
class_name SaveDataComponent
extends Node


@export var save_data_resource: Node3DDataResource ## The resource describing the type of object being saved

@onready var parent_node: Node3D = get_parent()


func _ready() -> void:
	add_to_group("save_data_component")


func _save_data() -> Resource:
	if parent_node == null:
		return

	if save_data_resource == null:
		push_error("save_data_resource not defined on node ", parent_node.name)
		return

	save_data_resource._save_data(parent_node)
	return save_data_resource