Made items activate directly when picked up
This commit is contained in:
@@ -26,8 +26,18 @@ public partial class VesnaBehaviour2D : Node
|
||||
_inventoryInstance = _inventoryManager.playerInventory;
|
||||
_inventoryManager.SlotIndexChanged += HandleInventorySelectedSlotIndexChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when picking up an item.
|
||||
/// Makes sure that item animations are also updated when they are occupying a currently empty spot.
|
||||
/// </summary>
|
||||
public void HandlePickUp()
|
||||
{
|
||||
//Calls the same event handler as the inventory to ensure the currently selected item is updated in the animation.
|
||||
HandleInventorySelectedSlotIndexChanged(0);
|
||||
}
|
||||
|
||||
private void HandleInventorySelectedSlotIndexChanged(int newIndex)
|
||||
private void HandleInventorySelectedSlotIndexChanged(int newIndex = 0)
|
||||
{
|
||||
InventorySlot currentSlot = InventoryManager.Instance.GetCurrentSelectedSlot();
|
||||
ItemInstance? currentItem = currentSlot.itemInstance;
|
||||
|
||||
@@ -11,6 +11,8 @@ public partial class ItemOnGround2D : Node
|
||||
[Export] public bool IsActive = true;
|
||||
|
||||
private int pickUpCounter = 0;
|
||||
|
||||
[Signal] public delegate void SuccessfulPickUpEventHandler();
|
||||
|
||||
private Label _itemLabel => GetNode<Label>("ItemLabel");
|
||||
private Label _pickupErrorLabel => GetNode<Label>("PickupErrorLabel");
|
||||
@@ -38,6 +40,7 @@ public partial class ItemOnGround2D : Node
|
||||
return;
|
||||
|
||||
var result = InventoryManager.Instance.CollectItem(itemInstance.Clone());
|
||||
EmitSignal(SignalName.SuccessfulPickUp);
|
||||
if (result == InventoryActionResult.Success)
|
||||
{
|
||||
if (!_infiniteSupply)
|
||||
|
||||
Reference in New Issue
Block a user