class_name SaveGameData
extends Resource

var unlocked_collectibles_ids: Array[StringName] = []
var saved_photos: Array[String] = []
var audio_bus_volumes: Dictionary[String, float] = {}

func to_dictionary() -> Dictionary:
	var serialized_collectible_ids: Array[String] = []
	for collectible_id in unlocked_collectibles_ids:
		serialized_collectible_ids.append(str(collectible_id))

	return {
		"unlocked_collectibles_ids": serialized_collectible_ids,
		"saved_photos": saved_photos,
		"audio_bus_volumes": audio_bus_volumes,
	}

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(StringName(str(collectible_id)))

	if data.has("saved_photos"):
		for photo_path in data["saved_photos"]:
			save_game_data.saved_photos.append(str(photo_path))

	if data.has("audio_bus_volumes") and data["audio_bus_volumes"] is Dictionary:
		for bus_name in data["audio_bus_volumes"]:
			save_game_data.audio_bus_volumes[str(bus_name)] = float(data["audio_bus_volumes"][bus_name])

	return save_game_data
