From 3ca1c17290a4782093d691998f8530e95bd6b4a5 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Thu, 19 Jan 2023 11:56:25 +1100 Subject: [PATCH] Remove the last comp shutdown methods (#13582) --- .../Spawners/Components/TimedSpawnerComponent.cs | 8 +------- .../Spawners/EntitySystems/TimedDespawnSystem.cs | 12 ++++++++++++ .../Pulling/Components/SharedPullerComponent.cs | 6 ------ Content.Shared/Pulling/Systems/SharedPullerSystem.cs | 7 +++++++ 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Content.Server/Spawners/Components/TimedSpawnerComponent.cs b/Content.Server/Spawners/Components/TimedSpawnerComponent.cs index 07d997f983..e314a348c4 100644 --- a/Content.Server/Spawners/Components/TimedSpawnerComponent.cs +++ b/Content.Server/Spawners/Components/TimedSpawnerComponent.cs @@ -31,7 +31,7 @@ namespace Content.Server.Spawners.Components [DataField("MaximumEntitiesSpawned")] public int MaximumEntitiesSpawned { get; set; } = 1; - private CancellationTokenSource? TokenSource; + public CancellationTokenSource? TokenSource; void ISerializationHooks.AfterDeserialization() { @@ -45,12 +45,6 @@ namespace Content.Server.Spawners.Components SetupTimer(); } - protected override void Shutdown() - { - base.Shutdown(); - TokenSource?.Cancel(); - } - private void SetupTimer() { TokenSource?.Cancel(); diff --git a/Content.Server/Spawners/EntitySystems/TimedDespawnSystem.cs b/Content.Server/Spawners/EntitySystems/TimedDespawnSystem.cs index 66b3742e04..cadad4633e 100644 --- a/Content.Server/Spawners/EntitySystems/TimedDespawnSystem.cs +++ b/Content.Server/Spawners/EntitySystems/TimedDespawnSystem.cs @@ -1,9 +1,21 @@ +using Content.Server.Spawners.Components; using Content.Shared.Spawners.EntitySystems; namespace Content.Server.Spawners.EntitySystems; public sealed class TimedDespawnSystem : SharedTimedDespawnSystem { + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnTimedSpawnerShutdown); + } + + private void OnTimedSpawnerShutdown(EntityUid uid, TimedSpawnerComponent component, ComponentShutdown args) + { + component.TokenSource?.Cancel(); + } + protected override bool CanDelete(EntityUid uid) { return true; diff --git a/Content.Shared/Pulling/Components/SharedPullerComponent.cs b/Content.Shared/Pulling/Components/SharedPullerComponent.cs index 7e65326816..a2f82f8583 100644 --- a/Content.Shared/Pulling/Components/SharedPullerComponent.cs +++ b/Content.Shared/Pulling/Components/SharedPullerComponent.cs @@ -18,12 +18,6 @@ [DataField("needsHands")] public bool NeedsHands = true; - protected override void Shutdown() - { - EntitySystem.Get().ForceDisconnectPuller(this); - base.Shutdown(); - } - protected override void OnRemove() { if (Pulling != default) diff --git a/Content.Shared/Pulling/Systems/SharedPullerSystem.cs b/Content.Shared/Pulling/Systems/SharedPullerSystem.cs index 162bcb1c8f..5810a9c0ff 100644 --- a/Content.Shared/Pulling/Systems/SharedPullerSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullerSystem.cs @@ -12,6 +12,7 @@ namespace Content.Shared.Pulling.Systems [UsedImplicitly] public sealed class SharedPullerSystem : EntitySystem { + [Dependency] private readonly SharedPullingStateManagementSystem _why = default!; [Dependency] private readonly SharedPullingSystem _pullSystem = default!; [Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!; [Dependency] private readonly AlertsSystem _alertsSystem = default!; @@ -25,6 +26,12 @@ namespace Content.Shared.Pulling.Systems SubscribeLocalEvent(PullerHandlePullStopped); SubscribeLocalEvent(OnVirtualItemDeleted); SubscribeLocalEvent(OnRefreshMovespeed); + SubscribeLocalEvent(OnPullerShutdown); + } + + private void OnPullerShutdown(EntityUid uid, SharedPullerComponent component, ComponentShutdown args) + { + _why.ForceDisconnectPuller(component); } private void OnVirtualItemDeleted(EntityUid uid, SharedPullerComponent component, VirtualItemDeletedEvent args)