Savesystem rework

This commit is contained in:
2025-11-23 21:02:40 +01:00
parent 4bbaab1a2a
commit fda2b95b38
5 changed files with 56 additions and 29 deletions
@@ -178,10 +178,6 @@ public partial class InventoryInstance : Node, ISaveable
public void UpdateSaveData()
{
var saveData = new SaveData();
saveData.SceneName = SCENE_NAME;
saveData.Id = ID;
var payloadData = new Godot.Collections.Dictionary<string, Variant>();
for (int i = 0; i < _slots.Count; i++)
@@ -196,20 +192,15 @@ public partial class InventoryInstance : Node, ISaveable
}
}
saveData.JsonPayload = Json.Stringify(payloadData, indent: "\t");
SavegameService.AppendSave(saveData);
SavegameService.AppendDataToSave(SCENE_NAME, ID, payloadData);
}
public void LoadFromSaveData()
{
var sceneName = SCENE_NAME;
var id = ID;
string jsonPayload = SavegameService.GetSaveData(sceneName, id);
if (string.IsNullOrEmpty(jsonPayload))
return;
Godot.Collections.Dictionary<string, Variant> save = Json.ParseString(jsonPayload).AsGodotDictionary<string, Variant>();
Godot.Collections.Dictionary<string, Variant> save = SavegameService.GetSaveData(sceneName, id);
if (save.Count > 0)
{