19 lines
492 B
GDScript3
19 lines
492 B
GDScript3
|
extends Node
|
||
|
|
||
|
func serialize() -> Dictionary:
|
||
|
var systems = {}
|
||
|
for child in get_children():
|
||
|
systems[child.name] = {
|
||
|
"script": child.script.resource_path,
|
||
|
"data": child.serialize()
|
||
|
}
|
||
|
return systems
|
||
|
|
||
|
func deserialize(data: Dictionary) -> void:
|
||
|
for system_name in data:
|
||
|
var system_data = data[system_name] as Dictionary
|
||
|
var system_node = load(system_data.script).new()
|
||
|
system_node.name = system_name
|
||
|
add_child(system_node, true)
|
||
|
system_node.deserialize(system_data.data)
|