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:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Access;
|
||||
using Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders;
|
||||
using Content.Shared.AI;
|
||||
using Content.Shared.GameTicking;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
@@ -22,7 +23,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
/// </summary>
|
||||
/// Long-term can be used to do hierarchical pathfinding
|
||||
[UsedImplicitly]
|
||||
public sealed class AiReachableSystem : EntitySystem
|
||||
public sealed class AiReachableSystem : EntitySystem, IResettingEntitySystem
|
||||
{
|
||||
/*
|
||||
* The purpose of this is to provide a higher-level / hierarchical abstraction of the actual pathfinding graph
|
||||
@@ -134,14 +135,6 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
_mapManager.OnGridRemoved -= GridRemoved;
|
||||
}
|
||||
|
||||
public void ResettingCleanup()
|
||||
{
|
||||
_queuedUpdates.Clear();
|
||||
_regions.Clear();
|
||||
_cachedAccessible.Clear();
|
||||
_queuedCacheDeletions.Clear();
|
||||
}
|
||||
|
||||
private void RecalculateNodeRegions(PathfindingChunkUpdateMessage message)
|
||||
{
|
||||
// TODO: Only need to do changed nodes ideally
|
||||
@@ -683,6 +676,14 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_queuedUpdates.Clear();
|
||||
_regions.Clear();
|
||||
_cachedAccessible.Clear();
|
||||
_queuedCacheDeletions.Clear();
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
private void SendDebugMessage(PlayerAttachSystemMessage message)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user