Replaces PowerReceiver's C# event with a ComponentMessage (#2888)

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2021-01-03 09:13:01 -06:00
committed by GitHub
parent 914a214a19
commit 32f04fd7ca
19 changed files with 182 additions and 181 deletions

View File

@@ -1,9 +1,10 @@
#nullable enable
#nullable enable
using System.Linq;
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using Robust.Server.GameObjects;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
@@ -81,25 +82,21 @@ namespace Content.Server.GameObjects.Components.BarSign
{
base.Initialize();
if (Owner.TryGetComponent(out PowerReceiverComponent? receiver))
{
receiver.OnPowerStateChanged += PowerOnOnPowerStateChanged;
}
UpdateSignInfo();
}
public override void OnRemove()
public override void HandleMessage(ComponentMessage message, IComponent? component)
{
if (Owner.TryGetComponent(out PowerReceiverComponent? receiver))
base.HandleMessage(message, component);
switch (message)
{
receiver.OnPowerStateChanged -= PowerOnOnPowerStateChanged;
case PowerChangedMessage powerChanged:
PowerOnOnPowerStateChanged(powerChanged);
break;
}
base.OnRemove();
}
private void PowerOnOnPowerStateChanged(object? sender, PowerStateEventArgs e)
private void PowerOnOnPowerStateChanged(PowerChangedMessage e)
{
UpdateSignInfo();
}