Add IResettingEntitySystem for entity systems that do resetting cleanup (#2257)

* Add IResettingEntitySystem for entity systems that do resetting cleanup

* You got a license for that submodule update?
This commit is contained in:
DrSmugleaf
2020-10-14 22:45:53 +02:00
committed by GitHub
parent 6be80c119b
commit 50bc61b672
17 changed files with 76 additions and 54 deletions

View File

@@ -5,6 +5,7 @@ using Content.Server.GameObjects.Components.Access;
using Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders;
using Content.Server.GameObjects.EntitySystems.JobQueues;
using Content.Server.GameObjects.EntitySystems.JobQueues.Queues;
using Content.Shared.GameTicking;
using Content.Shared.Physics;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Components.Transform;
@@ -28,7 +29,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
/// This system handles pathfinding graph updates as well as dispatches to the pathfinder
/// (90% of what it's doing is graph updates so not much point splitting the 2 roles)
/// </summary>
public class PathfindingSystem : EntitySystem
public class PathfindingSystem : EntitySystem, IResettingEntitySystem
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
@@ -230,16 +231,6 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
node.UpdateTile(tile);
}
public void ResettingCleanup()
{
_graph.Clear();
_collidableUpdateQueue.Clear();
_moveUpdateQueue.Clear();
_accessReaderUpdateQueue.Clear();
_tileUpdateQueue.Clear();
_lastKnownPositions.Clear();
}
private void HandleGridRemoval(GridId gridId)
{
if (_graph.ContainsKey(gridId))
@@ -389,5 +380,15 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
return true;
}
public void Reset()
{
_graph.Clear();
_collidableUpdateQueue.Clear();
_moveUpdateQueue.Clear();
_accessReaderUpdateQueue.Clear();
_tileUpdateQueue.Clear();
_lastKnownPositions.Clear();
}
}
}