This repository has been archived on 2020-09-30. You can view files and clone it, but cannot push or open issues or pull requests.
odyssey-old/Scenes/systems.gd

18 lines
492 B
GDScript

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)