Add IsUnmounting condition to UnmountTask
authorLiza Carvelli <liza@carvel.li>
Sun, 25 Aug 2024 11:45:57 +0000 (13:45 +0200)
committerLiza Carvelli <liza@carvel.li>
Sun, 25 Aug 2024 11:45:57 +0000 (13:45 +0200)
Questionable/Controller/Steps/Common/Mount.cs

index 144de5ba4eb1d69b7103dd396aefdfd18e96f65b..9502455c1c6f924f40d2f491eb6c86517ff2a3c0 100644 (file)
@@ -29,7 +29,7 @@ internal static class Mount
 
         public ITask Unmount()
         {
-            return new UnmountTask(condition, loggerFactory.CreateLogger<UnmountTask>(), gameFunctions);
+            return new UnmountTask(condition, loggerFactory.CreateLogger<UnmountTask>(), gameFunctions, clientState);
         }
     }
 
@@ -119,7 +119,11 @@ internal static class Mount
         public override string ToString() => "Mount";
     }
 
-    private sealed class UnmountTask(ICondition condition, ILogger<UnmountTask> logger, GameFunctions gameFunctions)
+    private sealed class UnmountTask(
+        ICondition condition,
+        ILogger<UnmountTask> logger,
+        GameFunctions gameFunctions,
+        IClientState clientState)
         : ITask
     {
         private bool _unmountTriggered;
@@ -148,6 +152,9 @@ internal static class Mount
             if (_continueAt >= DateTime.Now)
                 return ETaskResult.StillRunning;
 
+            if (IsUnmounting())
+                return ETaskResult.StillRunning;
+
             if (!_unmountTriggered)
             {
                 // if still flying, we still need to land
@@ -172,6 +179,8 @@ internal static class Mount
                 : ETaskResult.TaskComplete;
         }
 
+        private unsafe bool IsUnmounting() => **(byte**)(clientState.LocalPlayer!.Address + 1432) == 1;
+
         public override string ToString() => "Unmount";
     }