Fixed Tomato farming (again)

This commit is contained in:
2025-09-17 15:07:17 +02:00
parent 975dd45c94
commit 2cb605261e
9 changed files with 57 additions and 29 deletions
@@ -17,6 +17,9 @@ public partial class InventoryInstance : Node
[Signal]
public delegate void InventoryContentsChangedEventHandler();
/// <summary>
/// The total amount of Inventoryslots in the inventory (empty and occupied).
/// </summary>
[Export]
public int SlotAmount
{
@@ -49,7 +52,7 @@ public partial class InventoryInstance : Node
private InventoryActionResult AddItemAndStackRecursive(ItemInstance newItem, int slotSearch)
{
if (newItem.blueprint == null || newItem.amount == 0)
return InventoryActionResult.SourceDoesNotExists;
return InventoryActionResult.SourceDoesNotExist;
var slotIndex = -1;
// find stackable slot
@@ -97,7 +100,7 @@ public partial class InventoryInstance : Node
if (inventorySlot < 0 || inventorySlot >= _slots.Count)
{
itemInstance = null;
return InventoryActionResult.SourceDoesNotExists;
return InventoryActionResult.SourceDoesNotExist;
}
if (_slots[inventorySlot].IsEmpty())
@@ -107,6 +110,10 @@ public partial class InventoryInstance : Node
}
itemInstance = _slots[inventorySlot].itemInstance;
if (itemInstance == null)
return InventoryActionResult.SourceDoesNotExist;
itemInstance.amount -= 1;
_slots[inventorySlot].itemInstance = null;
EmitSignal(SignalName.InventoryContentsChanged);
return InventoryActionResult.Success;
@@ -120,7 +127,7 @@ public partial class InventoryInstance : Node
public InventoryActionResult AddItemToSlot(ItemInstance itemInstance, int destinationSlot)
{
if (destinationSlot < 0 || destinationSlot >= _slots.Count)
return InventoryActionResult.DestinationDoesNotExists;
return InventoryActionResult.DestinationDoesNotExist;
if (!_slots[destinationSlot].IsEmpty())
return InventoryActionResult.DestinationFull;