Add Inventory.EquippedItem signal

pull/37/head
John Montagu, the 4th Earl of Sandvich 2024-05-29 14:35:41 -07:00
parent dde1d18bc5
commit b13eb48b99
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
1 changed files with 7 additions and 1 deletions

View File

@ -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;