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

21 lines
518 B
GDScript3
Raw Normal View History

extends Node
2020-09-15 23:23:45 +00:00
class_name GameSystems
func serialize() -> Dictionary:
2020-09-15 23:23:45 +00:00
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:
2020-09-15 23:23:45 +00:00
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)