Fix AI crash when an entity is moved to an invalid grid (#2507)
This commit is contained in:
@@ -328,9 +328,16 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var newGridId = moveEvent.NewPosition.GetGridId(_entityManager);
|
||||||
|
if (newGridId == GridId.Invalid)
|
||||||
|
{
|
||||||
|
HandleEntityRemove(moveEvent.Sender);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// The pathfinding graph is tile-based so first we'll check if they're on a different tile and if we need to update.
|
// The pathfinding graph is tile-based so first we'll check if they're on a different tile and if we need to update.
|
||||||
// If you get entities bigger than 1 tile wide you'll need some other system so god help you.
|
// If you get entities bigger than 1 tile wide you'll need some other system so god help you.
|
||||||
var newTile = _mapManager.GetGrid(moveEvent.NewPosition.GetGridId(_entityManager)).GetTileRef(moveEvent.NewPosition);
|
var newTile = _mapManager.GetGrid(newGridId).GetTileRef(moveEvent.NewPosition);
|
||||||
|
|
||||||
if (oldNode == null || oldNode.TileRef == newTile)
|
if (oldNode == null || oldNode.TileRef == newTile)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user