Make PathfindingSystem take a nap during large explosions (#12309)

This commit is contained in:
Leon Friedrich
2022-11-04 14:24:41 +13:00
committed by GitHub
parent a0627b7558
commit 86ef8c5473
4 changed files with 35 additions and 8 deletions

View File

@@ -27,6 +27,15 @@ public sealed partial class PathfindingSystem
public const int PathfindingCollisionMask = (int) CollisionGroup.MobMask;
public const int PathfindingCollisionLayer = (int) CollisionGroup.MobLayer;
/// <summary>
/// If true, UpdateGrid() will not process grids.
/// </summary>
/// <remarks>
/// Useful if something like a large explosion is in the process of shredding the grid, as it avoids uneccesary
/// updating.
/// </remarks>
public bool PauseUpdating = false;
private readonly Stopwatch _stopwatch = new();
// Probably can't pool polys as there might be old pathfinding refs to them.
@@ -66,6 +75,9 @@ public sealed partial class PathfindingSystem
private void UpdateGrid()
{
if (PauseUpdating)
return;
var curTime = _timing.CurTime;
#if DEBUG
var updateCount = 0;