|
## 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
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("quick_save"):
|
|
save_game()
|
|
if event.is_action_pressed("quick_load"):
|
|
load_game()
|
|
|
|
|
|
func save_game() -> 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.save_game()
|
|
game_saved.emit()
|
|
|
|
func load_game() -> void:
|
|
EntityManager.reset_world.emit()
|
|
|
|
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.load_game()
|
|
game_loaded.emit()
|