Made items activate directly when picked up

This commit is contained in:
2025-07-05 13:18:19 +02:00
parent 48796de1ba
commit 600d9cfca1
3 changed files with 16 additions and 1 deletions
@@ -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;