mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
24 lines
777 B
GDScript
24 lines
777 B
GDScript
|
|
class_name SaveEngine
|
||
|
|
|
||
|
|
const SAVE_FILE = "user://save.json"
|
||
|
|
|
||
|
|
static func serialize():
|
||
|
|
return {
|
||
|
|
"out-game": {
|
||
|
|
"value": OutGameStorage.upgradableFieldsValue.duplicate(),
|
||
|
|
"level": OutGameStorage.upgradableFieldsLevel.duplicate()
|
||
|
|
},
|
||
|
|
"tutorial-watched": StarterPanel.tutorialWatched
|
||
|
|
}
|
||
|
|
static func apply(saveData: Dictionary):
|
||
|
|
OutGameStorage.upgradableFieldsValue = saveData["out-game"]["value"]
|
||
|
|
OutGameStorage.upgradableFieldsLevel = saveData["out-game"]["level"]
|
||
|
|
StarterPanel.tutorialWatched = saveData["tutorial-watched"]
|
||
|
|
static func load():
|
||
|
|
return JsonTool.parseFromFile(SAVE_FILE)
|
||
|
|
static func save():
|
||
|
|
var file = FileAccess.open(SAVE_FILE, FileAccess.ModeFlags.WRITE)
|
||
|
|
if file is FileAccess:
|
||
|
|
file.store_string(JsonTool.stringify(serialize()))
|
||
|
|
file.close()
|