Tools get deactivated from animation when switching to an empty slot in the inventory. Also fixed layering (AGAIN)

This commit is contained in:
2025-08-20 00:26:58 +02:00
parent 378bf45c49
commit 871e1856f1
5 changed files with 13 additions and 10 deletions
@@ -1,4 +1,3 @@
using System.Threading.Tasks;
using Babushka.scripts.CSharp.Common.Inventory;
using Babushka.scripts.CSharp.Common.Services;
using Godot;
@@ -46,23 +46,21 @@ public partial class VesnaBehaviour2D : Node
{
InventorySlot currentSlot = InventoryManager.Instance.GetCurrentSelectedSlot();
ItemInstance? currentItem = currentSlot.itemInstance;
if (currentItem == null)
return;
int toolId = -1;
if (currentItem.blueprint == _hoe)
if (currentItem != null && currentItem.blueprint == _hoe)
{
toolId = 0;
}
if (currentItem.blueprint == _wateringCan)
if (currentItem != null && currentItem.blueprint == _wateringCan)
{
toolId = 1;
}
ActivateTool(toolId);
_vesnaAnimations.ActivateTool(toolId >= 0, toolId);
EmitSignal(SignalName.InventorySelectionChanged, toolId);
}
@@ -1,4 +1,5 @@
using Godot;
namespace Babushka.scripts.CSharp.Common.Inventory;
[GlobalClass]
@@ -18,7 +19,7 @@ public partial class ItemResource : Resource
[Export]
public PackedScene? itemPrefab;
public ItemResource()
{
name = "";
@@ -27,3 +28,4 @@ public partial class ItemResource : Resource
itemPrefab = null;
}
}