1
0
forked from liza/Questionable

Add 'EquipRecommended' task

This commit is contained in:
Liza 2024-08-10 18:14:15 +02:00
parent d5e62ebc15
commit 2c77dc479f
Signed by: liza
GPG Key ID: 7199F8D727D55F67
5 changed files with 54 additions and 0 deletions

View File

@ -110,6 +110,7 @@
"Combat", "Combat",
"UseItem", "UseItem",
"EquipItem", "EquipItem",
"EquipRecommended",
"Say", "Say",
"Emote", "Emote",
"Action", "Action",

View File

@ -16,6 +16,7 @@ public sealed class InteractionTypeConverter() : EnumConverter<EInteractionType>
{ EInteractionType.Combat, "Combat" }, { EInteractionType.Combat, "Combat" },
{ EInteractionType.UseItem, "UseItem" }, { EInteractionType.UseItem, "UseItem" },
{ EInteractionType.EquipItem, "EquipItem" }, { EInteractionType.EquipItem, "EquipItem" },
{ EInteractionType.EquipRecommended, "EquipRecommended" },
{ EInteractionType.Say, "Say" }, { EInteractionType.Say, "Say" },
{ EInteractionType.Emote, "Emote" }, { EInteractionType.Emote, "Emote" },
{ EInteractionType.Action, "Action" }, { EInteractionType.Action, "Action" },

View File

@ -15,6 +15,7 @@ public enum EInteractionType
Combat, Combat,
UseItem, UseItem,
EquipItem, EquipItem,
EquipRecommended,
Say, Say,
Emote, Emote,
Action, Action,

View File

@ -0,0 +1,50 @@
using System;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
using Microsoft.Extensions.DependencyInjection;
using Questionable.Model;
using Questionable.Model.Questing;
namespace Questionable.Controller.Steps.Interactions;
internal static class EquipRecommended
{
internal sealed class Factory(IServiceProvider serviceProvider) : ITaskFactory
{
public ITask? CreateTask(Quest quest, QuestSequence sequence, QuestStep step)
{
if (step.InteractionType != EInteractionType.EquipRecommended)
return null;
return serviceProvider.GetRequiredService<DoEquipRecommended>();
}
}
internal sealed unsafe class DoEquipRecommended(IClientState clientState) : ITask
{
private bool _equipped;
public bool Start()
{
RecommendEquipModule.Instance()->SetupForClassJob((byte)clientState.LocalPlayer!.ClassJob.Id);
return true;
}
public ETaskResult Update()
{
if (RecommendEquipModule.Instance()->IsUpdating)
return ETaskResult.StillRunning;
if (!_equipped)
{
RecommendEquipModule.Instance()->EquipRecommendedGear();
_equipped = true;
return ETaskResult.StillRunning;
}
return ETaskResult.TaskComplete;
}
public override string ToString() => "EquipRecommended";
}
}

View File

@ -151,6 +151,7 @@ public sealed class QuestionablePlugin : IDalamudPlugin
.AddTaskWithFactory<UseItem.Factory, UseItem.UseOnGround, UseItem.UseOnObject, UseItem.Use, .AddTaskWithFactory<UseItem.Factory, UseItem.UseOnGround, UseItem.UseOnObject, UseItem.Use,
UseItem.UseOnPosition>(); UseItem.UseOnPosition>();
serviceCollection.AddTaskWithFactory<EquipItem.Factory, EquipItem.DoEquip>(); serviceCollection.AddTaskWithFactory<EquipItem.Factory, EquipItem.DoEquip>();
serviceCollection.AddTaskWithFactory<EquipRecommended.Factory, EquipRecommended.DoEquipRecommended>();
serviceCollection.AddTaskWithFactory<TurnInDelivery.Factory, TurnInDelivery.SatisfactionSupplyTurnIn>(); serviceCollection.AddTaskWithFactory<TurnInDelivery.Factory, TurnInDelivery.SatisfactionSupplyTurnIn>();
serviceCollection serviceCollection
.AddTaskWithFactory<SinglePlayerDuty.Factory, SinglePlayerDuty.DisableYesAlready, .AddTaskWithFactory<SinglePlayerDuty.Factory, SinglePlayerDuty.DisableYesAlready,