From: DrSmugleaf Date: Wed, 18 Oct 2023 02:35:36 +0000 (-0700) Subject: Replace Component.OnRemove with ComponentRemove event subscriptions (#21072) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=a136616531a9b1d8575dfa520be746f4b76b92eb;p=space-station-14.git Replace Component.OnRemove with ComponentRemove event subscriptions (#21072) --- diff --git a/Content.Server/Power/Components/ApcPowerReceiverComponent.cs b/Content.Server/Power/Components/ApcPowerReceiverComponent.cs index ae4d739430..b8340d0be4 100644 --- a/Content.Server/Power/Components/ApcPowerReceiverComponent.cs +++ b/Content.Server/Power/Components/ApcPowerReceiverComponent.cs @@ -59,13 +59,6 @@ namespace Content.Server.Power.Components }; public float PowerReceived => NetworkLoad.ReceivingPower; - - protected override void OnRemove() - { - Provider?.RemoveReceiver(this); - - base.OnRemove(); - } } /// diff --git a/Content.Server/Power/Components/BaseNetConnectorComponent.cs b/Content.Server/Power/Components/BaseNetConnectorComponent.cs index 551b5f3621..f2a1372dbc 100644 --- a/Content.Server/Power/Components/BaseNetConnectorComponent.cs +++ b/Content.Server/Power/Components/BaseNetConnectorComponent.cs @@ -33,12 +33,6 @@ namespace Content.Server.Power.Components [DataField("node")] public string? NodeId { get; set; } - protected override void OnRemove() - { - ClearNet(); - base.OnRemove(); - } - public void TryFindAndSetNet() { if (TryFindNet(out var net)) diff --git a/Content.Server/Power/EntitySystems/PowerNetConnectorSystem.cs b/Content.Server/Power/EntitySystems/PowerNetConnectorSystem.cs index df38c2f17a..8738f493ac 100644 --- a/Content.Server/Power/EntitySystems/PowerNetConnectorSystem.cs +++ b/Content.Server/Power/EntitySystems/PowerNetConnectorSystem.cs @@ -12,6 +12,21 @@ public sealed class PowerNetConnectorSystem : EntitySystem SubscribeLocalEvent(OnApcPowerProviderInit); SubscribeLocalEvent(OnBatteryChargerInit); SubscribeLocalEvent(OnBatteryDischargerInit); + + // TODO please end my life + SubscribeLocalEvent(OnRemove); + SubscribeLocalEvent(OnRemove); + SubscribeLocalEvent(OnRemove); + SubscribeLocalEvent(OnRemove); + SubscribeLocalEvent(OnRemove); + SubscribeLocalEvent(OnRemove); + } + + private void OnRemove(EntityUid uid, TComp component, ComponentRemove args) + where TComp : BaseNetConnectorComponent + where TNet : class + { + component.ClearNet(); } private void OnPowerSupplierInit(EntityUid uid, PowerSupplierComponent component, ComponentInit args) diff --git a/Content.Server/Power/EntitySystems/PowerNetSystem.cs b/Content.Server/Power/EntitySystems/PowerNetSystem.cs index a3aa1caee2..425f4637af 100644 --- a/Content.Server/Power/EntitySystems/PowerNetSystem.cs +++ b/Content.Server/Power/EntitySystems/PowerNetSystem.cs @@ -3,8 +3,8 @@ using Content.Server.NodeContainer.EntitySystems; using Content.Server.Power.Components; using Content.Server.Power.NodeGroups; using Content.Server.Power.Pow3r; -using JetBrains.Annotations; using Content.Shared.Power; +using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Shared.Threading; @@ -34,6 +34,7 @@ namespace Content.Server.Power.EntitySystems SubscribeLocalEvent(ApcPowerReceiverInit); SubscribeLocalEvent(ApcPowerReceiverShutdown); + SubscribeLocalEvent(ApcPowerReceiverRemove); SubscribeLocalEvent(ApcPowerReceiverPaused); SubscribeLocalEvent(ApcPowerReceiverUnpaused); @@ -64,6 +65,11 @@ namespace Content.Server.Power.EntitySystems _powerState.Loads.Free(component.NetworkLoad.Id); } + private void ApcPowerReceiverRemove(EntityUid uid, ApcPowerReceiverComponent component, ComponentRemove args) + { + component.Provider?.RemoveReceiver(component); + } + private static void ApcPowerReceiverPaused( EntityUid uid, ApcPowerReceiverComponent component, diff --git a/Content.Shared/Pulling/Components/PullableComponent.cs b/Content.Shared/Pulling/Components/PullableComponent.cs index 51ab2c91e4..30222c481b 100644 --- a/Content.Shared/Pulling/Components/PullableComponent.cs +++ b/Content.Shared/Pulling/Components/PullableComponent.cs @@ -1,6 +1,5 @@ using Robust.Shared.GameStates; using Robust.Shared.Map; -using Robust.Shared.Physics.Dynamics.Joints; using Robust.Shared.Serialization; namespace Content.Shared.Pulling.Components @@ -39,16 +38,6 @@ namespace Content.Shared.Pulling.Components [Access(typeof(SharedPullingSystem), Other = AccessPermissions.ReadExecute)] [ViewVariables] public bool PrevFixedRotation; - - protected override void OnRemove() - { - if (Puller != null) - { - // This is absolute paranoia but it's also absolutely necessary. Too many puller state bugs. - 20kdc - Logger.ErrorS("c.go.c.pulling", "PULLING STATE CORRUPTION IMMINENT IN PULLABLE {0} - OnRemove called when Puller is set!", Owner); - } - base.OnRemove(); - } } [Serializable, NetSerializable] diff --git a/Content.Shared/Pulling/Components/SharedPullerComponent.cs b/Content.Shared/Pulling/Components/SharedPullerComponent.cs index 4ee8b3d129..c21e8a76de 100644 --- a/Content.Shared/Pulling/Components/SharedPullerComponent.cs +++ b/Content.Shared/Pulling/Components/SharedPullerComponent.cs @@ -17,15 +17,5 @@ /// [DataField("needsHands")] public bool NeedsHands = true; - - protected override void OnRemove() - { - if (Pulling != default) - { - // This is absolute paranoia but it's also absolutely necessary. Too many puller state bugs. - 20kdc - Logger.ErrorS("c.go.c.pulling", "PULLING STATE CORRUPTION IMMINENT IN PULLER {0} - OnRemove called when Pulling is set!", Owner); - } - base.OnRemove(); - } } } diff --git a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs index 63f6d64867..974859a620 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs @@ -1,4 +1,3 @@ -using System.Linq; using Content.Shared.Physics.Pull; using Content.Shared.Pulling.Components; using JetBrains.Annotations;