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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user