|
|
@ -45,22 +45,20 @@ func save_game() -> void: |
|
|
|
save_node_data() |
|
|
|
|
|
|
|
var result: int = ResourceSaver.save(game_data_resource, save_game_file_path) |
|
|
|
print("Save Result: ", result) |
|
|
|
|
|
|
|
if result != OK: |
|
|
|
printerr("Failed to save game: ", result) |
|
|
|
|
|
|
|
func load_game() -> void: |
|
|
|
if !FileAccess.file_exists(save_game_file_path): |
|
|
|
#push_error("Save file does not exist: ", save_game_file_path) |
|
|
|
printerr("Failed to load save. File does not exist: ", save_game_file_path) |
|
|
|
return |
|
|
|
|
|
|
|
game_data_resource = ResourceLoader.load(save_game_file_path) |
|
|
|
|
|
|
|
if game_data_resource == null: |
|
|
|
push_error("Could not load save file: ", save_game_file_path) |
|
|
|
printerr("Failed to load save. Unknown format? ", save_game_file_path) |
|
|
|
return |
|
|
|
|
|
|
|
var root_node: Window = get_tree().root |
|
|
|
|
|
|
|
for resource: Resource in game_data_resource.save_data_nodes: |
|
|
|
if resource is Node3DDataResource: |
|
|
|
(resource as Node3DDataResource)._load_data(root_node) |