diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs index 3470365282..4f866d3348 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs @@ -130,6 +130,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible _regions.Clear(); _cachedAccessible.Clear(); _queuedCacheDeletions.Clear(); + _mapManager.OnGridRemoved -= GridRemoved; } public void ResettingCleanup() @@ -626,6 +627,12 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible /// private void GenerateRegions(PathfindingChunk chunk) { + // Grid deleted while update queued. + if (!_mapManager.TryGetGrid(chunk.GridId, out _)) + { + return; + } + if (!_regions.ContainsKey(chunk.GridId)) { _regions.Add(chunk.GridId, new Dictionary>());