2020-06-28 09:23:26 -06:00
|
|
|
|
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
2019-08-12 18:00:02 +02:00
|
|
|
|
using Content.Shared.GameObjects.Components;
|
|
|
|
|
|
using Robust.Server.GameObjects;
|
|
|
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects.Components
|
|
|
|
|
|
{
|
|
|
|
|
|
[RegisterComponent]
|
|
|
|
|
|
public sealed class ComputerComponent : SharedComputerComponent
|
|
|
|
|
|
{
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
2020-06-28 09:23:26 -06:00
|
|
|
|
if (Owner.TryGetComponent(out PowerReceiverComponent powerReceiver))
|
2019-08-12 18:00:02 +02:00
|
|
|
|
{
|
2020-06-28 09:23:26 -06:00
|
|
|
|
powerReceiver.OnPowerStateChanged += PowerReceiverOnOnPowerStateChanged;
|
2019-08-12 18:00:02 +02:00
|
|
|
|
|
|
|
|
|
|
if (Owner.TryGetComponent(out AppearanceComponent appearance))
|
|
|
|
|
|
{
|
2020-06-28 09:23:26 -06:00
|
|
|
|
appearance.SetData(ComputerVisuals.Powered, powerReceiver.Powered);
|
2019-08-12 18:00:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-28 09:23:26 -06:00
|
|
|
|
public override void OnRemove()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Owner.TryGetComponent(out PowerReceiverComponent powerReceiver))
|
|
|
|
|
|
{
|
|
|
|
|
|
powerReceiver.OnPowerStateChanged -= PowerReceiverOnOnPowerStateChanged;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
base.OnRemove();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void PowerReceiverOnOnPowerStateChanged(object sender, PowerStateEventArgs e)
|
2019-08-12 18:00:02 +02:00
|
|
|
|
{
|
|
|
|
|
|
if (Owner.TryGetComponent(out AppearanceComponent appearance))
|
|
|
|
|
|
{
|
|
|
|
|
|
appearance.SetData(ComputerVisuals.Powered, e.Powered);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|