Files
OldThink/Content.Server/GameObjects/Components/ComputerComponent.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2019-08-12 18:00:02 +02:00
using Content.Server.GameObjects.Components.Power;
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();
if (Owner.TryGetComponent(out PowerDeviceComponent powerDevice))
{
powerDevice.OnPowerStateChanged += PowerDeviceOnOnPowerStateChanged;
if (Owner.TryGetComponent(out AppearanceComponent appearance))
{
appearance.SetData(ComputerVisuals.Powered, powerDevice.Powered);
}
}
}
private void PowerDeviceOnOnPowerStateChanged(object sender, PowerStateEventArgs e)
{
if (Owner.TryGetComponent(out AppearanceComponent appearance))
{
appearance.SetData(ComputerVisuals.Powered, e.Powered);
}
}
}
}