## Used with the SaveDataComponent for defining node and scene_file_path
class_name SceneDataResource
extends Node3DDataResource


@export var node_name: String
@export var scene_file_path: String


func _save_data(node: Node3D) -> void:
	super._save_data(node)

	node_name = node.name
	scene_file_path = node.scene_file_path


func _load_data(window: Window) -> void:
	var parent_node: Node3D
	if parent_node_path != null:
		parent_node = window.get_node_or_null(parent_node_path)

	var scene_node: Node3D
	if node_path != null:
		var scene_file_resource: Resource = load(scene_file_path)
		scene_node = scene_file_resource.instantiate()

	if parent_node != null and scene_node != null:
		parent_node.add_child(scene_node)