Makes a lot of entity systems unsubscribe from events on shutdown.

This commit is contained in:
Vera Aguilera Puerto
2021-04-09 16:08:12 +02:00
parent c28f22ebff
commit 03cd390478
15 changed files with 119 additions and 28 deletions

View File

@@ -45,6 +45,13 @@ namespace Content.Server.GameObjects.EntitySystems.AI
SubscribeLocalEvent<MobStateChangedMessage>(MobStateChanged);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<SleepAiMessage>();
UnsubscribeLocalEvent<MobStateChangedMessage>();
}
/// <inheritdoc />
public override void Update(float frameTime)
{

View File

@@ -90,6 +90,22 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
_mapManager.OnGridRemoved += GridRemoved;
}
public override void Shutdown()
{
base.Shutdown();
_queuedUpdates.Clear();
_regions.Clear();
_cachedAccessible.Clear();
_queuedCacheDeletions.Clear();
_mapManager.OnGridRemoved -= GridRemoved;
UnsubscribeLocalEvent<PathfindingChunkUpdateMessage>();
UnsubscribeNetworkEvent<SharedAiDebug.SubscribeReachableMessage>();
UnsubscribeNetworkEvent<SharedAiDebug.UnsubscribeReachableMessage>();
}
private void GridRemoved(MapId mapId, GridId gridId)
{
_regions.Remove(gridId);
@@ -126,20 +142,6 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
_queuedCacheDeletions.Clear();
}
public override void Shutdown()
{
base.Shutdown();
_queuedUpdates.Clear();
_regions.Clear();
_cachedAccessible.Clear();
_queuedCacheDeletions.Clear();
_mapManager.OnGridRemoved -= GridRemoved;
UnsubscribeLocalEvent<PathfindingChunkUpdateMessage>();
UnsubscribeLocalEvent<PlayerAttachSystemMessage>();
UnsubscribeNetworkEvent<SharedAiDebug.SubscribeReachableMessage>();
UnsubscribeNetworkEvent<SharedAiDebug.UnsubscribeReachableMessage>();
}
#if DEBUG
private void HandleSubscription(SharedAiDebug.SubscribeReachableMessage message, EntitySessionEventArgs eventArgs)
{