From 63b3f4cd3a7a0bde86a79c95fb6c9d2dbf6dd1a1 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sat, 15 Jun 2024 22:22:00 +0200 Subject: [PATCH] Unmount: Make sure to call twice if you've been in flight initially --- .../Controller/Steps/BaseTasks/UnmountTask.cs | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) 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;