Nuke PowerChangedMessage (#7231)

This commit is contained in:
metalgearsloth
2022-03-29 03:58:51 +11:00
committed by GitHub
parent 2d610ebb52
commit 49163f1dec
18 changed files with 134 additions and 140 deletions

View File

@@ -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();

View File

@@ -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<ParticleAcceleratorControlBoxComponent, PowerChangedEvent>(OnControlBoxPowerChange);
}
private static void OnControlBoxPowerChange(EntityUid uid, ParticleAcceleratorControlBoxComponent component, PowerChangedEvent args)
{
component.OnPowerStateChanged(args);
}
}

View File

@@ -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<RotateEvent>(EventSource.Local, this, RotateEvent);
SubscribeLocalEvent<ParticleAcceleratorPartComponent, RotateEvent>(OnRotateEvent);
SubscribeLocalEvent<ParticleAcceleratorPartComponent, PhysicsBodyTypeChangedEvent>(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();
}
}
}

View File

@@ -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<ParticleAcceleratorPowerBoxComponent, PowerConsumerReceivedChanged>(
PowerBoxReceivedChanged);
SubscribeLocalEvent<ParticleAcceleratorPowerBoxComponent, PowerConsumerReceivedChanged>(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);
}
}
}

View File

@@ -0,0 +1,12 @@
namespace Content.Server.ParticleAccelerator.EntitySystems;
public sealed partial class ParticleAcceleratorSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
InitializeControlBoxSystem();
InitializePartSystem();
InitializePowerBoxSystem();
}
}