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

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

View 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);
}
}

View File

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

View File

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

View File

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