Created ISaveable interface and made existing saveable classes inherit from it.

pull/32/head
kziolkowski 2 months ago
parent 4ed6f4e7d9
commit 4bbaab1a2a

@ -1,4 +1,3 @@
using System;
using System.Linq;
using Babushka.scripts.CSharp.Common.Services;
using Godot;

@ -13,7 +13,7 @@ namespace Babushka.scripts.CSharp.Common.Farming;
/// Defines the behaviour of the field, i.e. interactions, states and effects.
/// </summary>
[GlobalClass]
public partial class FieldBehaviour2D : Sprite2D
public partial class FieldBehaviour2D : Sprite2D, ISaveable
{
[ExportGroup("Persistence")]
[Export] public string SaveId = "";

@ -7,7 +7,7 @@ using Babushka.scripts.CSharp.Common.Savegame;
namespace Babushka.scripts.CSharp.Common.Inventory;
public partial class InventoryInstance : Node
public partial class InventoryInstance : Node, ISaveable
{
private List<InventorySlot> _slots = new();
public IReadOnlyList<InventorySlot> Slots => _slots;

@ -0,0 +1,17 @@
namespace Babushka.scripts.CSharp.Common.Savegame;
/// <summary>
/// Defines the behaviour of Nodes that have fields that should save / load to disk.
/// </summary>
public interface ISaveable
{
/// <summary>
/// Adds or updates the field data that shall be stored to disk.
/// </summary>
public void UpdateSaveData();
/// <summary>
/// Loads the field data from disk.
/// </summary>
public void LoadFromSaveData();
}
Loading…
Cancel
Save