Handle zone transitiions in new movement logic v2.19
authorLiza Carvelli <liza@carvel.li>
Fri, 30 Aug 2024 11:59:33 +0000 (13:59 +0200)
committerLiza Carvelli <liza@carvel.li>
Fri, 30 Aug 2024 12:00:10 +0000 (14:00 +0200)
Directory.Build.targets
Questionable/Controller/Steps/Shared/MoveTo.cs

index 6b83635a7afca8fc1b202c1d297450c6df351148..c6651601896a7016e9652c8cc30933daebd1d548 100644 (file)
@@ -1,5 +1,5 @@
 <Project>
     <PropertyGroup>
-        <Version>2.18</Version>
+        <Version>2.19</Version>
     </PropertyGroup>
 </Project>
index 331926743260ea389bb37bd87ab72f4ec76cafa0..f9e0d69089aba6eeaf38cbd953a1e7a383f0007f 100644 (file)
@@ -169,6 +169,8 @@ internal static class MoveTo
         private readonly Action _startAction;
         private readonly Vector3 _destination;
         private readonly MoveParams _moveParams;
+        private readonly bool _isUnderwaterInitially;
+        private bool _canRestart;
 
         public MoveInternal(MoveParams moveParams,
             MovementController movementController,
@@ -213,6 +215,7 @@ internal static class MoveTo
             }
 
             _moveParams = moveParams;
+            _canRestart = moveParams.RestartNavigation;
         }
 
         public bool Start()
@@ -231,13 +234,20 @@ internal static class MoveTo
             if (movementStartedAt == DateTime.MaxValue || movementStartedAt.AddSeconds(2) >= DateTime.Now)
                 return ETaskResult.StillRunning;
 
-            if (_moveParams.RestartNavigation &&
+            if (_canRestart &&
                 Vector3.Distance(_clientState.LocalPlayer!.Position, _destination) >
                 (_moveParams.StopDistance ?? QuestStep.DefaultStopDistance) + 5f)
             {
-                _logger.LogInformation("Looks like movement was interrupted, re-attempting to move");
-                _startAction();
-                return ETaskResult.StillRunning;
+                _canRestart = false;
+                if (_clientState.TerritoryType == _moveParams.TerritoryId)
+                {
+                    _logger.LogInformation("Looks like movement was interrupted, re-attempting to move");
+                    _startAction();
+                    return ETaskResult.StillRunning;
+                }
+                else
+                    _logger.LogInformation(
+                        "Looks like movement was interrupted, do nothing since we're in a different territory now");
             }
 
             return ETaskResult.TaskComplete;