diff --git a/Items/Inventory.cs b/Items/Inventory.cs index 772d6e4..e958821 100644 --- a/Items/Inventory.cs +++ b/Items/Inventory.cs @@ -20,6 +20,9 @@ public partial class Inventory : Node2D [Signal] public delegate void UsedItemEventHandler(Item item); + [Signal] + public delegate void EquippedItemEventHandler(Item newItem, Item prevItem); + public const int MaxCapacity = 3; private Item _selectedItem; @@ -87,7 +90,8 @@ public partial class Inventory : Node2D return false; } - _selectedItem?.Unequip(Character); + Item prevItem = _selectedItem; + prevItem?.Unequip(Character); _selectedIndex = index; if (index >= 0) @@ -100,6 +104,8 @@ public partial class Inventory : Node2D _selectedItem = null; } + EmitSignal(SignalName.EquippedItem, prevItem, _selectedItem); + GD.Print($"Inventory: {index} is new selected index."); return true;