Nuke PowerChangedMessage (#7231)
This commit is contained in:
@@ -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<AMEControllerComponent, PowerChangedEvent>(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<AMEControllerComponent>())
|
||||
{
|
||||
comp.OnUpdate(frameTime);
|
||||
}
|
||||
_accumulatedFrameTime -= 10;
|
||||
_accumulatedFrameTime -= UpdateCooldown;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnAMEPowerChange(EntityUid uid, AMEControllerComponent component, PowerChangedEvent args)
|
||||
{
|
||||
component.UpdateUserInterface();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,20 +62,6 @@ namespace Content.Server.AME.Components
|
||||
_jarSlot = ContainerHelpers.EnsureContainer<ContainerSlot>(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);
|
||||
|
||||
17
Content.Server/Arcade/ArcadeSystem.BlockGame.cs
Normal file
17
Content.Server/Arcade/ArcadeSystem.BlockGame.cs
Normal file
@@ -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<BlockGameArcadeComponent, PowerChangedEvent>(OnBlockPowerChanged);
|
||||
}
|
||||
|
||||
private static void OnBlockPowerChanged(EntityUid uid, BlockGameArcadeComponent component, PowerChangedEvent args)
|
||||
{
|
||||
component.OnPowerStateChanged(args);
|
||||
}
|
||||
}
|
||||
17
Content.Server/Arcade/ArcadeSystem.SpaceVillain.cs
Normal file
17
Content.Server/Arcade/ArcadeSystem.SpaceVillain.cs
Normal file
@@ -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<SpaceVillainArcadeComponent, PowerChangedEvent>(OnSVillainPower);
|
||||
}
|
||||
|
||||
private void OnSVillainPower(EntityUid uid, SpaceVillainArcadeComponent component, PowerChangedEvent args)
|
||||
{
|
||||
component.OnPowerStateChanged(args);
|
||||
}
|
||||
}
|
||||
@@ -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<BlockGameMessages.HighScoreEntry> _roundHighscores = new();
|
||||
private readonly List<BlockGameMessages.HighScoreEntry> _globalHighscores = new();
|
||||
@@ -19,6 +19,8 @@ namespace Content.Server.Arcade
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<BlockGameArcadeComponent, AfterActivatableUIOpenEvent>(OnAfterUIOpen);
|
||||
SubscribeLocalEvent<SpaceVillainArcadeComponent, AfterActivatableUIOpenEvent>(OnAfterUIOpenSV);
|
||||
InitializeBlockGame();
|
||||
InitializeSpaceVillain();
|
||||
}
|
||||
|
||||
private void OnAfterUIOpen(EntityUid uid, BlockGameArcadeComponent component, AfterActivatableUIOpenEvent args)
|
||||
|
||||
@@ -23,20 +23,6 @@ namespace Content.Server.Arcade.Components
|
||||
private IPlayerSession? _player;
|
||||
private readonly List<IPlayerSession> _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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -68,25 +68,6 @@ namespace Content.Server.Chemistry.Components
|
||||
_bufferSolution = EntitySystem.Get<SolutionContainerSystem>().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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles ui messages from the client. For things such as button presses
|
||||
/// which interact with the world and require server action.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if the <c>pack</c> 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();
|
||||
}
|
||||
|
||||
@@ -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<ChemMasterComponent, PowerChangedEvent>(OnChemMasterPowerChange);
|
||||
}
|
||||
|
||||
private static void OnChemMasterPowerChange(EntityUid uid, ChemMasterComponent component, PowerChangedEvent args)
|
||||
{
|
||||
component.UpdateUserInterface();
|
||||
}
|
||||
}
|
||||
@@ -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<ReagentDispenserComponent, PowerChangedEvent>(OnReagentDispenserPower);
|
||||
}
|
||||
|
||||
private static void OnReagentDispenserPower(EntityUid uid, ReagentDispenserComponent component, PowerChangedEvent args)
|
||||
{
|
||||
component.OnPowerChanged();
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,10 @@ public sealed partial class ChemistrySystem : EntitySystem
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
// Why ChemMaster duplicates reagentdispenser nobody knows.
|
||||
InitializeChemMaster();
|
||||
InitializeHypospray();
|
||||
InitializeInjector();
|
||||
InitializeReagentDispenser();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Content.Server.ParticleAccelerator.EntitySystems;
|
||||
|
||||
public sealed partial class ParticleAcceleratorSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
InitializeControlBoxSystem();
|
||||
InitializePartSystem();
|
||||
InitializePowerBoxSystem();
|
||||
}
|
||||
}
|
||||
@@ -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<AppearanceComponent?>(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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised whenever an ApcPowerReceiver becomes powered / unpowered.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user