Made Player inventory saveable

This commit is contained in:
jonathan
2026-02-04 22:01:26 +01:00
parent a6fa4315dc
commit c7142111ed
4 changed files with 70 additions and 5 deletions
@@ -3,6 +3,7 @@ using Babushka.scripts.CSharp.Common.Farming;
using Babushka.scripts.CSharp.Common.Inventory;
using Babushka.scripts.CSharp.GameEntity.Management;
using Godot;
using Newtonsoft.Json.Linq;
namespace Babushka.scripts.CSharp.GameEntity.Entities;
@@ -33,4 +34,18 @@ public class VesnaEntity : PositionalEntity
node.player2d.Initialize(this);
parent.AddChild(node);
}
public override void SaveEntity(JObject json)
{
base.SaveEntity(json);
json["slot"] = CurrentSelectedSlotIndex;
json["inventory"] = inventory.SaveToJson();
}
public override void LoadEntity(JObject json)
{
base.LoadEntity(json);
CurrentSelectedSlotIndex = json.Value<int>("slot");
inventory.LoadFromJson(json.Value<JObject>("inventory")!);
}
}