From ffd14d93a5441b69b373ff49af3ddc4a575ab59e Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sat, 8 Mar 2025 02:11:38 +0100 Subject: [PATCH] Fix StartSingleQuest IPC --- .../Controller/ContextMenuController.cs | 2 +- .../GameUi/InteractionUiController.cs | 2 +- Questionable/Controller/QuestController.cs | 31 ++++++++++++++++--- .../Controller/Steps/Common/NextQuest.cs | 8 ++++- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/Questionable/Controller/ContextMenuController.cs b/Questionable/Controller/ContextMenuController.cs index 45230c5f..153dc2bf 100644 --- a/Questionable/Controller/ContextMenuController.cs +++ b/Questionable/Controller/ContextMenuController.cs @@ -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"); diff --git a/Questionable/Controller/GameUi/InteractionUiController.cs b/Questionable/Controller/GameUi/InteractionUiController.cs index c4c70b98..74b5fd4a 100644 --- a/Questionable/Controller/GameUi/InteractionUiController.cs +++ b/Questionable/Controller/GameUi/InteractionUiController.cs @@ -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; diff --git a/Questionable/Controller/QuestController.cs b/Questionable/Controller/QuestController.cs index 0fc2d41a..5f874f12 100644 --- a/Questionable/Controller/QuestController.cs +++ b/Questionable/Controller/QuestController.cs @@ -281,9 +281,13 @@ internal sealed class QuestController : MiniTaskController _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 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 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 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 { Manual, Automatic, - CurrentQuestOnly, + GatheringOnly, + SingleQuestA, + SingleQuestB, } } diff --git a/Questionable/Controller/Steps/Common/NextQuest.cs b/Questionable/Controller/Steps/Common/NextQuest.cs index 8262a9ec..7f8cff16 100644 --- a/Questionable/Controller/Steps/Common/NextQuest.cs +++ b/Questionable/Controller/Steps/Common/NextQuest.cs @@ -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)) { -- 2.20.1