From 941d571d48d80f09b302eca4b6b685f319c86998 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Fri, 4 Apr 2025 01:22:27 +0200 Subject: [PATCH] Fix movement --- Questionable/Controller/MovementController.cs | 3 +++ .../Controller/Steps/Movement/MoveExecutor.cs | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Questionable/Controller/MovementController.cs b/Questionable/Controller/MovementController.cs index d753a356..0bb7abf7 100644 --- a/Questionable/Controller/MovementController.cs +++ b/Questionable/Controller/MovementController.cs @@ -360,6 +360,9 @@ internal sealed class MovementController : IDisposable if (Destination == null) throw new InvalidOperationException("Destination is null"); + if (DateTime.Now - MovementStartedAt <= TimeSpan.FromSeconds(5)) + return; + var nextWaypoint = navPoints.FirstOrDefault(); if (nextWaypoint != default) { diff --git a/Questionable/Controller/Steps/Movement/MoveExecutor.cs b/Questionable/Controller/Steps/Movement/MoveExecutor.cs index 16181d17..1789de93 100644 --- a/Questionable/Controller/Steps/Movement/MoveExecutor.cs +++ b/Questionable/Controller/Steps/Movement/MoveExecutor.cs @@ -96,7 +96,7 @@ internal sealed class MoveExecutor : TaskExecutor, IToastAware if (requiresMovement) PrepareMovementIfNeeded(); - if (Task.Mount == true || Task.Fly) + if (Task.Mount == true) { var mountTask = new Mount.MountTask(Task.TerritoryId, Mount.EMountIf.Always); _mountBeforeMovement = (_serviceProvider.GetRequiredService(), mountTask); @@ -121,11 +121,20 @@ internal sealed class MoveExecutor : TaskExecutor, IToastAware : Mount.EMountIf.AwayFromPosition; var mountTask = new Mount.MountTask(Task.TerritoryId, mountIf, _destination); DateTime retryAt = DateTime.Now; - _mountDuringMovement = (_serviceProvider.GetRequiredService(), mountTask); + (Mount.MountExecutor Executor, Mount.MountTask)? move; + if (_mountEvaluator.EvaluateMountState(mountTask, true, ref retryAt) != Mount.MountResult.DontMount) - _mountDuringMovement.Value.Executor.Start(mountTask); + { + move = (_serviceProvider.GetRequiredService(), mountTask); + move.Value.Executor.Start(mountTask); + } + else + move = null; + + if (Task.Fly) + _mountBeforeMovement = move; else - _mountDuringMovement = null; + _mountDuringMovement = move; } } -- 2.30.2