Browse Source

Correcting resetting world and hiding UI on game load

Ryan Reed 1 month ago
parent
commit
252fcc8bd0
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      save_load/autoloads/save_game_manager.gd

+ 10
- 2
save_load/autoloads/save_game_manager.gd View File

@ -27,7 +27,7 @@ func _ready() -> void:
quick_load.connect(quick_load_game)
quick_save.connect(quick_load_game)
create_save_file.connect(_on_save_game_as_resource)
load_save_file.connect(_load_game_resource)
load_save_file.connect(load_game_save)
delete_save_file.connect(_on_delete_save_file)
func _unhandled_input(event: InputEvent) -> void:
@ -77,6 +77,10 @@ func list_saves(include_quick_saves: bool = true, include_auto_saves: bool = tru
save_files.sort_custom(_custom_save_file_sort)
return save_files
func load_game_save(resource_filename: String) -> void:
_load_game_resource(resource_filename)
game_loaded.emit()
func quick_save_game() -> void:
if not _load_save_level_data_component(): return
@ -88,7 +92,6 @@ func quick_load_game() -> void:
if not _load_save_level_data_component(): return
# TODO: Don't reset world if quicksave not found
EntityManager.reset_world.emit()
_load_game_resource(_save_level_data_component.settings.quicksave_file_name)
game_loaded.emit()
@ -133,6 +136,9 @@ func _load_save_level_data_component() -> bool:
func _load_game_resource(resource_filename: String) -> void:
if not _load_save_level_data_component(): return
EntityManager.reset_world.emit()
var save_game_file_path: String = _save_level_data_component.settings.save_game_data_path + resource_filename
if !FileAccess.file_exists(save_game_file_path):
printerr("Failed to load save. File does not exist: ", save_game_file_path)
@ -148,6 +154,8 @@ func _load_game_resource(resource_filename: String) -> void:
if resource is Node3DDataResource:
(resource as Node3DDataResource)._load_data(root_node)
game_loaded.emit()
func _save_game_as_resource(resource_filename: String) -> void:
if not _load_save_level_data_component(): return


Loading…
Cancel
Save