Move when 'SendNotification' happens so it'll be before the solo duty dialog
authorLiza Carvelli <liza@carvel.li>
Mon, 4 Nov 2024 19:10:35 +0000 (20:10 +0100)
committerLiza Carvelli <liza@carvel.li>
Mon, 4 Nov 2024 19:10:35 +0000 (20:10 +0100)
Questionable/Controller/Steps/Common/SendNotification.cs
Questionable/Controller/Steps/Shared/WaitAtEnd.cs
Questionable/QuestionablePlugin.cs

index 76b8a810b77671c5c4e391f8035c2f507bacf658..5edb743cd42631772e739bd0ab1fd25ed50bd6ef 100644 (file)
@@ -1,13 +1,36 @@
-using Dalamud.Game.Text;
+using System.Collections.Generic;
+using Dalamud.Game.Text;
 using Dalamud.Game.Text.SeStringHandling;
 using Dalamud.Plugin.Services;
+using Questionable.Data;
 using Questionable.External;
+using Questionable.Model;
 using Questionable.Model.Questing;
 
 namespace Questionable.Controller.Steps.Common;
 
 internal static class SendNotification
 {
+    internal sealed class Factory(
+        Configuration configuration,
+        TerritoryData territoryData) : SimpleTaskFactory
+    {
+        public override ITask? CreateTask(Quest quest, QuestSequence sequence, QuestStep step)
+        {
+            return step.InteractionType switch
+            {
+                EInteractionType.Snipe when !configuration.General.AutomaticallyCompleteSnipeTasks =>
+                    new Task(step.InteractionType, step.Comment),
+                EInteractionType.Duty =>
+                    new Task(step.InteractionType, step.ContentFinderConditionId.HasValue
+                        ? territoryData.GetContentFinderConditionName(step.ContentFinderConditionId.Value)
+                        : step.Comment),
+                EInteractionType.SinglePlayerDuty => new Task(step.InteractionType, quest.Info.Name),
+                _ => null,
+            };
+        }
+    }
+
     internal sealed record Task(EInteractionType InteractionType, string? Comment) : ITask
     {
         public override string ToString() => "SendNotification";
index 84d2e1ca95183cf4171875d4c17c8f786eae9749..d64c009bf503ddf3eb3a7d1fd3b528049ffa82c8 100644 (file)
@@ -6,7 +6,6 @@ using System.Numerics;
 using Dalamud.Game.ClientState.Conditions;
 using Dalamud.Plugin.Services;
 using Questionable.Controller.Steps.Common;
-using Questionable.Controller.Steps.Interactions;
 using Questionable.Controller.Utils;
 using Questionable.Data;
 using Questionable.Functions;
@@ -20,8 +19,7 @@ internal static class WaitAtEnd
     internal sealed class Factory(
         IClientState clientState,
         ICondition condition,
-        TerritoryData territoryData,
-        Configuration configuration)
+        TerritoryData territoryData)
         : ITaskFactory
     {
         public IEnumerable<ITask> CreateAllTasks(Quest quest, QuestSequence sequence, QuestStep step)
@@ -49,28 +47,12 @@ internal static class WaitAtEnd
 
                 case EInteractionType.WaitForManualProgress:
                 case EInteractionType.Instruction:
-                    return [new WaitNextStepOrSequence()];
-
                 case EInteractionType.Snipe:
-                    if (configuration.General.AutomaticallyCompleteSnipeTasks)
-                        return [new WaitNextStepOrSequence()];
-                    else
-                        return [
-                            new SendNotification.Task(step.InteractionType, step.Comment),
-                            new WaitNextStepOrSequence()
-                        ];
+                    return [new WaitNextStepOrSequence()];
 
                 case EInteractionType.Duty:
-                    return [
-                        new SendNotification.Task(step.InteractionType, step.ContentFinderConditionId.HasValue ? territoryData.GetContentFinderConditionName(step.ContentFinderConditionId.Value) : step.Comment),
-                        new EndAutomation(),
-                    ];
-
                 case EInteractionType.SinglePlayerDuty:
-                    return [
-                        new SendNotification.Task(step.InteractionType, quest.Info.Name),
-                        new EndAutomation()
-                    ];
+                    return [new EndAutomation()];
 
                 case EInteractionType.WalkTo:
                 case EInteractionType.Jump:
index b97158c61a9dc2e5f8424da32d5d996a16934645..9289b1206b5cd9bbf7fd7cf959ccd899667bcc43 100644 (file)
@@ -163,6 +163,8 @@ public sealed class QuestionablePlugin : IDalamudPlugin
         serviceCollection.AddTaskFactoryAndExecutor<MoveTo.MoveTask, MoveTo.Factory, MoveTo.MoveExecutor>();
         serviceCollection.AddTaskExecutor<MoveTo.WaitForNearDataId, MoveTo.WaitForNearDataIdExecutor>();
         serviceCollection.AddTaskExecutor<MoveTo.LandTask, MoveTo.LandExecutor>();
+        serviceCollection
+            .AddTaskFactoryAndExecutor<SendNotification.Task, SendNotification.Factory, SendNotification.Executor>();
 
         serviceCollection
             .AddTaskFactoryAndExecutor<NextQuest.SetQuestTask, NextQuest.Factory, NextQuest.NextQuestExecutor>();
@@ -206,7 +208,6 @@ public sealed class QuestionablePlugin : IDalamudPlugin
         serviceCollection.AddTaskExecutor<InitiateLeve.Initiate, InitiateLeve.InitiateExecutor>();
         serviceCollection.AddTaskExecutor<InitiateLeve.SelectDifficulty, InitiateLeve.SelectDifficultyExecutor>();
 
-        serviceCollection.AddTaskExecutor<SendNotification.Task, SendNotification.Executor>();
         serviceCollection.AddTaskExecutor<WaitCondition.Task, WaitCondition.WaitConditionExecutor>();
         serviceCollection.AddTaskFactory<WaitAtEnd.Factory>();
         serviceCollection.AddTaskExecutor<WaitAtEnd.WaitDelay, WaitAtEnd.WaitDelayExecutor>();