diff --git a/vnavmesh/IPCProvider.cs b/vnavmesh/IPCProvider.cs index 5189aae..b2ba515 100644 --- a/vnavmesh/IPCProvider.cs +++ b/vnavmesh/IPCProvider.cs @@ -18,7 +18,7 @@ public IPCProvider(NavmeshManager navmeshManager, FollowPath followPath, AsyncMo RegisterFunc("Nav.Rebuild", () => navmeshManager.Reload(false)); RegisterFunc("Nav.Pathfind", (Vector3 from, Vector3 to, bool fly) => navmeshManager.QueryPath(from, to, fly)); RegisterFunc("Nav.PathfindCancelable", (Vector3 from, Vector3 to, bool fly, CancellationToken cancel) => navmeshManager.QueryPath(from, to, fly, cancel)); - RegisterAction("Nav.PathfindCancelCurrent", () => navmeshManager.CancelCurrentPathfinding()); + RegisterAction("Nav.PathfindCancelAll", navmeshManager.CancelAllQueries); RegisterFunc("Nav.PathfindInProgress", () => navmeshManager.PathfindInProgress); RegisterFunc("Nav.PathfindNumQueued", () => navmeshManager.NumQueuedPathfindRequests); RegisterFunc("Nav.IsAutoLoad", () => navmeshManager.AutoLoad); diff --git a/vnavmesh/NavmeshManager.cs b/vnavmesh/NavmeshManager.cs index 302f9b1..9ef3d1f 100644 --- a/vnavmesh/NavmeshManager.cs +++ b/vnavmesh/NavmeshManager.cs @@ -151,17 +151,17 @@ public bool Reload(bool allowLoadFromCache) return task; } - public void CancelCurrentPathfinding() + public void CancelAllQueries() { - if (_queryCancelSource == null || _currentPathfindTask is null || _query == null) + if (_queryCancelSource == null) { - Service.Log.Error($"Can't cancel query - navmesh is not loaded"); + Service.Log.Error($"Can't cancel queries - navmesh is not loaded"); return; } - _queryCancelSource.Cancel(); // this will cancel current pathfind task + _queryCancelSource.Cancel(); // this will cancel current and all queued pathfind tasks + _queryCancelSource.Dispose(); _queryCancelSource = new(); // create new token source for future tasks - } // if non-empty string is returned, active layout is ready