Automatically equip recommended gear for duty/singleplayerduty/combat
This commit is contained in:
parent
82c8826e0f
commit
2dfc774da1
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Questionable.Model;
|
using Questionable.Model;
|
||||||
@ -20,7 +21,20 @@ internal static class EquipRecommended
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal sealed unsafe class DoEquipRecommended(IClientState clientState) : ITask
|
internal sealed class BeforeDutyOrInstance(IServiceProvider serviceProvider) : ITaskFactory
|
||||||
|
{
|
||||||
|
public ITask? CreateTask(Quest quest, QuestSequence sequence, QuestStep step)
|
||||||
|
{
|
||||||
|
if (step.InteractionType != EInteractionType.Duty &&
|
||||||
|
step.InteractionType != EInteractionType.SinglePlayerDuty &&
|
||||||
|
step.InteractionType != EInteractionType.Combat)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return serviceProvider.GetRequiredService<DoEquipRecommended>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed unsafe class DoEquipRecommended(IClientState clientState, IChatGui chatGui) : ITask
|
||||||
{
|
{
|
||||||
private bool _equipped;
|
private bool _equipped;
|
||||||
|
|
||||||
@ -32,12 +46,43 @@ internal static class EquipRecommended
|
|||||||
|
|
||||||
public ETaskResult Update()
|
public ETaskResult Update()
|
||||||
{
|
{
|
||||||
if (RecommendEquipModule.Instance()->IsUpdating)
|
var recommendedEquipModule = RecommendEquipModule.Instance();
|
||||||
|
if (recommendedEquipModule->IsUpdating)
|
||||||
return ETaskResult.StillRunning;
|
return ETaskResult.StillRunning;
|
||||||
|
|
||||||
if (!_equipped)
|
if (!_equipped)
|
||||||
{
|
{
|
||||||
RecommendEquipModule.Instance()->EquipRecommendedGear();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAllEquipped)
|
||||||
|
{
|
||||||
|
chatGui.Print("Equipping recommended gear.", "Questionable");
|
||||||
|
recommendedEquipModule->EquipRecommendedGear();
|
||||||
|
}
|
||||||
|
|
||||||
_equipped = true;
|
_equipped = true;
|
||||||
return ETaskResult.StillRunning;
|
return ETaskResult.StillRunning;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using Questionable.Controller;
|
using Questionable.Controller;
|
||||||
using Questionable.Controller.CombatModules;
|
using Questionable.Controller.CombatModules;
|
||||||
using Questionable.Controller.NavigationOverrides;
|
using Questionable.Controller.NavigationOverrides;
|
||||||
|
using Questionable.Controller.Steps;
|
||||||
using Questionable.Controller.Steps.Shared;
|
using Questionable.Controller.Steps.Shared;
|
||||||
using Questionable.Controller.Steps.Common;
|
using Questionable.Controller.Steps.Common;
|
||||||
using Questionable.Controller.Steps.Gathering;
|
using Questionable.Controller.Steps.Gathering;
|
||||||
@ -128,6 +129,7 @@ public sealed class QuestionablePlugin : IDalamudPlugin
|
|||||||
|
|
||||||
// task factories
|
// task factories
|
||||||
serviceCollection.AddTaskWithFactory<StepDisabled.Factory, StepDisabled.Task>();
|
serviceCollection.AddTaskWithFactory<StepDisabled.Factory, StepDisabled.Task>();
|
||||||
|
serviceCollection.AddSingleton<ITaskFactory, EquipRecommended.BeforeDutyOrInstance>();
|
||||||
serviceCollection.AddTaskWithFactory<GatheringRequiredItems.Factory, GatheringRequiredItems.StartGathering>();
|
serviceCollection.AddTaskWithFactory<GatheringRequiredItems.Factory, GatheringRequiredItems.StartGathering>();
|
||||||
serviceCollection.AddTaskWithFactory<AetheryteShortcut.Factory, AetheryteShortcut.UseAetheryteShortcut>();
|
serviceCollection.AddTaskWithFactory<AetheryteShortcut.Factory, AetheryteShortcut.UseAetheryteShortcut>();
|
||||||
serviceCollection.AddTaskWithFactory<SkipCondition.Factory, SkipCondition.CheckSkip>();
|
serviceCollection.AddTaskWithFactory<SkipCondition.Factory, SkipCondition.CheckSkip>();
|
||||||
|
Loading…
Reference in New Issue
Block a user