Power Rework (#863)

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2020-06-28 09:23:26 -06:00
committed by GitHub
parent ffe25de723
commit 23cc6b1d4e
154 changed files with 11253 additions and 3913 deletions

View File

@@ -1,4 +1,4 @@
using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using Content.Shared.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
@@ -12,18 +12,28 @@ namespace Content.Server.GameObjects.Components
{
base.Initialize();
if (Owner.TryGetComponent(out PowerDeviceComponent powerDevice))
if (Owner.TryGetComponent(out PowerReceiverComponent powerReceiver))
{
powerDevice.OnPowerStateChanged += PowerDeviceOnOnPowerStateChanged;
powerReceiver.OnPowerStateChanged += PowerReceiverOnOnPowerStateChanged;
if (Owner.TryGetComponent(out AppearanceComponent appearance))
{
appearance.SetData(ComputerVisuals.Powered, powerDevice.Powered);
appearance.SetData(ComputerVisuals.Powered, powerReceiver.Powered);
}
}
}
private void PowerDeviceOnOnPowerStateChanged(object sender, PowerStateEventArgs e)
public override void OnRemove()
{
if (Owner.TryGetComponent(out PowerReceiverComponent powerReceiver))
{
powerReceiver.OnPowerStateChanged -= PowerReceiverOnOnPowerStateChanged;
}
base.OnRemove();
}
private void PowerReceiverOnOnPowerStateChanged(object sender, PowerStateEventArgs e)
{
if (Owner.TryGetComponent(out AppearanceComponent appearance))
{