|
## Performs the actual Saving[br][br]
|
|
##
|
|
## Below is a basic definition of various components and resources for reference:[br]
|
|
## * SaveLevelDataComponent - The root save component that performs saving and loading of the actual data from disk
|
|
## * SaveDataComponent - Attached to a node that has properties that need to be saved
|
|
## * Node Type Resources - Each type of node that requires saving, such as a TileMapLayer, needs a resource created
|
|
extends Node
|
|
|
|
|
|
signal game_saved
|
|
signal game_loaded
|
|
signal refresh_saves_list
|
|
signal create_auto_save_file
|
|
signal create_save_file(filename: String)
|
|
signal delete_save_file(filename: String)
|
|
signal load_save_file(filename: String)
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("quick_save"):
|
|
quick_save()
|
|
if event.is_action_pressed("quick_load"):
|
|
quick_load()
|
|
|
|
|
|
func quick_save() -> void:
|
|
var save_level_data_component: SaveLevelDataComponent = get_tree().get_first_node_in_group("save_level_data_component")
|
|
if save_level_data_component == null:
|
|
push_error("Could not find SaveLevelDataComponent node in level")
|
|
return
|
|
|
|
save_level_data_component.quick_save_game()
|
|
game_saved.emit()
|
|
|
|
func quick_load() -> void:
|
|
var save_level_data_component: SaveLevelDataComponent = get_tree().get_first_node_in_group("save_level_data_component")
|
|
if save_level_data_component == null:
|
|
push_error("Could not find SaveLevelDataComponent node in level")
|
|
return
|
|
|
|
# TODO: Don't reset world if quicksave not found
|
|
EntityManager.reset_world.emit()
|
|
save_level_data_component.quick_load_game()
|
|
game_loaded.emit()
|