refactoring save_game

This commit is contained in:
2026-04-16 12:30:40 +02:00
parent e02bd1819f
commit 2508ac96fa
8 changed files with 50 additions and 39 deletions

View File

@@ -0,0 +1,24 @@
class_name SaveGameData
extends Resource
var unlocked_collectibles_ids: Array[String] = []
var saved_photos: Array[String] = []
func to_dictionary() -> Dictionary:
return {
"unlocked_collectibles_ids": unlocked_collectibles_ids,
"saved_photos": saved_photos,
}
static func from_dictionary(data: Dictionary) -> SaveGameData:
var save_game_data := SaveGameData.new()
if data.has("unlocked_collectibles_ids"):
for collectible_id in data["unlocked_collectibles_ids"]:
save_game_data.unlocked_collectibles_ids.append(str(collectible_id))
if data.has("saved_photos"):
for photo_path in data["saved_photos"]:
save_game_data.saved_photos.append(str(photo_path))
return save_game_data