68 lines
1.7 KiB
C#
68 lines
1.7 KiB
C#
using System.Linq;
|
|
using Dalamud.Plugin.Services;
|
|
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
|
using LLib.GameData;
|
|
using Questionable.Controller.Steps.Common;
|
|
using Questionable.Data;
|
|
using Questionable.Model;
|
|
using Questionable.Model.Questing;
|
|
|
|
namespace Questionable.Controller.Steps.Shared;
|
|
|
|
internal static class SwitchClassJob
|
|
{
|
|
internal sealed class Factory(ClassJobUtils classJobUtils) : SimpleTaskFactory()
|
|
{
|
|
public override ITask? CreateTask(Quest quest, QuestSequence sequence, QuestStep step)
|
|
{
|
|
if (step.InteractionType != EInteractionType.SwitchClass)
|
|
{
|
|
return null;
|
|
}
|
|
return new Task(classJobUtils.AsIndividualJobs(step.TargetClass, quest.Id).Single());
|
|
}
|
|
}
|
|
|
|
internal sealed record Task(EClassJob ClassJob) : ITask
|
|
{
|
|
public override string ToString()
|
|
{
|
|
return $"SwitchJob({ClassJob})";
|
|
}
|
|
}
|
|
|
|
internal sealed class SwitchClassJobExecutor(IClientState clientState) : AbstractDelayedTaskExecutor<Task>()
|
|
{
|
|
protected unsafe override bool StartInternal()
|
|
{
|
|
if (clientState.LocalPlayer.ClassJob.RowId == (uint)base.Task.ClassJob)
|
|
{
|
|
return false;
|
|
}
|
|
RaptureGearsetModule* ptr = RaptureGearsetModule.Instance();
|
|
if (ptr != null)
|
|
{
|
|
for (int i = 0; i < 100; i++)
|
|
{
|
|
RaptureGearsetModule.GearsetEntry* gearset = ptr->GetGearset(i);
|
|
if (gearset->ClassJob == (byte)base.Task.ClassJob)
|
|
{
|
|
ptr->EquipGearset(gearset->Id, 0);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
throw new TaskException($"No gearset found for {base.Task.ClassJob}");
|
|
}
|
|
|
|
protected override ETaskResult UpdateInternal()
|
|
{
|
|
return ETaskResult.TaskComplete;
|
|
}
|
|
|
|
public override bool ShouldInterruptOnDamage()
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|