Fix pathfinding entity deletions
Also some slight optimisations in the process.
This commit is contained in:
@@ -98,6 +98,7 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// TODO: These 2 methods currently don't account for a bunch of changes (e.g. airlock unpowered, wrenching, etc.)
|
||||
/// TODO: Could probably optimise this slightly more.
|
||||
public void AddEntity(IEntity entity)
|
||||
{
|
||||
// If we're a door
|
||||
@@ -128,25 +129,28 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the entity from this node.
|
||||
/// Will check each category and remove it from the applicable one
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
public void RemoveEntity(IEntity entity)
|
||||
{
|
||||
if (_accessReaders.ContainsKey(entity.Uid))
|
||||
// There's no guarantee that the entity isn't deleted
|
||||
// 90% of updates are probably entities moving around
|
||||
// Entity can't be under multiple categories so just checking each once is fine.
|
||||
if (_physicsUids.Contains(entity.Uid))
|
||||
{
|
||||
_physicsUids.Remove(entity.Uid);
|
||||
}
|
||||
else if (_accessReaders.ContainsKey(entity.Uid))
|
||||
{
|
||||
_accessReaders.Remove(entity.Uid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity.HasComponent<CollidableComponent>())
|
||||
}
|
||||
else if (_blockedCollidables.ContainsKey(entity.Uid))
|
||||
{
|
||||
if (entity.TryGetComponent(out PhysicsComponent physicsComponent) && physicsComponent.Anchored)
|
||||
{
|
||||
_blockedCollidables.Remove(entity.Uid);
|
||||
GenerateMask();
|
||||
}
|
||||
else
|
||||
{
|
||||
_physicsUids.Remove(entity.Uid);
|
||||
}
|
||||
_blockedCollidables.Remove(entity.Uid);
|
||||
GenerateMask();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user