Fix StartSingleQuest IPC
authorLiza Carvelli <liza@carvel.li>
Sat, 8 Mar 2025 01:11:38 +0000 (02:11 +0100)
committerLiza Carvelli <liza@carvel.li>
Sat, 8 Mar 2025 01:11:38 +0000 (02:11 +0100)
Questionable/Controller/ContextMenuController.cs
Questionable/Controller/GameUi/InteractionUiController.cs
Questionable/Controller/QuestController.cs
Questionable/Controller/Steps/Common/NextQuest.cs

index 45230c5..153dc2b 100644 (file)
@@ -181,7 +181,7 @@ internal sealed class ContextMenuController : IDisposable
                 }
             ];
             _questController.SetGatheringQuest(quest);
-            _questController.StartSingleQuest("SatisfactionSupply prepare gathering");
+            _questController.StartGatheringQuest("SatisfactionSupply prepare gathering");
         }
         else
             _chatGui.PrintError($"No associated quest ({info.QuestId}).", "Questionable");
index c4c70b9..74b5fd4 100644 (file)
@@ -525,7 +525,7 @@ internal sealed class InteractionUiController : IDisposable
                             return null;
 
                         _questController.GatheringQuest.SetSequence(1);
-                        _questController.StartSingleQuest("SatisfactionSupply turn in");
+                        _questController.StartGatheringQuest("SatisfactionSupply turn in");
                     }
 
                     return i;
index 0fc2d41..5f874f1 100644 (file)
@@ -281,9 +281,13 @@ internal sealed class QuestController : MiniTaskController<QuestController>
                     _logger.LogInformation("Next quest {QuestId} accepted or completed",
                         _nextQuest.Quest.Id);
 
-                    // if (_nextQuest.Quest.Id is LeveId)
-                    //  _startedQuest = _nextQuest;
+                    if (AutomationType == EAutomationType.SingleQuestA)
+                    {
+                        _startedQuest = _nextQuest;
+                        AutomationType = EAutomationType.SingleQuestB;
+                    }
 
+                    _logger.LogDebug("Started: {StartedQuest}", _startedQuest?.Quest.Id);
                     _nextQuest = null;
                 }
             }
@@ -349,7 +353,15 @@ internal sealed class QuestController : MiniTaskController<QuestController>
                             Stop("Quest level too high");
                         }
                         else
+                        {
+                            if (AutomationType == EAutomationType.SingleQuestB)
+                            {
+                                _logger.LogInformation("Single quest is finished");
+                                AutomationType = EAutomationType.Manual;
+                            }
+
                             CheckNextTasks("Different Quest");
+                        }
                     }
                     else if (_startedQuest != null)
                     {
@@ -521,7 +533,7 @@ internal sealed class QuestController : MiniTaskController<QuestController>
 
     private void CheckNextTasks(string label)
     {
-        if (AutomationType == EAutomationType.Automatic)
+        if (AutomationType is EAutomationType.Automatic or EAutomationType.SingleQuestA or EAutomationType.SingleQuestB)
         {
             using var scope = _logger.BeginScope(label);
 
@@ -597,10 +609,17 @@ internal sealed class QuestController : MiniTaskController<QuestController>
         ExecuteNextStep();
     }
 
+    public void StartGatheringQuest(string label)
+    {
+        using var scope = _logger.BeginScope($"GQ/{label}");
+        AutomationType = EAutomationType.GatheringOnly;
+        ExecuteNextStep();
+    }
+
     public void StartSingleQuest(string label)
     {
         using var scope = _logger.BeginScope($"SQ/{label}");
-        AutomationType = EAutomationType.CurrentQuestOnly;
+        AutomationType = EAutomationType.SingleQuestA;
         ExecuteNextStep();
     }
 
@@ -881,6 +900,8 @@ internal sealed class QuestController : MiniTaskController<QuestController>
     {
         Manual,
         Automatic,
-        CurrentQuestOnly,
+        GatheringOnly,
+        SingleQuestA,
+        SingleQuestB,
     }
 }
index 8262a9e..7f8cff1 100644 (file)
@@ -44,9 +44,15 @@ internal static class NextQuest
     {
         protected override bool Start()
         {
-            if (questFunctions.IsQuestLocked(Task.NextQuestId, Task.CurrentQuestId))
+            if (questController.AutomationType is QuestController.EAutomationType.SingleQuestA or QuestController.EAutomationType.SingleQuestB)
+            {
+                logger.LogInformation("Won't set next quest to {QuestId}, automation type is CurrentQuestOnly", Task.NextQuestId);
+                questController.SetNextQuest(null);
+            }
+            else if (questFunctions.IsQuestLocked(Task.NextQuestId, Task.CurrentQuestId))
             {
                 logger.LogInformation("Can't set next quest to {QuestId}, quest is locked", Task.NextQuestId);
+                questController.SetNextQuest(null);
             }
             else if (questRegistry.TryGetQuest(Task.NextQuestId, out Quest? quest))
             {