added basic scene manager

This commit is contained in:
Luca 2024-09-27 09:37:12 +02:00
parent f694d5c4f8
commit 2cf0846597
7 changed files with 37 additions and 57 deletions

View file

@ -44,17 +44,12 @@ func load_game():
# Save a reference to the current save game
current_save = saved_game
print(saved_game.party[0].display_name)
# Clean up all non-static objects from the scene
get_tree().call_group("save_nodes", "on_before_load_game")
# Restore world data
# doing it via get_tree, until the SceneManager exists
var _world : Node = load(saved_game.world).instantiate()
get_node("/root/Game/CurrentLevel").add_child(_world)
world = _world
#SceneManager.set_world(saved_game.world)
SceneManager.set_world(saved_game.world)
# Restore all other nodes
for node in saved_game.saved_data:
@ -63,8 +58,8 @@ func load_game():
var restored_node = scene.instantiate()
# Add the item to the world
# todo: add parent as value to save
world.add_child(restored_node)
# todo: add parent as value to save and restore to the parent
SceneManager.current_world.add_child(restored_node)
# run a callback to restore the item's state
if restored_node.has_method("on_load_game"):