Add Inventory.EquippedItem signal
parent
dde1d18bc5
commit
b13eb48b99
|
@ -20,6 +20,9 @@ public partial class Inventory : Node2D
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void UsedItemEventHandler(Item item);
|
public delegate void UsedItemEventHandler(Item item);
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void EquippedItemEventHandler(Item newItem, Item prevItem);
|
||||||
|
|
||||||
public const int MaxCapacity = 3;
|
public const int MaxCapacity = 3;
|
||||||
|
|
||||||
private Item _selectedItem;
|
private Item _selectedItem;
|
||||||
|
@ -87,7 +90,8 @@ public partial class Inventory : Node2D
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_selectedItem?.Unequip(Character);
|
Item prevItem = _selectedItem;
|
||||||
|
prevItem?.Unequip(Character);
|
||||||
_selectedIndex = index;
|
_selectedIndex = index;
|
||||||
|
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
|
@ -100,6 +104,8 @@ public partial class Inventory : Node2D
|
||||||
_selectedItem = null;
|
_selectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EmitSignal(SignalName.EquippedItem, prevItem, _selectedItem);
|
||||||
|
|
||||||
GD.Print($"Inventory: {index} is new selected index.");
|
GD.Print($"Inventory: {index} is new selected index.");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue