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.
 

46 lines
1.7 KiB

## Performs the actual saving and loading of data related to this level/scene
## Utilized by the SaveGameManager
class_name SaveLevelDataComponent
extends Node
## See documentation to where this path is: https://docs.godotengine.org/en/stable/tutorials/io/data_paths.html#accessing-persistent-user-data-user[br][br]
## Default Paths:[br]
## * Windows: %APPDATA%\Godot\app_userdata\[project_name][br]
## * macOS: ~/Library/Application Support/Godot/app_userdata/[project_name][br]
## * Linux: ~/.local/share/godot/app_userdata/[project_name][br]
@export var save_game_data_path: String = "user://game_data/"
@export var max_auto_saves: int = 5
@export_group("Save File Names")
@export var save_file_name: String = "save_%s_game_data.tres" ## %s is the level name
@export var quicksave_file_name: String = "quicksave_game_data.tres"
@export var autosave_file_name: String = "autosave_%s_game_data.tres" ## %s is the save number (probably 01)
var level_scene_name: String
var game_data_resource: SaveGameDataResource
func _ready() -> void:
add_to_group("save_level_data_component")
level_scene_name = get_parent().name
SaveGameManager.create_auto_save_file.connect(_on_create_auto_save_file)
func load_game() -> void:
SaveGameManager.load_save_file.emit(save_file_name % level_scene_name)
func quick_load_game() -> void:
SaveGameManager.quick_load.emit()
func quick_save_game() -> void:
SaveGameManager.quick_save.emit()
func save_game() -> void:
SaveGameManager.create_save_file.emit(save_file_name % level_scene_name)
func _on_create_auto_save_file() -> void:
# TODO: Check max number of autosaves, increment existing autosaves, etc
#_save_game_as_resource(autosave_file_name % "01")
pass