Fix pathfinding exception (#11228)
This commit is contained in:
@@ -77,6 +77,9 @@ public sealed class PickAccessibleComponentOperator : HTNOperator
|
||||
// TODO: God the path api sucks PLUS I need some fast way to get this.
|
||||
var job = _path.RequestPath(owner, target.Owner, CancellationToken.None);
|
||||
|
||||
if (job == null)
|
||||
continue;
|
||||
|
||||
await job.AsTask;
|
||||
|
||||
if (job.Result == null || !_entManager.TryGetComponent<TransformComponent>(target.Owner, out var targetXform))
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Content.Server.NPC.Pathfinding
|
||||
return job;
|
||||
}
|
||||
|
||||
public Job<Queue<TileRef>> RequestPath(EntityUid source, EntityUid target, CancellationToken cancellationToken)
|
||||
public Job<Queue<TileRef>>? RequestPath(EntityUid source, EntityUid target, CancellationToken cancellationToken)
|
||||
{
|
||||
var collisionMask = 0;
|
||||
|
||||
@@ -46,18 +46,17 @@ namespace Content.Server.NPC.Pathfinding
|
||||
collisionMask = body.CollisionMask;
|
||||
}
|
||||
|
||||
var start = TileRef.Zero;
|
||||
var end = TileRef.Zero;
|
||||
|
||||
if (TryComp<TransformComponent>(source, out var xform) &&
|
||||
_mapManager.TryGetGrid(xform.GridUid, out var grid) &&
|
||||
TryComp<TransformComponent>(target, out var targetXform) &&
|
||||
_mapManager.TryGetGrid(targetXform.GridUid, out var targetGrid))
|
||||
if (!TryComp<TransformComponent>(source, out var xform) ||
|
||||
!_mapManager.TryGetGrid(xform.GridUid, out var grid) ||
|
||||
!TryComp<TransformComponent>(target, out var targetXform) ||
|
||||
!_mapManager.TryGetGrid(targetXform.GridUid, out var targetGrid))
|
||||
{
|
||||
start = grid.GetTileRef(xform.Coordinates);
|
||||
end = grid.GetTileRef(targetXform.Coordinates);
|
||||
return null;
|
||||
}
|
||||
|
||||
var start = grid.GetTileRef(xform.Coordinates);
|
||||
var end = targetGrid.GetTileRef(targetXform.Coordinates);
|
||||
|
||||
var args = new PathfindingArgs(source, _access.FindAccessTags(source), collisionMask, start, end);
|
||||
|
||||
var startNode = GetNode(start);
|
||||
|
||||
Reference in New Issue
Block a user