diff --git a/Content.Server/AME/AntimatterEngineSystem.cs b/Content.Server/AME/AntimatterEngineSystem.cs index a358ea7f13..5ed617ba56 100644 --- a/Content.Server/AME/AntimatterEngineSystem.cs +++ b/Content.Server/AME/AntimatterEngineSystem.cs @@ -1,6 +1,6 @@ using Content.Server.AME.Components; +using Content.Server.Power.Components; using JetBrains.Annotations; -using Robust.Shared.GameObjects; namespace Content.Server.AME { @@ -9,19 +9,33 @@ namespace Content.Server.AME { private float _accumulatedFrameTime; + private const float UpdateCooldown = 10f; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnAMEPowerChange); + } + public override void Update(float frameTime) { base.Update(frameTime); + + // TODO: Won't exactly work with replays I guess? _accumulatedFrameTime += frameTime; - if (_accumulatedFrameTime >= 10) + if (_accumulatedFrameTime >= UpdateCooldown) { foreach (var comp in EntityManager.EntityQuery()) { comp.OnUpdate(frameTime); } - _accumulatedFrameTime -= 10; + _accumulatedFrameTime -= UpdateCooldown; } + } + private static void OnAMEPowerChange(EntityUid uid, AMEControllerComponent component, PowerChangedEvent args) + { + component.UpdateUserInterface(); } } } diff --git a/Content.Server/AME/Components/AMEControllerComponent.cs b/Content.Server/AME/Components/AMEControllerComponent.cs index 515755cde4..6ff56213a0 100644 --- a/Content.Server/AME/Components/AMEControllerComponent.cs +++ b/Content.Server/AME/Components/AMEControllerComponent.cs @@ -62,20 +62,6 @@ namespace Content.Server.AME.Components _jarSlot = ContainerHelpers.EnsureContainer(Owner, $"{Name}-fuelJarContainer"); } - [Obsolete("Component Messages are deprecated, use Entity Events instead.")] - public override void HandleMessage(ComponentMessage message, IComponent? component) - { -#pragma warning disable 618 - base.HandleMessage(message, component); -#pragma warning restore 618 - switch (message) - { - case PowerChangedMessage powerChanged: - OnPowerChanged(powerChanged); - break; - } - } - internal void OnUpdate(float frameTime) { if (!_injecting) @@ -111,11 +97,6 @@ namespace Content.Server.AME.Components } - private void OnPowerChanged(PowerChangedMessage e) - { - UpdateUserInterface(); - } - // Used to update core count public void OnAMENodeGroupUpdate() { @@ -151,7 +132,7 @@ namespace Content.Server.AME.Components return true; } - private void UpdateUserInterface() + public void UpdateUserInterface() { var state = GetUserInterfaceState(); UserInterface?.SetState(state); diff --git a/Content.Server/Arcade/ArcadeSystem.BlockGame.cs b/Content.Server/Arcade/ArcadeSystem.BlockGame.cs new file mode 100644 index 0000000000..6c8370ee5f --- /dev/null +++ b/Content.Server/Arcade/ArcadeSystem.BlockGame.cs @@ -0,0 +1,17 @@ +using Content.Server.Arcade.Components; +using Content.Server.Power.Components; + +namespace Content.Server.Arcade; + +public sealed partial class ArcadeSystem +{ + private void InitializeBlockGame() + { + SubscribeLocalEvent(OnBlockPowerChanged); + } + + private static void OnBlockPowerChanged(EntityUid uid, BlockGameArcadeComponent component, PowerChangedEvent args) + { + component.OnPowerStateChanged(args); + } +} diff --git a/Content.Server/Arcade/ArcadeSystem.SpaceVillain.cs b/Content.Server/Arcade/ArcadeSystem.SpaceVillain.cs new file mode 100644 index 0000000000..7b99165cdb --- /dev/null +++ b/Content.Server/Arcade/ArcadeSystem.SpaceVillain.cs @@ -0,0 +1,17 @@ +using Content.Server.Arcade.Components; +using Content.Server.Power.Components; + +namespace Content.Server.Arcade; + +public sealed partial class ArcadeSystem +{ + private void InitializeSpaceVillain() + { + SubscribeLocalEvent(OnSVillainPower); + } + + private void OnSVillainPower(EntityUid uid, SpaceVillainArcadeComponent component, PowerChangedEvent args) + { + component.OnPowerStateChanged(args); + } +} diff --git a/Content.Server/Arcade/ArcadeSystem.cs b/Content.Server/Arcade/ArcadeSystem.cs index 5cdfaf2027..fa4c81626d 100644 --- a/Content.Server/Arcade/ArcadeSystem.cs +++ b/Content.Server/Arcade/ArcadeSystem.cs @@ -9,7 +9,7 @@ using Robust.Server.GameObjects; namespace Content.Server.Arcade { // ReSharper disable once ClassNeverInstantiated.Global - public sealed class ArcadeSystem : EntitySystem + public sealed partial class ArcadeSystem : EntitySystem { private readonly List _roundHighscores = new(); private readonly List _globalHighscores = new(); @@ -19,6 +19,8 @@ namespace Content.Server.Arcade base.Initialize(); SubscribeLocalEvent(OnAfterUIOpen); SubscribeLocalEvent(OnAfterUIOpenSV); + InitializeBlockGame(); + InitializeSpaceVillain(); } private void OnAfterUIOpen(EntityUid uid, BlockGameArcadeComponent component, AfterActivatableUIOpenEvent args) diff --git a/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs b/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs index e4bca71008..031b48bc7b 100644 --- a/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs +++ b/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs @@ -23,20 +23,6 @@ namespace Content.Server.Arcade.Components private IPlayerSession? _player; private readonly List _spectators = new(); - [Obsolete("Component Messages are deprecated, use Entity Events instead.")] - public override void HandleMessage(ComponentMessage message, IComponent? component) - { -#pragma warning disable 618 - base.HandleMessage(message, component); -#pragma warning restore 618 - switch (message) - { - case PowerChangedMessage powerChanged: - OnPowerStateChanged(powerChanged); - break; - } - } - public void RegisterPlayerSession(IPlayerSession session) { if (_player == null) _player = session; @@ -92,7 +78,7 @@ namespace Content.Server.Arcade.Components _game = new BlockGame(this); } - private void OnPowerStateChanged(PowerChangedMessage e) + public void OnPowerStateChanged(PowerChangedEvent e) { if (e.Powered) return; diff --git a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs index a1ab366b80..a95aece504 100644 --- a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs +++ b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs @@ -73,28 +73,13 @@ namespace Content.Server.Arcade.Components } } - [Obsolete("Component Messages are deprecated, use Entity Events instead.")] - public override void HandleMessage(ComponentMessage message, IComponent? component) - { -#pragma warning disable 618 - base.HandleMessage(message, component); -#pragma warning restore 618 - switch (message) - { - case PowerChangedMessage powerChanged: - OnOnPowerStateChanged(powerChanged); - break; - } - } - - private void OnOnPowerStateChanged(PowerChangedMessage e) + public void OnPowerStateChanged(PowerChangedEvent e) { if (e.Powered) return; UserInterface?.CloseAll(); } - private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage serverMsg) { if (!Powered) diff --git a/Content.Server/Chemistry/Components/ChemMasterComponent.cs b/Content.Server/Chemistry/Components/ChemMasterComponent.cs index a0004d163d..e5963a089c 100644 --- a/Content.Server/Chemistry/Components/ChemMasterComponent.cs +++ b/Content.Server/Chemistry/Components/ChemMasterComponent.cs @@ -68,25 +68,6 @@ namespace Content.Server.Chemistry.Components _bufferSolution = EntitySystem.Get().EnsureSolution(Owner, SolutionName); } - [Obsolete("Component Messages are deprecated, use Entity Events instead.")] - public override void HandleMessage(ComponentMessage message, IComponent? component) - { -#pragma warning disable 618 - base.HandleMessage(message, component); -#pragma warning restore 618 - switch (message) - { - case PowerChangedMessage: - OnPowerChanged(); - break; - } - } - - private void OnPowerChanged() - { - UpdateUserInterface(); - } - /// /// Handles ui messages from the client. For things such as button presses /// which interact with the world and require server action. diff --git a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs index 4511dabb0e..629f1ef0f8 100644 --- a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs +++ b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs @@ -74,20 +74,6 @@ namespace Content.Server.Chemistry.Components InitializeFromPrototype(); } - [Obsolete("Component Messages are deprecated, use Entity Events instead.")] - public override void HandleMessage(ComponentMessage message, IComponent? component) - { -#pragma warning disable 618 - base.HandleMessage(message, component); -#pragma warning restore 618 - switch (message) - { - case PowerChangedMessage powerChanged: - OnPowerChanged(powerChanged); - break; - } - } - /// /// Checks to see if the pack defined in this components yaml prototype /// exists. If so, it fills the reagent inventory list. @@ -127,7 +113,7 @@ namespace Content.Server.Chemistry.Components } - private void OnPowerChanged(PowerChangedMessage e) + public void OnPowerChanged() { UpdateUserInterface(); } diff --git a/Content.Server/Chemistry/EntitySystems/ChemistrySystem.ChemMaster.cs b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.ChemMaster.cs new file mode 100644 index 0000000000..86f374af09 --- /dev/null +++ b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.ChemMaster.cs @@ -0,0 +1,17 @@ +using Content.Server.Chemistry.Components; +using Content.Server.Power.Components; + +namespace Content.Server.Chemistry.EntitySystems; + +public sealed partial class ChemistrySystem +{ + private void InitializeChemMaster() + { + SubscribeLocalEvent(OnChemMasterPowerChange); + } + + private static void OnChemMasterPowerChange(EntityUid uid, ChemMasterComponent component, PowerChangedEvent args) + { + component.UpdateUserInterface(); + } +} diff --git a/Content.Server/Chemistry/EntitySystems/ChemistrySystem.ReagentDispenser.cs b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.ReagentDispenser.cs new file mode 100644 index 0000000000..d604b6654e --- /dev/null +++ b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.ReagentDispenser.cs @@ -0,0 +1,17 @@ +using Content.Server.Chemistry.Components; +using Content.Server.Power.Components; + +namespace Content.Server.Chemistry.EntitySystems; + +public sealed partial class ChemistrySystem +{ + private void InitializeReagentDispenser() + { + SubscribeLocalEvent(OnReagentDispenserPower); + } + + private static void OnReagentDispenserPower(EntityUid uid, ReagentDispenserComponent component, PowerChangedEvent args) + { + component.OnPowerChanged(); + } +} diff --git a/Content.Server/Chemistry/EntitySystems/ChemistrySystem.cs b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.cs index 27dfa55972..5ab05ef506 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemistrySystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.cs @@ -18,7 +18,10 @@ public sealed partial class ChemistrySystem : EntitySystem public override void Initialize() { + // Why ChemMaster duplicates reagentdispenser nobody knows. + InitializeChemMaster(); InitializeHypospray(); InitializeInjector(); + InitializeReagentDispenser(); } } diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs index 01c80efd2e..a8de028692 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs @@ -99,20 +99,6 @@ namespace Content.Server.ParticleAccelerator.Components _apcPowerReceiverComponent!.Load = 250; } - [Obsolete("Component Messages are deprecated, use Entity Events instead.")] - public override void HandleMessage(ComponentMessage message, IComponent? component) - { -#pragma warning disable 618 - base.HandleMessage(message, component); -#pragma warning restore 618 - switch (message) - { - case PowerChangedMessage powerChanged: - OnPowerStateChanged(powerChanged); - break; - } - } - protected override void Startup() { base.Startup(); @@ -122,7 +108,7 @@ namespace Content.Server.ParticleAccelerator.Components // This is the power state for the PA control box itself. // Keep in mind that the PA itself can keep firing as long as the HV cable under the power box has... power. - private void OnPowerStateChanged(PowerChangedMessage e) + public void OnPowerStateChanged(PowerChangedEvent e) { UpdateAppearance(); diff --git a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.ControlBox.cs b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.ControlBox.cs new file mode 100644 index 0000000000..91c6d5b4a7 --- /dev/null +++ b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.ControlBox.cs @@ -0,0 +1,17 @@ +using Content.Server.ParticleAccelerator.Components; +using Content.Server.Power.Components; + +namespace Content.Server.ParticleAccelerator.EntitySystems; + +public sealed partial class ParticleAcceleratorSystem +{ + private void InitializeControlBoxSystem() + { + SubscribeLocalEvent(OnControlBoxPowerChange); + } + + private static void OnControlBoxPowerChange(EntityUid uid, ParticleAcceleratorControlBoxComponent component, PowerChangedEvent args) + { + component.OnPowerStateChanged(args); + } +} diff --git a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPartSystem.cs b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs similarity index 52% rename from Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPartSystem.cs rename to Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs index e68f5e5470..d087bab9d2 100644 --- a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPartSystem.cs +++ b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs @@ -1,18 +1,14 @@ using Content.Server.ParticleAccelerator.Components; using JetBrains.Annotations; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; namespace Content.Server.ParticleAccelerator.EntitySystems { [UsedImplicitly] - public sealed class ParticleAcceleratorPartSystem : EntitySystem + public sealed partial class ParticleAcceleratorSystem { - public override void Initialize() + private void InitializePartSystem() { - base.Initialize(); - - EntityManager.EventBus.SubscribeEvent(EventSource.Local, this, RotateEvent); + SubscribeLocalEvent(OnRotateEvent); SubscribeLocalEvent(BodyTypeChanged); } @@ -24,12 +20,9 @@ namespace Content.Server.ParticleAccelerator.EntitySystems component.OnAnchorChanged(); } - private void RotateEvent(ref RotateEvent ev) + private static void OnRotateEvent(EntityUid uid, ParticleAcceleratorPartComponent component, ref RotateEvent args) { - if (EntityManager.TryGetComponent(ev.Sender, out ParticleAcceleratorPartComponent? part)) - { - part.Rotated(); - } + component.Rotated(); } } } diff --git a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPowerBoxSystem.cs b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.PowerBox.cs similarity index 59% rename from Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPowerBoxSystem.cs rename to Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.PowerBox.cs index b71f010544..62f9d4370f 100644 --- a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPowerBoxSystem.cs +++ b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.PowerBox.cs @@ -5,15 +5,11 @@ using Robust.Shared.GameObjects; namespace Content.Server.ParticleAccelerator.EntitySystems { - [UsedImplicitly] - public sealed class ParticleAcceleratorPowerBoxSystem : EntitySystem + public sealed partial class ParticleAcceleratorSystem { - public override void Initialize() + private void InitializePowerBoxSystem() { - base.Initialize(); - - SubscribeLocalEvent( - PowerBoxReceivedChanged); + SubscribeLocalEvent(PowerBoxReceivedChanged); } private static void PowerBoxReceivedChanged( @@ -21,8 +17,7 @@ namespace Content.Server.ParticleAccelerator.EntitySystems ParticleAcceleratorPowerBoxComponent component, PowerConsumerReceivedChanged args) { - if (component.Master != null) - component.Master.PowerBoxReceivedChanged(args); + component.Master?.PowerBoxReceivedChanged(args); } } } diff --git a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.cs b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.cs new file mode 100644 index 0000000000..a3c8a19779 --- /dev/null +++ b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.cs @@ -0,0 +1,12 @@ +namespace Content.Server.ParticleAccelerator.EntitySystems; + +public sealed partial class ParticleAcceleratorSystem : EntitySystem +{ + public override void Initialize() + { + base.Initialize(); + InitializeControlBoxSystem(); + InitializePartSystem(); + InitializePowerBoxSystem(); + } +} diff --git a/Content.Server/Power/Components/ApcPowerReceiverComponent.cs b/Content.Server/Power/Components/ApcPowerReceiverComponent.cs index 2c5a6d68c8..71b6bfc0dc 100644 --- a/Content.Server/Power/Components/ApcPowerReceiverComponent.cs +++ b/Content.Server/Power/Components/ApcPowerReceiverComponent.cs @@ -82,9 +82,6 @@ namespace Content.Server.Power.Components public void ApcPowerChanged() { -#pragma warning disable 618 - SendMessage(new PowerChangedMessage(Powered)); -#pragma warning restore 618 _entMan.EventBus.RaiseLocalEvent(Owner, new PowerChangedEvent(Powered, NetworkLoad.ReceivingPower)); if (_entMan.TryGetComponent(Owner, out var appearance)) @@ -104,18 +101,6 @@ namespace Content.Server.Power.Components } } -#pragma warning disable 618 - public sealed class PowerChangedMessage : ComponentMessage -#pragma warning restore 618 - { - public readonly bool Powered; - - public PowerChangedMessage(bool powered) - { - Powered = powered; - } - } - /// /// Raised whenever an ApcPowerReceiver becomes powered / unpowered. ///