using System; using Dalamud.Game.ClientState.Objects.Enums; using Microsoft.Extensions.Logging; using Questionable.Functions; using Questionable.Model; using Questionable.Model.Common; using Questionable.Model.Questing; namespace Questionable.Controller.Steps.Interactions; internal static class AethernetShard { internal sealed class Factory : SimpleTaskFactory { public override ITask? CreateTask(Quest quest, QuestSequence sequence, QuestStep step) { if (step.InteractionType != EInteractionType.AttuneAethernetShard) { return null; } ArgumentNullException.ThrowIfNull(step.AethernetShard, "step.AethernetShard"); return new Attune(step.AethernetShard.Value); } } internal sealed record Attune(EAetheryteLocation AetheryteLocation) : ITask { public bool ShouldRedoOnInterrupt() { return true; } public override string ToString() { return $"AttuneAethernetShard({AetheryteLocation})"; } } internal sealed class DoAttune(AetheryteFunctions aetheryteFunctions, GameFunctions gameFunctions, ILogger logger) : TaskExecutor() { protected override bool Start() { if (!aetheryteFunctions.IsAetheryteUnlocked(base.Task.AetheryteLocation)) { logger.LogInformation("Attuning to aethernet shard {AethernetShard}", base.Task.AetheryteLocation); base.ProgressContext = InteractionProgressContext.FromActionUseOrDefault(() => gameFunctions.InteractWith((uint)base.Task.AetheryteLocation, ObjectKind.Aetheryte)); return true; } logger.LogInformation("Already attuned to aethernet shard {AethernetShard}", base.Task.AetheryteLocation); return false; } public override ETaskResult Update() { if (!aetheryteFunctions.IsAetheryteUnlocked(base.Task.AetheryteLocation)) { return ETaskResult.StillRunning; } return ETaskResult.TaskComplete; } public override bool ShouldInterruptOnDamage() { return true; } } }