using System; using System.Collections.Generic; using System.Numerics; using Dalamud.Plugin.Services; using Microsoft.Extensions.Logging; using Questionable.Controller.Steps.Common; using Questionable.Data; using Questionable.Model; using Questionable.Model.Common; using Questionable.Model.Questing; namespace Questionable.Controller.Steps.Movement; internal static class MoveTo { internal sealed class Factory(IClientState clientState, AetheryteData aetheryteData, TerritoryData territoryData, ILogger logger) : ITaskFactory { public IEnumerable CreateAllTasks(Quest quest, QuestSequence sequence, QuestStep step) { if (step.Position.HasValue) { return CreateMoveTasks(step, step.Position.Value); } if (step != null && step.DataId.HasValue && step.StopDistance.HasValue) { return new global::_003C_003Ez__ReadOnlySingleElementList(new WaitForNearDataId(step.DataId.Value, step.StopDistance.Value)); } EAetheryteLocation valueOrDefault = default(EAetheryteLocation); bool flag; if (step != null) { EInteractionType interactionType = step.InteractionType; if ((uint)(interactionType - 4) <= 1u) { EAetheryteLocation? aetheryte = step.Aetheryte; if (aetheryte.HasValue) { valueOrDefault = aetheryte.GetValueOrDefault(); flag = true; goto IL_00a3; } } } flag = false; goto IL_00a3; IL_00a3: if (flag) { return CreateMoveTasks(step, aetheryteData.Locations[valueOrDefault]); } if (step != null && step.InteractionType == EInteractionType.AttuneAethernetShard) { EAetheryteLocation? aetheryte = step.AethernetShard; if (aetheryte.HasValue) { EAetheryteLocation valueOrDefault2 = aetheryte.GetValueOrDefault(); return CreateMoveTasks(step, aetheryteData.Locations[valueOrDefault2]); } } return Array.Empty(); } private IEnumerable CreateMoveTasks(QuestStep step, Vector3 destination) { if (step.InteractionType == EInteractionType.Jump && step.JumpDestination != null && (clientState.LocalPlayer.Position - step.JumpDestination.Position).Length() <= (step.JumpDestination.StopDistance ?? 1f)) { logger.LogInformation("We're at the jump destination, skipping movement"); yield break; } yield return new WaitCondition.Task(() => clientState.TerritoryType == step.TerritoryId, "Wait(territory: " + territoryData.GetNameAndId(step.TerritoryId) + ")"); if (!step.DisableNavmesh) { yield return new WaitNavmesh.Task(); } yield return new MoveTask(step, destination); if (step != null) { bool? fly = step.Fly; if (fly.HasValue && fly == true && (step.Land ?? false)) { yield return new LandTask(); } } } } }