Files
tbd-station-14/Content.Server/Arcade/WireActions/ArcadeOverflowWireAction.cs
2023-01-16 08:14:46 +11:00

52 lines
1.4 KiB
C#

using Content.Server.Arcade.Components;
using Content.Server.Wires;
using Content.Shared.Arcade;
using Content.Shared.Wires;
namespace Content.Server.Arcade;
[DataDefinition]
public sealed class ArcadeOverflowWireAction : BaseToggleWireAction
{
private Color _color = Color.Red;
private string _text = "LMTR";
protected override string Text
{
get => _text;
set => _text = value;
}
public override object? StatusKey { get; } = SharedSpaceVillainArcadeComponent.Indicators.HealthLimiter;
public override void ToggleValue(EntityUid owner, bool setting)
{
if (EntityManager.TryGetComponent<SpaceVillainArcadeComponent>(owner, out var arcade))
{
arcade.OverflowFlag = !setting;
}
}
public override bool GetValue(EntityUid owner)
{
return EntityManager.TryGetComponent<SpaceVillainArcadeComponent>(owner, out var arcade)
&& !arcade.OverflowFlag;
}
public override StatusLightData? GetStatusLightData(Wire wire)
{
var lightState = StatusLightState.Off;
if (IsPowered(wire.Owner) && EntityManager.HasComponent<SpaceVillainArcadeComponent>(wire.Owner))
{
lightState = !GetValue(wire.Owner)
? StatusLightState.BlinkingSlow
: StatusLightState.On;
}
return new StatusLightData(
_color,
lightState,
_text);
}
}