Replace IResettingEntitySystem with RoundRestartCleanupEvent. (#4245)

* Replace IResettingEntitySystem with RoundRestartCleanupEvent.

* oops
This commit is contained in:
Vera Aguilera Puerto
2021-06-29 15:56:07 +02:00
committed by GitHub
parent 16e1c2c798
commit bc7b315b18
27 changed files with 136 additions and 66 deletions

View File

@@ -21,7 +21,7 @@ namespace Content.Server.AI.Pathfinding.Accessible
/// </summary>
/// Long-term can be used to do hierarchical pathfinding
[UsedImplicitly]
public sealed class AiReachableSystem : EntitySystem, IResettingEntitySystem
public sealed class AiReachableSystem : EntitySystem
{
/*
* The purpose of this is to provide a higher-level / hierarchical abstraction of the actual pathfinding graph
@@ -81,6 +81,7 @@ namespace Content.Server.AI.Pathfinding.Accessible
public override void Initialize()
{
_pathfindingSystem = Get<PathfindingSystem>();
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
SubscribeLocalEvent<PathfindingChunkUpdateMessage>(RecalculateNodeRegions);
#if DEBUG
SubscribeNetworkEvent<SharedAiDebug.SubscribeReachableMessage>(HandleSubscription);
@@ -699,7 +700,7 @@ namespace Content.Server.AI.Pathfinding.Accessible
#endif
}
public void Reset()
public void Reset(RoundRestartCleanupEvent ev)
{
_queuedUpdates.Clear();
_regions.Clear();

View File

@@ -27,7 +27,7 @@ namespace Content.Server.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, IResettingEntitySystem
public class PathfindingSystem : EntitySystem
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
@@ -201,6 +201,7 @@ namespace Content.Server.AI.Pathfinding
public override void Initialize()
{
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
SubscribeLocalEvent<CollisionChangeMessage>(QueueCollisionChangeMessage);
SubscribeLocalEvent<MoveEvent>(QueueMoveEvent);
SubscribeLocalEvent<AccessReaderChangeMessage>(QueueAccessChangeMessage);
@@ -385,7 +386,7 @@ namespace Content.Server.AI.Pathfinding
return true;
}
public void Reset()
public void Reset(RoundRestartCleanupEvent ev)
{
_graph.Clear();
_collidableUpdateQueue.Clear();