diff --git a/Questionable/Controller/Steps/BaseTasks/UnmountTask.cs b/Questionable/Controller/Steps/BaseTasks/UnmountTask.cs index 9a11cd492..761f87b5b 100644 --- a/Questionable/Controller/Steps/BaseTasks/UnmountTask.cs +++ b/Questionable/Controller/Steps/BaseTasks/UnmountTask.cs @@ -9,7 +9,7 @@ internal sealed class UnmountTask(ICondition condition, ILogger log : ITask { private bool _unmountTriggered; - private DateTime _unmountedAt = DateTime.MinValue; + private DateTime _continueAt = DateTime.MinValue; public bool Start() { @@ -17,26 +17,34 @@ internal sealed class UnmountTask(ICondition condition, ILogger log return false; logger.LogInformation("Step explicitly wants no mount, trying to unmount..."); + if (condition[ConditionFlag.InFlight]) + { + gameFunctions.Unmount(); + return true; + } + _unmountTriggered = gameFunctions.Unmount(); - if (_unmountTriggered) - _unmountedAt = DateTime.Now; + _continueAt = DateTime.Now.AddSeconds(1); return true; } public ETaskResult Update() { + if (_continueAt >= DateTime.Now) + return ETaskResult.StillRunning; + if (!_unmountTriggered) { - _unmountTriggered = gameFunctions.Unmount(); - if (_unmountTriggered) - _unmountedAt = DateTime.Now; + // if still flying, we still need to land + if (condition[ConditionFlag.InFlight]) + gameFunctions.Unmount(); + else + _unmountTriggered = gameFunctions.Unmount(); + _continueAt = DateTime.Now.AddSeconds(0.5); return ETaskResult.StillRunning; } - if (DateTime.Now < _unmountedAt.AddSeconds(1)) - return ETaskResult.StillRunning; - return condition[ConditionFlag.Mounted] ? ETaskResult.StillRunning : ETaskResult.TaskComplete;