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,4 +1,4 @@
#nullable enable
#nullable enable
using System.Linq;
using System.Threading.Tasks;
using Content.Server.GameObjects.Components.GUI;
@@ -59,11 +59,6 @@ namespace Content.Server.GameObjects.Components.Power.AME
Owner.TryGetComponent(out _appearance);
if (Owner.TryGetComponent(out PowerReceiverComponent? receiver))
{
receiver.OnPowerStateChanged += OnPowerChanged;
}
Owner.TryGetComponent(out _powerSupplier);
_injecting = false;
@@ -71,6 +66,17 @@ namespace Content.Server.GameObjects.Components.Power.AME
_jarSlot = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-fuelJarContainer", Owner);
}
public override void HandleMessage(ComponentMessage message, IComponent? component)
{
base.HandleMessage(message, component);
switch (message)
{
case PowerChangedMessage powerChanged:
OnPowerChanged(powerChanged);
break;
}
}
internal void OnUpdate(float frameTime)
{
if(!_injecting)
@@ -127,7 +133,7 @@ namespace Content.Server.GameObjects.Components.Power.AME
}
}
private void OnPowerChanged(object? sender, PowerStateEventArgs e)
private void OnPowerChanged(PowerChangedMessage e)
{
UpdateUserInterface();
}