Massive refactor (inventory menu still a little broken but its Good Enough)

This commit is contained in:
2024-09-12 02:24:14 -07:00
parent 149c8d9571
commit b4662a0c7b
94 changed files with 1066 additions and 825 deletions

View File

@@ -11,14 +11,12 @@ public partial class Accessory : Node3D, IInventoryItem, IEquipable
{
public override void _Notification(int what) => this.Notify(what);
public Guid ID { get; } = new Guid();
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
public InventoryItemInfo Info => AccessoryInfo;
public InventoryItemStats Info => AccessoryInfo;
[Export]
public AccessoryInfo AccessoryInfo { get; set; } = new AccessoryInfo();
public AccessoryStats AccessoryInfo { get; set; } = new AccessoryStats();
[Node] public Sprite3D Sprite { get; set; } = default!;
@@ -32,21 +30,18 @@ public partial class Accessory : Node3D, IInventoryItem, IEquipable
public void Throw()
{
GameRepo.InventoryItems.Value.Remove(this);
GameRepo.PlayerData.Inventory.Remove(this);
}
public void Drop()
{
GameRepo.InventoryItems.Value.Remove(this);
GameRepo.PlayerData.Inventory.Remove(this);
}
public void OnEntered(Node3D body)
{
if (GameRepo.InventoryItems.Value.Count() >= GameRepo.MaxItemSize)
return;
var inventoryList = GameRepo.InventoryItems.Value.Append(this).ToList();
GameRepo.InventoryItems.OnNext(inventoryList);
QueueFree();
var isAdded = GameRepo.PlayerData.Inventory.TryAdd(this);
if (isAdded)
QueueFree();
}
}