diff --git a/Content.Client/GameObjects/EntitySystems/ConstructionSystem.cs b/Content.Client/GameObjects/EntitySystems/ConstructionSystem.cs index 77dff4b52a..b55d5cbf03 100644 --- a/Content.Client/GameObjects/EntitySystems/ConstructionSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/ConstructionSystem.cs @@ -51,8 +51,12 @@ namespace Content.Client.GameObjects.EntitySystems /// public override void Shutdown() { - CommandBinds.Unregister(); base.Shutdown(); + + UnsubscribeLocalEvent(); + UnsubscribeNetworkEvent(); + + CommandBinds.Unregister(); } public event EventHandler? CraftingAvailabilityChanged; diff --git a/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterSystem.cs b/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterSystem.cs index d0fde4ba02..56654dcaf7 100644 --- a/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterSystem.cs @@ -40,6 +40,12 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter SubscribeLocalEvent(HandlePlayerAttached); } + public override void Shutdown() + { + base.Shutdown(); + UnsubscribeLocalEvent(); + } + private void HandlePlayerAttached(PlayerAttachSysMessage message) { _attachedEntity = message.AttachedEntity; diff --git a/Content.Client/GameObjects/EntitySystems/HealthOverlay/HealthOverlaySystem.cs b/Content.Client/GameObjects/EntitySystems/HealthOverlay/HealthOverlaySystem.cs index 46001650b0..ff113fac88 100644 --- a/Content.Client/GameObjects/EntitySystems/HealthOverlay/HealthOverlaySystem.cs +++ b/Content.Client/GameObjects/EntitySystems/HealthOverlay/HealthOverlaySystem.cs @@ -46,6 +46,13 @@ namespace Content.Client.GameObjects.EntitySystems.HealthOverlay SubscribeLocalEvent(HandlePlayerAttached); } + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + } + public void Reset() { foreach (var gui in _guis.Values) diff --git a/Content.Client/GameObjects/EntitySystems/IconSmoothSystem.cs b/Content.Client/GameObjects/EntitySystems/IconSmoothSystem.cs index da24e8d78b..5a5c058d2c 100644 --- a/Content.Client/GameObjects/EntitySystems/IconSmoothSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/IconSmoothSystem.cs @@ -24,9 +24,16 @@ namespace Content.Client.GameObjects.EntitySystems /// public override void Initialize() { - SubscribeLocalEvent(HandleDirtyEvent); + base.Initialize(); - IoCManager.InjectDependencies(this); + SubscribeLocalEvent(HandleDirtyEvent); + } + + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); } public override void FrameUpdate(float frameTime) diff --git a/Content.Client/GameObjects/EntitySystems/VerbSystem.cs b/Content.Client/GameObjects/EntitySystems/VerbSystem.cs index 05fc585389..613e9b1cb1 100644 --- a/Content.Client/GameObjects/EntitySystems/VerbSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/VerbSystem.cs @@ -46,7 +46,6 @@ namespace Content.Client.GameObjects.EntitySystems public override void Initialize() { base.Initialize(); - IoCManager.InjectDependencies(this); SubscribeNetworkEvent(FillEntityPopup); SubscribeNetworkEvent(HandleContainerVisibilityMessage); @@ -62,11 +61,14 @@ namespace Content.Client.GameObjects.EntitySystems public override void Shutdown() { + base.Shutdown(); + + UnsubscribeNetworkEvent(); + UnsubscribeNetworkEvent(); UnsubscribeLocalEvent(); _contextMenuPresenter?.Dispose(); CommandBinds.Unregister(); - base.Shutdown(); } public void Reset() diff --git a/Content.Client/GameObjects/EntitySystems/WindowSystem.cs b/Content.Client/GameObjects/EntitySystems/WindowSystem.cs index 234c90073f..77f0133cdd 100644 --- a/Content.Client/GameObjects/EntitySystems/WindowSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/WindowSystem.cs @@ -17,6 +17,13 @@ namespace Content.Client.GameObjects.EntitySystems SubscribeLocalEvent(HandleDirtyEvent); } + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + } + private void HandleDirtyEvent(WindowSmoothDirtyEvent ev) { if (ev.Sender.HasComponent()) diff --git a/Content.IntegrationTests/Tests/Networking/SimplePredictReconcileTest.cs b/Content.IntegrationTests/Tests/Networking/SimplePredictReconcileTest.cs index 3708c0abe0..41ea1faab5 100644 --- a/Content.IntegrationTests/Tests/Networking/SimplePredictReconcileTest.cs +++ b/Content.IntegrationTests/Tests/Networking/SimplePredictReconcileTest.cs @@ -454,6 +454,13 @@ namespace Content.IntegrationTests.Tests.Networking SubscribeLocalEvent(HandleMessage); } + public override void Shutdown() + { + base.Shutdown(); + UnsubscribeNetworkEvent(); + UnsubscribeLocalEvent(); + } + private void HandleMessage(SetFooMessage message, EntitySessionEventArgs args) { var entity = EntityManager.GetEntity(message.Uid); diff --git a/Content.Server/GameObjects/EntitySystems/AI/AiSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/AiSystem.cs index 65793cd21f..dd0baff191 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/AiSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/AiSystem.cs @@ -45,6 +45,13 @@ namespace Content.Server.GameObjects.EntitySystems.AI SubscribeLocalEvent(MobStateChanged); } + public override void Shutdown() + { + base.Shutdown(); + UnsubscribeLocalEvent(); + UnsubscribeLocalEvent(); + } + /// public override void Update(float frameTime) { diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs index dea1ad68ef..a0adf2fd7c 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs @@ -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(); + UnsubscribeNetworkEvent(); + UnsubscribeNetworkEvent(); + } + 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(); - UnsubscribeLocalEvent(); - UnsubscribeNetworkEvent(); - UnsubscribeNetworkEvent(); - } - #if DEBUG private void HandleSubscription(SharedAiDebug.SubscribeReachableMessage message, EntitySessionEventArgs eventArgs) { diff --git a/Content.Server/GameObjects/EntitySystems/Body/Surgery/SurgeryToolSystem.cs b/Content.Server/GameObjects/EntitySystems/Body/Surgery/SurgeryToolSystem.cs index e63268b58c..95b20f1d89 100644 --- a/Content.Server/GameObjects/EntitySystems/Body/Surgery/SurgeryToolSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Body/Surgery/SurgeryToolSystem.cs @@ -22,6 +22,14 @@ namespace Content.Server.GameObjects.EntitySystems.Body.Surgery SubscribeLocalEvent(OnSurgeryWindowClose); } + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + UnsubscribeLocalEvent(); + } + public void Reset() { _openSurgeryUIs.Clear(); diff --git a/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs b/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs index ccf4e09435..8b9b3c9364 100644 --- a/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs @@ -27,6 +27,17 @@ namespace Content.Server.GameObjects.EntitySystems SubscribeLocalEvent(HandleAttackHand); } + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + UnsubscribeLocalEvent(); + UnsubscribeLocalEvent(); + + UnsubscribeLocalEvent(HandleAttackHand); + } + private void HandleAttackHand(EntityUid uid, BuckleComponent component, AttackHandMessage args) { args.Handled = component.TryUnbuckle(args.User); @@ -40,14 +51,6 @@ namespace Content.Server.GameObjects.EntitySystems } } - public override void Shutdown() - { - base.Shutdown(); - - UnsubscribeLocalEvent(); - UnsubscribeLocalEvent(HandleAttackHand); - } - private void MoveEvent(MoveEvent ev) { if (!ev.Sender.TryGetComponent(out BuckleComponent? buckle)) diff --git a/Content.Server/GameObjects/EntitySystems/GhostRoleSystem.cs b/Content.Server/GameObjects/EntitySystems/GhostRoleSystem.cs index 61e5ba93e2..3433bfb7af 100644 --- a/Content.Server/GameObjects/EntitySystems/GhostRoleSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/GhostRoleSystem.cs @@ -30,9 +30,18 @@ namespace Content.Server.GameObjects.EntitySystems public override void Initialize() { + base.Initialize(); + SubscribeLocalEvent(OnPlayerAttached); } + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + } + private uint GetNextRoleIdentifier() { return unchecked(_nextRoleIdentifier++); diff --git a/Content.Server/GameObjects/EntitySystems/HandsSystem.cs b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs index 410c83211c..cca7ae53f0 100644 --- a/Content.Server/GameObjects/EntitySystems/HandsSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs @@ -51,8 +51,12 @@ namespace Content.Server.GameObjects.EntitySystems /// public override void Shutdown() { - CommandBinds.Unregister(); base.Shutdown(); + + UnsubscribeLocalEvent(); + UnsubscribeLocalEvent(); + + CommandBinds.Unregister(); } private static void HandleContainerModified(ContainerModifiedMessage args) diff --git a/Content.Server/GameObjects/EntitySystems/StorageSystem.cs b/Content.Server/GameObjects/EntitySystems/StorageSystem.cs index 5c59a3f762..9455f6cc06 100644 --- a/Content.Server/GameObjects/EntitySystems/StorageSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/StorageSystem.cs @@ -16,10 +16,20 @@ namespace Content.Server.GameObjects.EntitySystems /// public override void Initialize() { + base.Initialize(); + SubscribeLocalEvent(HandleEntityRemovedFromContainer); SubscribeLocalEvent(HandleEntityInsertedIntoContainer); } + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + UnsubscribeLocalEvent(); + } + /// public override void Update(float frameTime) { diff --git a/Content.Server/GameObjects/EntitySystems/WeightlessSystem.cs b/Content.Server/GameObjects/EntitySystems/WeightlessSystem.cs index 0471b95336..74608420a9 100644 --- a/Content.Server/GameObjects/EntitySystems/WeightlessSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/WeightlessSystem.cs @@ -26,6 +26,14 @@ namespace Content.Server.GameObjects.EntitySystems SubscribeLocalEvent(EntParentChanged); } + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + UnsubscribeLocalEvent(); + } + public void Reset() { _alerts.Clear();