lockedReasonn = $"{classJob} not unlocked";
else if (quantityToGather == 0)
lockedReasonn = "No allowances";
+ else if (quantityToGather > _gameFunctions.GetFreeInventorySlots())
+ lockedReasonn = "Inventory full";
else if (_gameFunctions.IsOccupied())
lockedReasonn = "Can't be used while interacting";
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Component.GUI;
using LLib.GameUI;
+using Questionable.Functions;
using Questionable.Model.Gathering;
namespace Questionable.Controller.Steps.Gathering;
internal sealed class DoGather(
GatheringController gatheringController,
+ GameFunctions gameFunctions,
IGameGui gameGui,
ICondition condition) : ITask
{
if (gatheringController.HasNodeDisappeared(_currentNode))
return ETaskResult.TaskComplete;
+ if (gameFunctions.GetFreeInventorySlots() == 0)
+ throw new TaskException("Inventory full");
+
if (condition[ConditionFlag.Gathering])
{
if (gameGui.TryGetAddonByName("GatheringMasterpiece", out AtkUnitBase* _))
}
}
+ if (gameFunctions.GetFreeInventorySlots() == 0)
+ throw new TaskException("Inventory full");
+
NodeCondition? nodeCondition = GetNodeCondition();
if (nodeCondition == null)
return ETaskResult.TaskComplete;
LAddon.IsAddonReady(fade) &&
fade->IsVisible;
}
+
+ public int GetFreeInventorySlots()
+ {
+ InventoryManager* inventoryManager = InventoryManager.Instance();
+ if (inventoryManager == null)
+ return 0;
+
+ int slots = 0;
+ for (InventoryType inventoryType = InventoryType.Inventory1;
+ inventoryType <= InventoryType.Inventory4;
+ ++inventoryType)
+ {
+ InventoryContainer* inventoryContainer = inventoryManager->GetInventoryContainer(inventoryType);
+ if (inventoryContainer == null)
+ continue;
+
+ for (int i = 0; i < inventoryContainer->Size; ++i)
+ {
+ InventoryItem* item = inventoryContainer->GetInventorySlot(i);
+ if (item == null || item->ItemId == 0)
+ ++slots;
+ }
+ }
+
+ return slots;
+ }
}