Massive refactor (inventory menu still a little broken but its Good Enough)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user