Replaces PowerReceiver's C# event with a ComponentMessage (#2888)
Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user