Made Player inventory saveable
This commit is contained in:
@@ -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")!);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user