A Minecraft style clone in Godot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

41 lines
1.3 KiB

## 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()