Unmount: Make sure to call twice if you've been in flight initially
This commit is contained in:
parent
83de113c08
commit
63b3f4cd3a
@ -9,7 +9,7 @@ internal sealed class UnmountTask(ICondition condition, ILogger<UnmountTask> log
|
|||||||
: ITask
|
: ITask
|
||||||
{
|
{
|
||||||
private bool _unmountTriggered;
|
private bool _unmountTriggered;
|
||||||
private DateTime _unmountedAt = DateTime.MinValue;
|
private DateTime _continueAt = DateTime.MinValue;
|
||||||
|
|
||||||
public bool Start()
|
public bool Start()
|
||||||
{
|
{
|
||||||
@ -17,26 +17,34 @@ internal sealed class UnmountTask(ICondition condition, ILogger<UnmountTask> log
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
logger.LogInformation("Step explicitly wants no mount, trying to unmount...");
|
logger.LogInformation("Step explicitly wants no mount, trying to unmount...");
|
||||||
|
if (condition[ConditionFlag.InFlight])
|
||||||
|
{
|
||||||
|
gameFunctions.Unmount();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
_unmountTriggered = gameFunctions.Unmount();
|
_unmountTriggered = gameFunctions.Unmount();
|
||||||
if (_unmountTriggered)
|
_continueAt = DateTime.Now.AddSeconds(1);
|
||||||
_unmountedAt = DateTime.Now;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ETaskResult Update()
|
public ETaskResult Update()
|
||||||
{
|
{
|
||||||
|
if (_continueAt >= DateTime.Now)
|
||||||
|
return ETaskResult.StillRunning;
|
||||||
|
|
||||||
if (!_unmountTriggered)
|
if (!_unmountTriggered)
|
||||||
{
|
{
|
||||||
_unmountTriggered = gameFunctions.Unmount();
|
// if still flying, we still need to land
|
||||||
if (_unmountTriggered)
|
if (condition[ConditionFlag.InFlight])
|
||||||
_unmountedAt = DateTime.Now;
|
gameFunctions.Unmount();
|
||||||
|
else
|
||||||
|
_unmountTriggered = gameFunctions.Unmount();
|
||||||
|
|
||||||
|
_continueAt = DateTime.Now.AddSeconds(0.5);
|
||||||
return ETaskResult.StillRunning;
|
return ETaskResult.StillRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DateTime.Now < _unmountedAt.AddSeconds(1))
|
|
||||||
return ETaskResult.StillRunning;
|
|
||||||
|
|
||||||
return condition[ConditionFlag.Mounted]
|
return condition[ConditionFlag.Mounted]
|
||||||
? ETaskResult.StillRunning
|
? ETaskResult.StillRunning
|
||||||
: ETaskResult.TaskComplete;
|
: ETaskResult.TaskComplete;
|
||||||
|
Loading…
Reference in New Issue
Block a user