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;
using System.Collections.Generic;
using System.Linq;
@@ -504,7 +504,7 @@ namespace Content.Server.GameObjects.Components.Disposal
UpdateInterface();
}
private void PowerStateChanged(object? sender, PowerStateEventArgs args)
private void PowerStateChanged(PowerChangedMessage args)
{
if (!args.Powered)
{
@@ -574,11 +574,6 @@ namespace Content.Server.GameObjects.Components.Disposal
physics.AnchoredChanged += UpdateVisualState;
}
if (Owner.TryGetComponent(out PowerReceiverComponent? receiver))
{
receiver.OnPowerStateChanged += PowerStateChanged;
}
UpdateVisualState();
}
@@ -589,11 +584,6 @@ namespace Content.Server.GameObjects.Components.Disposal
physics.AnchoredChanged -= UpdateVisualState;
}
if (Owner.TryGetComponent(out PowerReceiverComponent? receiver))
{
receiver.OnPowerStateChanged -= PowerStateChanged;
}
foreach (var entity in _container.ContainedEntities.ToArray())
{
_container.ForceRemove(entity);
@@ -626,6 +616,10 @@ namespace Content.Server.GameObjects.Components.Disposal
_lastExitAttempt = _gameTiming.CurTime;
Remove(msg.Entity);
break;
case PowerChangedMessage powerChanged:
PowerStateChanged(powerChanged);
break;
}
}