Created ISaveable interface and made existing saveable classes inherit from it.
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Babushka.scripts.CSharp.Common.Services;
|
using Babushka.scripts.CSharp.Common.Services;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Babushka.scripts.CSharp.Common.Farming;
|
|||||||
/// Defines the behaviour of the field, i.e. interactions, states and effects.
|
/// Defines the behaviour of the field, i.e. interactions, states and effects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[GlobalClass]
|
[GlobalClass]
|
||||||
public partial class FieldBehaviour2D : Sprite2D
|
public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
||||||
{
|
{
|
||||||
[ExportGroup("Persistence")]
|
[ExportGroup("Persistence")]
|
||||||
[Export] public string SaveId = "";
|
[Export] public string SaveId = "";
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using Babushka.scripts.CSharp.Common.Savegame;
|
|||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Inventory;
|
namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||||
|
|
||||||
public partial class InventoryInstance : Node
|
public partial class InventoryInstance : Node, ISaveable
|
||||||
{
|
{
|
||||||
private List<InventorySlot> _slots = new();
|
private List<InventorySlot> _slots = new();
|
||||||
public IReadOnlyList<InventorySlot> Slots => _slots;
|
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();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user