Stop AD when questionable is currently running an AD dungeon/trial

This commit is contained in:
Liza 2025-02-08 00:21:18 +01:00
parent 21721e34b4
commit 48cc37dd05
Signed by: liza
GPG Key ID: 2C41B84815CF6445
3 changed files with 14 additions and 2 deletions

View File

@ -473,6 +473,9 @@ internal sealed class QuestController : MiniTaskController<QuestController>
private void ClearTasksInternal()
{
//_logger.LogDebug("Clearing task (internally)");
if (_taskQueue.CurrentTaskExecutor is IStoppableTaskExecutor stoppableTaskExecutor)
stoppableTaskExecutor.StopNow();
_taskQueue.Reset();
_yesAlreadyIpc.RestoreYesAlready();

View File

@ -49,7 +49,7 @@ internal static class Duty
TerritoryData territoryData,
IClientState clientState,
IChatGui chatGui,
SendNotification.Executor sendNotificationExecutor) : TaskExecutor<StartAutoDutyTask>
SendNotification.Executor sendNotificationExecutor) : TaskExecutor<StartAutoDutyTask>, IStoppableTaskExecutor
{
protected override bool Start()
{
@ -94,6 +94,8 @@ internal static class Duty
: ETaskResult.StillRunning;
}
public void StopNow() => autoDutyIpc.Stop();
public override bool ShouldInterruptOnDamage() => false;
}
@ -105,7 +107,7 @@ internal static class Duty
internal sealed class WaitAutoDutyExecutor(
AutoDutyIpc autoDutyIpc,
TerritoryData territoryData,
IClientState clientState) : TaskExecutor<WaitAutoDutyTask>
IClientState clientState) : TaskExecutor<WaitAutoDutyTask>, IStoppableTaskExecutor
{
protected override bool Start() => true;
@ -120,6 +122,8 @@ internal static class Duty
: ETaskResult.StillRunning;
}
public void StopNow() => autoDutyIpc.Stop();
public override bool ShouldInterruptOnDamage() => false;
}

View File

@ -25,6 +25,11 @@ internal interface IExtraTaskCreator : ITaskExecutor
IEnumerable<ITask> CreateExtraTasks();
}
internal interface IStoppableTaskExecutor : ITaskExecutor
{
void StopNow();
}
internal abstract class TaskExecutor<T> : ITaskExecutor
where T : class, ITask
{