Don't pathfind on deleted grid (#8300)
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Content.Server.AI.Pathfinding.Accessible
|
||||
/// <summary>
|
||||
/// Gets all of the tiles in range that can we access
|
||||
/// </summary>
|
||||
/// If you want Dikstra then add distances.
|
||||
/// If you want Dijkstra then add distances.
|
||||
/// Doesn't use the JobQueue as it will generally be encapsulated by other jobs
|
||||
/// <param name="pathfindingArgs"></param>
|
||||
/// <param name="range"></param>
|
||||
|
||||
@@ -16,17 +16,20 @@ namespace Content.Server.AI.Pathfinding.Pathfinders
|
||||
private readonly PathfindingNode? _startNode;
|
||||
private PathfindingNode? _endNode;
|
||||
private readonly PathfindingArgs _pathfindingArgs;
|
||||
private readonly IEntityManager _entityManager;
|
||||
|
||||
public AStarPathfindingJob(
|
||||
double maxTime,
|
||||
PathfindingNode startNode,
|
||||
PathfindingNode endNode,
|
||||
PathfindingArgs pathfindingArgs,
|
||||
CancellationToken cancellationToken) : base(maxTime, cancellationToken)
|
||||
CancellationToken cancellationToken,
|
||||
IEntityManager entityManager) : base(maxTime, cancellationToken)
|
||||
{
|
||||
_startNode = startNode;
|
||||
_endNode = endNode;
|
||||
_pathfindingArgs = pathfindingArgs;
|
||||
_entityManager = entityManager;
|
||||
}
|
||||
|
||||
protected override async Task<Queue<TileRef>?> Process()
|
||||
@@ -44,6 +47,9 @@ namespace Content.Server.AI.Pathfinding.Pathfinders
|
||||
return null;
|
||||
}
|
||||
|
||||
if (_entityManager.Deleted(_pathfindingArgs.Start.GridIndex))
|
||||
return null;
|
||||
|
||||
var frontier = new PriorityQueue<ValueTuple<float, PathfindingNode>>(new PathfindingComparer());
|
||||
var costSoFar = new Dictionary<PathfindingNode, float>();
|
||||
var cameFrom = new Dictionary<PathfindingNode, PathfindingNode>();
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Content.Server.AI.Pathfinding
|
||||
{
|
||||
var startNode = GetNode(pathfindingArgs.Start);
|
||||
var endNode = GetNode(pathfindingArgs.End);
|
||||
var job = new AStarPathfindingJob(0.003, startNode, endNode, pathfindingArgs, cancellationToken);
|
||||
var job = new AStarPathfindingJob(0.003, startNode, endNode, pathfindingArgs, cancellationToken, EntityManager);
|
||||
_pathfindingQueue.EnqueueJob(job);
|
||||
|
||||
return job;
|
||||
|
||||
Reference in New Issue
Block a user