📝 added documentation comments
This commit is contained in:
@@ -179,9 +179,9 @@ public partial class FieldBehaviour2D : Sprite2D
|
|||||||
{
|
{
|
||||||
_currentPlant.Field = this;
|
_currentPlant.Field = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region SAVE AND LOAD
|
||||||
|
|
||||||
public void UpdateSaveData()
|
public void UpdateSaveData()
|
||||||
{
|
{
|
||||||
@@ -258,7 +258,7 @@ public partial class FieldBehaviour2D : Sprite2D
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ using System;
|
|||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Savegame;
|
namespace Babushka.scripts.CSharp.Common.Savegame;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Central structure for SaveData entries.
|
||||||
|
/// SceneName and ID are later combined and used as keys for the save system.
|
||||||
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class SaveData
|
public class SaveData
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ using FileAccess = Godot.FileAccess;
|
|||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Savegame;
|
namespace Babushka.scripts.CSharp.Common.Savegame;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the saving and loading of game states.
|
||||||
|
/// Holds the central SaveData object that serves as a temporary SaveFile.
|
||||||
|
/// Automatically writes to disk on every scene change.
|
||||||
|
/// </summary>
|
||||||
public static class SavegameService
|
public static class SavegameService
|
||||||
{
|
{
|
||||||
public static readonly string SavePath = "res://savegame/savegame.json";
|
public static readonly string SavePath = "res://savegame/savegame.json";
|
||||||
@@ -14,6 +19,10 @@ public static class SavegameService
|
|||||||
public static bool _loaded = false;
|
public static bool _loaded = false;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds or overwrites an entry in the SaveData dictionary.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="saveData"></param>
|
||||||
public static void AppendSave(SaveData saveData)
|
public static void AppendSave(SaveData saveData)
|
||||||
{
|
{
|
||||||
string key = string.Concat(saveData.SceneName, "_", saveData.Id);
|
string key = string.Concat(saveData.SceneName, "_", saveData.Id);
|
||||||
@@ -29,6 +38,13 @@ public static class SavegameService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks the SaveData dictionary for an entry and returns the jsondata as a string for it.
|
||||||
|
/// Requires the scenename and object ID for lookup.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sceneName"></param>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static string GetSaveData(string sceneName, string id)
|
public static string GetSaveData(string sceneName, string id)
|
||||||
{
|
{
|
||||||
string saveData = "";
|
string saveData = "";
|
||||||
@@ -50,6 +66,9 @@ public static class SavegameService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes the contents of the current SaveData dictionary to disk as a json file.
|
||||||
|
/// </summary>
|
||||||
public static void Save()
|
public static void Save()
|
||||||
{
|
{
|
||||||
string json = Json.Stringify(SaveDatas, indent: "\t");
|
string json = Json.Stringify(SaveDatas, indent: "\t");
|
||||||
@@ -57,6 +76,9 @@ public static class SavegameService
|
|||||||
file.StoreString(json);
|
file.StoreString(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the current savegame file from disk and parses it into the SaveData dictionary.
|
||||||
|
/// </summary>
|
||||||
public static void Load()
|
public static void Load()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user