From 251df93b71454d77d7bae1efee68d164e03c1a3a Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Thu, 13 May 2021 02:05:46 +0200 Subject: [PATCH] Remove usages of AnchoredChangedMessage. It was a component message which is now deprecated. --- .../Components/Atmos/GasCanisterComponent.cs | 13 +------- .../Disposal/DisposalMailingUnitComponent.cs | 6 +--- .../Disposal/DisposalTubeComponent.cs | 6 +--- .../Disposal/DisposalUnitComponent.cs | 6 +--- .../PA/ParticleAcceleratorPartComponent.cs | 11 ------- .../PowerReceiverComponent.cs | 13 +------- .../RadiationCollectorComponent.cs | 13 +------- .../ContainmentFieldGeneratorComponent.cs | 14 +-------- .../ContainmentFieldGeneratorSystem.cs | 30 +++++++++++++++++++ .../Disposal/DisposalMailingUnitSystem.cs | 30 +++++++++++++++++++ .../Disposal/DisposalTubeSystem.cs | 30 +++++++++++++++++++ .../Disposal/DisposalUnitSystem.cs | 30 +++++++++++++++++++ .../EntitySystems/GasCanisterSystem.cs | 22 ++++++++++++++ .../ParticleAcceleratorPartSystem.cs | 16 ++++++++++ .../Power/PowerReceiverSystem.cs | 30 +++++++++++++++++++ .../Power/RadiationCollectorSystem.cs | 30 +++++++++++++++++++ 16 files changed, 225 insertions(+), 75 deletions(-) create mode 100644 Content.Server/GameObjects/EntitySystems/ContainmentFieldGeneratorSystem.cs create mode 100644 Content.Server/GameObjects/EntitySystems/Disposal/DisposalMailingUnitSystem.cs create mode 100644 Content.Server/GameObjects/EntitySystems/Disposal/DisposalTubeSystem.cs create mode 100644 Content.Server/GameObjects/EntitySystems/Disposal/DisposalUnitSystem.cs create mode 100644 Content.Server/GameObjects/EntitySystems/Power/PowerReceiverSystem.cs create mode 100644 Content.Server/GameObjects/EntitySystems/Power/RadiationCollectorSystem.cs diff --git a/Content.Server/GameObjects/Components/Atmos/GasCanisterComponent.cs b/Content.Server/GameObjects/Components/Atmos/GasCanisterComponent.cs index c937e9ca41..cb8b816b0e 100644 --- a/Content.Server/GameObjects/Components/Atmos/GasCanisterComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/GasCanisterComponent.cs @@ -94,17 +94,6 @@ namespace Content.Server.GameObjects.Components.Atmos UpdateAppearance(); } - public override void HandleMessage(ComponentMessage message, IComponent? component) - { - base.HandleMessage(message, component); - switch (message) - { - case AnchoredChangedMessage: - AnchorUpdate(); - break; - } - } - #region Connector port methods public override void OnRemove() @@ -139,7 +128,7 @@ namespace Content.Server.GameObjects.Components.Atmos ConnectedPort = null; } - private void AnchorUpdate() + public void AnchorUpdate() { if (Anchored) { diff --git a/Content.Server/GameObjects/Components/Disposal/DisposalMailingUnitComponent.cs b/Content.Server/GameObjects/Components/Disposal/DisposalMailingUnitComponent.cs index 86a5412a07..7d1cf436aa 100644 --- a/Content.Server/GameObjects/Components/Disposal/DisposalMailingUnitComponent.cs +++ b/Content.Server/GameObjects/Components/Disposal/DisposalMailingUnitComponent.cs @@ -445,7 +445,7 @@ namespace Content.Server.GameObjects.Components.Disposal _tag = tag; } - private void UpdateVisualState() + public void UpdateVisualState() { UpdateVisualState(false); } @@ -620,10 +620,6 @@ namespace Content.Server.GameObjects.Components.Disposal Remove(msg.Entity); break; - case AnchoredChangedMessage: - UpdateVisualState(); - break; - case PowerChangedMessage powerChanged: PowerStateChanged(powerChanged); break; diff --git a/Content.Server/GameObjects/Components/Disposal/DisposalTubeComponent.cs b/Content.Server/GameObjects/Components/Disposal/DisposalTubeComponent.cs index e351b3ee08..9755610ff4 100644 --- a/Content.Server/GameObjects/Components/Disposal/DisposalTubeComponent.cs +++ b/Content.Server/GameObjects/Components/Disposal/DisposalTubeComponent.cs @@ -194,7 +194,7 @@ namespace Content.Server.GameObjects.Components.Disposal appearance.SetData(DisposalTubeVisuals.VisualState, state); } - private void AnchoredChanged() + public void AnchoredChanged() { if (!Owner.TryGetComponent(out PhysicsComponent? physics)) { @@ -267,10 +267,6 @@ namespace Content.Server.GameObjects.Components.Disposal _lastClang = _gameTiming.CurTime; SoundSystem.Play(Filter.Pvs(Owner), _clangSound, Owner.Transform.Coordinates); break; - - case AnchoredChangedMessage: - AnchoredChanged(); - break; } } diff --git a/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs b/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs index 0a906d5bef..e206a53748 100644 --- a/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs +++ b/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs @@ -382,7 +382,7 @@ namespace Content.Server.GameObjects.Components.Disposal } } - private void UpdateVisualState() + public void UpdateVisualState() { UpdateVisualState(false); } @@ -547,10 +547,6 @@ namespace Content.Server.GameObjects.Components.Disposal Remove(msg.Entity); break; - case AnchoredChangedMessage: - UpdateVisualState(); - break; - case PowerChangedMessage powerChanged: PowerStateChanged(powerChanged); break; diff --git a/Content.Server/GameObjects/Components/PA/ParticleAcceleratorPartComponent.cs b/Content.Server/GameObjects/Components/PA/ParticleAcceleratorPartComponent.cs index de6c9f56c8..7d72c785b6 100644 --- a/Content.Server/GameObjects/Components/PA/ParticleAcceleratorPartComponent.cs +++ b/Content.Server/GameObjects/Components/PA/ParticleAcceleratorPartComponent.cs @@ -16,17 +16,6 @@ namespace Content.Server.GameObjects.Components.PA Owner.Transform.Anchored = true; } - public override void HandleMessage(ComponentMessage message, IComponent? component) - { - base.HandleMessage(message, component); - switch (message) - { - case AnchoredChangedMessage: - OnAnchorChanged(); - break; - } - } - public void OnAnchorChanged() { RescanIfPossible(); diff --git a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs index a86a5a94f2..71f8dc2289 100644 --- a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs +++ b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs @@ -106,17 +106,6 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents } } - public override void HandleMessage(ComponentMessage message, IComponent? component) - { - base.HandleMessage(message, component); - switch (message) - { - case AnchoredChangedMessage: - AnchorUpdate(); - break; - } - } - public void ApcPowerChanged() { var oldPowered = Powered; @@ -211,7 +200,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents } } - private void AnchorUpdate() + public void AnchorUpdate() { if (Anchored) { diff --git a/Content.Server/GameObjects/Components/Power/PowerNetComponents/RadiationCollectorComponent.cs b/Content.Server/GameObjects/Components/Power/PowerNetComponents/RadiationCollectorComponent.cs index 6fc041c302..72de6f934d 100644 --- a/Content.Server/GameObjects/Components/Power/PowerNetComponents/RadiationCollectorComponent.cs +++ b/Content.Server/GameObjects/Components/Power/PowerNetComponents/RadiationCollectorComponent.cs @@ -25,18 +25,7 @@ namespace Content.Server.GameObjects.Components.Power.PowerNetComponents [ComponentDependency] private readonly PhysicsComponent? _collidableComponent = default!; - public override void HandleMessage(ComponentMessage message, IComponent? component) - { - base.HandleMessage(message, component); - switch (message) - { - case AnchoredChangedMessage: - OnAnchoredChanged(); - break; - } - } - - private void OnAnchoredChanged() + public void OnAnchoredChanged() { if(_collidableComponent != null && _collidableComponent.BodyType == BodyType.Static) Owner.SnapToGrid(); diff --git a/Content.Server/GameObjects/Components/Singularity/ContainmentFieldGeneratorComponent.cs b/Content.Server/GameObjects/Components/Singularity/ContainmentFieldGeneratorComponent.cs index b4afa98712..17381b7a66 100644 --- a/Content.Server/GameObjects/Components/Singularity/ContainmentFieldGeneratorComponent.cs +++ b/Content.Server/GameObjects/Components/Singularity/ContainmentFieldGeneratorComponent.cs @@ -5,7 +5,6 @@ using System.Linq; using Content.Shared.GameObjects.Components.Tag; using Content.Shared.Physics; using Robust.Shared.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Maths; using Robust.Shared.Physics; @@ -70,18 +69,7 @@ namespace Content.Server.GameObjects.Components.Singularity public bool CanRepell(IEntity toRepell) => _connection1?.Item2?.CanRepell(toRepell) == true || _connection2?.Item2?.CanRepell(toRepell) == true; - public override void HandleMessage(ComponentMessage message, IComponent? component) - { - base.HandleMessage(message, component); - switch (message) - { - case AnchoredChangedMessage: - OnAnchoredChanged(); - break; - } - } - - private void OnAnchoredChanged() + public void OnAnchoredChanged() { if(_collidableComponent?.BodyType != BodyType.Static) { diff --git a/Content.Server/GameObjects/EntitySystems/ContainmentFieldGeneratorSystem.cs b/Content.Server/GameObjects/EntitySystems/ContainmentFieldGeneratorSystem.cs new file mode 100644 index 0000000000..c817c69855 --- /dev/null +++ b/Content.Server/GameObjects/EntitySystems/ContainmentFieldGeneratorSystem.cs @@ -0,0 +1,30 @@ +using Content.Server.GameObjects.Components.Singularity; +using Robust.Shared.GameObjects; + +namespace Content.Server.GameObjects.EntitySystems +{ + public sealed class ContainmentFieldGeneratorSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(BodyTypeChanged); + } + + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + } + + private static void BodyTypeChanged( + EntityUid uid, + ContainmentFieldGeneratorComponent component, + PhysicsBodyTypeChangedEvent args) + { + component.OnAnchoredChanged(); + } + } +} diff --git a/Content.Server/GameObjects/EntitySystems/Disposal/DisposalMailingUnitSystem.cs b/Content.Server/GameObjects/EntitySystems/Disposal/DisposalMailingUnitSystem.cs new file mode 100644 index 0000000000..1082d93fee --- /dev/null +++ b/Content.Server/GameObjects/EntitySystems/Disposal/DisposalMailingUnitSystem.cs @@ -0,0 +1,30 @@ +using Content.Server.GameObjects.Components.Disposal; +using Robust.Shared.GameObjects; + +namespace Content.Server.GameObjects.EntitySystems.Disposal +{ + public sealed class DisposalMailingUnitSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(BodyTypeChanged); + } + + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + } + + private static void BodyTypeChanged( + EntityUid uid, + DisposalMailingUnitComponent component, + PhysicsBodyTypeChangedEvent args) + { + component.UpdateVisualState(); + } + } +} diff --git a/Content.Server/GameObjects/EntitySystems/Disposal/DisposalTubeSystem.cs b/Content.Server/GameObjects/EntitySystems/Disposal/DisposalTubeSystem.cs new file mode 100644 index 0000000000..1b89a9f39e --- /dev/null +++ b/Content.Server/GameObjects/EntitySystems/Disposal/DisposalTubeSystem.cs @@ -0,0 +1,30 @@ +using Content.Server.GameObjects.Components.Disposal; +using Robust.Shared.GameObjects; + +namespace Content.Server.GameObjects.EntitySystems.Disposal +{ + public sealed class DisposalTubeSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(BodyTypeChanged); + } + + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + } + + private static void BodyTypeChanged( + EntityUid uid, + DisposalTubeComponent component, + PhysicsBodyTypeChangedEvent args) + { + component.AnchoredChanged(); + } + } +} diff --git a/Content.Server/GameObjects/EntitySystems/Disposal/DisposalUnitSystem.cs b/Content.Server/GameObjects/EntitySystems/Disposal/DisposalUnitSystem.cs new file mode 100644 index 0000000000..dad718a116 --- /dev/null +++ b/Content.Server/GameObjects/EntitySystems/Disposal/DisposalUnitSystem.cs @@ -0,0 +1,30 @@ +using Content.Server.GameObjects.Components.Disposal; +using Robust.Shared.GameObjects; + +namespace Content.Server.GameObjects.EntitySystems.Disposal +{ + public sealed class DisposalUnitSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(BodyTypeChanged); + } + + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + } + + private static void BodyTypeChanged( + EntityUid uid, + DisposalUnitComponent component, + PhysicsBodyTypeChangedEvent args) + { + component.UpdateVisualState(); + } + } +} diff --git a/Content.Server/GameObjects/EntitySystems/GasCanisterSystem.cs b/Content.Server/GameObjects/EntitySystems/GasCanisterSystem.cs index f895b706e0..e1d030ae97 100644 --- a/Content.Server/GameObjects/EntitySystems/GasCanisterSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/GasCanisterSystem.cs @@ -7,6 +7,28 @@ namespace Content.Server.GameObjects.EntitySystems [UsedImplicitly] internal sealed class GasCanisterSystem : EntitySystem { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnBodyTypeChanged); + } + + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + } + + private static void OnBodyTypeChanged( + EntityUid uid, + GasCanisterComponent component, + PhysicsBodyTypeChangedEvent args) + { + component.AnchorUpdate(); + } + public override void Update(float frameTime) { foreach (var component in ComponentManager.EntityQuery(true)) diff --git a/Content.Server/GameObjects/EntitySystems/ParticleAcceleratorPartSystem.cs b/Content.Server/GameObjects/EntitySystems/ParticleAcceleratorPartSystem.cs index 13c6ffef50..0c3cc08ac1 100644 --- a/Content.Server/GameObjects/EntitySystems/ParticleAcceleratorPartSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/ParticleAcceleratorPartSystem.cs @@ -13,6 +13,22 @@ namespace Content.Server.GameObjects.EntitySystems base.Initialize(); EntityManager.EventBus.SubscribeEvent(EventSource.Local, this, RotateEvent); + SubscribeLocalEvent(BodyTypeChanged); + } + + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + } + + private static void BodyTypeChanged( + EntityUid uid, + ParticleAcceleratorPartComponent component, + PhysicsBodyTypeChangedEvent args) + { + component.OnAnchorChanged(); } private static void RotateEvent(RotateEvent ev) diff --git a/Content.Server/GameObjects/EntitySystems/Power/PowerReceiverSystem.cs b/Content.Server/GameObjects/EntitySystems/Power/PowerReceiverSystem.cs new file mode 100644 index 0000000000..e71f011669 --- /dev/null +++ b/Content.Server/GameObjects/EntitySystems/Power/PowerReceiverSystem.cs @@ -0,0 +1,30 @@ +using Content.Server.GameObjects.Components.Power.ApcNetComponents; +using Robust.Shared.GameObjects; + +namespace Content.Server.GameObjects.EntitySystems +{ + public sealed class PowerReceiverSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(BodyTypeChanged); + } + + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + } + + private static void BodyTypeChanged( + EntityUid uid, + PowerReceiverComponent component, + PhysicsBodyTypeChangedEvent args) + { + component.AnchorUpdate(); + } + } +} diff --git a/Content.Server/GameObjects/EntitySystems/Power/RadiationCollectorSystem.cs b/Content.Server/GameObjects/EntitySystems/Power/RadiationCollectorSystem.cs new file mode 100644 index 0000000000..f98b65a90f --- /dev/null +++ b/Content.Server/GameObjects/EntitySystems/Power/RadiationCollectorSystem.cs @@ -0,0 +1,30 @@ +using Content.Server.GameObjects.Components.Power.PowerNetComponents; +using Robust.Shared.GameObjects; + +namespace Content.Server.GameObjects.EntitySystems +{ + public sealed class RadiationCollectorSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(BodyTypeChanged); + } + + public override void Shutdown() + { + base.Shutdown(); + + UnsubscribeLocalEvent(); + } + + private static void BodyTypeChanged( + EntityUid uid, + RadiationCollectorComponent component, + PhysicsBodyTypeChangedEvent args) + { + component.OnAnchoredChanged(); + } + } +}