Add a delay to equipping recommended gear for specific instances where ilvl calculation would otherwise be off

This commit is contained in:
Liza 2025-01-24 20:30:58 +01:00
parent 2ebc4b5a0d
commit ffccd347bd
Signed by: liza
GPG Key ID: 2C41B84815CF6445

View File

@ -43,7 +43,8 @@ internal static class EquipRecommended
internal sealed unsafe class DoEquipRecommended(IClientState clientState, IChatGui chatGui, ICondition condition)
: TaskExecutor<EquipTask>
{
private bool _equipped;
private bool _checkedOrTriggeredEquipmentUpdate;
private DateTime _continueAt = DateTime.MinValue;
protected override bool Start()
{
@ -60,8 +61,25 @@ internal static class EquipRecommended
if (recommendedEquipModule->IsUpdating)
return ETaskResult.StillRunning;
if (!_equipped)
if (!_checkedOrTriggeredEquipmentUpdate)
{
if (!IsAllRecommendeGearEquipped())
{
chatGui.Print("Equipping recommended gear.", CommandHandler.MessageTag, CommandHandler.TagColor);
recommendedEquipModule->EquipRecommendedGear();
_continueAt = DateTime.Now.AddSeconds(1);
}
_checkedOrTriggeredEquipmentUpdate = true;
return ETaskResult.StillRunning;
}
return DateTime.Now >= _continueAt ? ETaskResult.TaskComplete : ETaskResult.StillRunning;
}
private bool IsAllRecommendeGearEquipped()
{
var recommendedEquipModule = RecommendEquipModule.Instance();
InventoryManager* inventoryManager = InventoryManager.Instance();
InventoryContainer* equippedItems =
inventoryManager->GetInventoryContainer(InventoryType.EquippedItems);
@ -87,17 +105,7 @@ internal static class EquipRecommended
isAllEquipped = false;
}
if (!isAllEquipped)
{
chatGui.Print("Equipping recommended gear.", CommandHandler.MessageTag, CommandHandler.TagColor);
recommendedEquipModule->EquipRecommendedGear();
}
_equipped = true;
return ETaskResult.StillRunning;
}
return ETaskResult.TaskComplete;
return isAllEquipped;
}
public override bool ShouldInterruptOnDamage() => true;