Add a delay to equipping recommended gear for specific instances where ilvl calculation would otherwise be off
This commit is contained in:
parent
2ebc4b5a0d
commit
ffccd347bd
@ -43,7 +43,8 @@ internal static class EquipRecommended
|
|||||||
internal sealed unsafe class DoEquipRecommended(IClientState clientState, IChatGui chatGui, ICondition condition)
|
internal sealed unsafe class DoEquipRecommended(IClientState clientState, IChatGui chatGui, ICondition condition)
|
||||||
: TaskExecutor<EquipTask>
|
: TaskExecutor<EquipTask>
|
||||||
{
|
{
|
||||||
private bool _equipped;
|
private bool _checkedOrTriggeredEquipmentUpdate;
|
||||||
|
private DateTime _continueAt = DateTime.MinValue;
|
||||||
|
|
||||||
protected override bool Start()
|
protected override bool Start()
|
||||||
{
|
{
|
||||||
@ -60,44 +61,51 @@ internal static class EquipRecommended
|
|||||||
if (recommendedEquipModule->IsUpdating)
|
if (recommendedEquipModule->IsUpdating)
|
||||||
return ETaskResult.StillRunning;
|
return ETaskResult.StillRunning;
|
||||||
|
|
||||||
if (!_equipped)
|
if (!_checkedOrTriggeredEquipmentUpdate)
|
||||||
{
|
{
|
||||||
InventoryManager* inventoryManager = InventoryManager.Instance();
|
if (!IsAllRecommendeGearEquipped())
|
||||||
InventoryContainer* equippedItems =
|
|
||||||
inventoryManager->GetInventoryContainer(InventoryType.EquippedItems);
|
|
||||||
bool isAllEquipped = true;
|
|
||||||
foreach (var recommendedItemPtr in recommendedEquipModule->RecommendedItems)
|
|
||||||
{
|
|
||||||
var recommendedItem = recommendedItemPtr.Value;
|
|
||||||
if (recommendedItem == null || recommendedItem->ItemId == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
bool isEquipped = false;
|
|
||||||
for (int i = 0; i < equippedItems->Size; ++i)
|
|
||||||
{
|
|
||||||
var equippedItem = equippedItems->Items[i];
|
|
||||||
if (equippedItem.ItemId != 0 && equippedItem.ItemId == recommendedItem->ItemId)
|
|
||||||
{
|
|
||||||
isEquipped = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isEquipped)
|
|
||||||
isAllEquipped = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isAllEquipped)
|
|
||||||
{
|
{
|
||||||
chatGui.Print("Equipping recommended gear.", CommandHandler.MessageTag, CommandHandler.TagColor);
|
chatGui.Print("Equipping recommended gear.", CommandHandler.MessageTag, CommandHandler.TagColor);
|
||||||
recommendedEquipModule->EquipRecommendedGear();
|
recommendedEquipModule->EquipRecommendedGear();
|
||||||
|
_continueAt = DateTime.Now.AddSeconds(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_equipped = true;
|
_checkedOrTriggeredEquipmentUpdate = true;
|
||||||
return ETaskResult.StillRunning;
|
return ETaskResult.StillRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ETaskResult.TaskComplete;
|
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);
|
||||||
|
bool isAllEquipped = true;
|
||||||
|
foreach (var recommendedItemPtr in recommendedEquipModule->RecommendedItems)
|
||||||
|
{
|
||||||
|
var recommendedItem = recommendedItemPtr.Value;
|
||||||
|
if (recommendedItem == null || recommendedItem->ItemId == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bool isEquipped = false;
|
||||||
|
for (int i = 0; i < equippedItems->Size; ++i)
|
||||||
|
{
|
||||||
|
var equippedItem = equippedItems->Items[i];
|
||||||
|
if (equippedItem.ItemId != 0 && equippedItem.ItemId == recommendedItem->ItemId)
|
||||||
|
{
|
||||||
|
isEquipped = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isEquipped)
|
||||||
|
isAllEquipped = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isAllEquipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ShouldInterruptOnDamage() => true;
|
public override bool ShouldInterruptOnDamage() => true;
|
||||||
|
Loading…
Reference in New Issue
Block a user