Wire action cleanup (#13496)
This commit is contained in:
@@ -7,36 +7,19 @@ using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.Atmos.Monitor;
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class AirAlarmPanicWire : BaseWireAction
|
||||
public sealed class AirAlarmPanicWire : ComponentWireAction<AirAlarmComponent>
|
||||
{
|
||||
private string _text = "PANC";
|
||||
protected override string Text
|
||||
{
|
||||
get => _text;
|
||||
set => _text = value;
|
||||
}
|
||||
private Color _color = Color.Red;
|
||||
public override string Name { get; set; } = "wire-name-air-alarm-panic";
|
||||
public override Color Color { get; set; } = Color.Red;
|
||||
|
||||
private AirAlarmSystem _airAlarmSystem = default!;
|
||||
|
||||
public override object StatusKey { get; } = AirAlarmWireStatus.Panic;
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
{
|
||||
var lightState = StatusLightState.Off;
|
||||
if (IsPowered(wire.Owner) && EntityManager.TryGetComponent<AirAlarmComponent>(wire.Owner, out var alarm))
|
||||
{
|
||||
lightState = alarm.CurrentMode == AirAlarmMode.Panic
|
||||
public override StatusLightState? GetLightState(Wire wire, AirAlarmComponent comp)
|
||||
=> comp.CurrentMode == AirAlarmMode.Panic
|
||||
? StatusLightState.On
|
||||
: StatusLightState.Off;
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_color,
|
||||
lightState,
|
||||
_text);
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -45,9 +28,8 @@ public sealed class AirAlarmPanicWire : BaseWireAction
|
||||
_airAlarmSystem = EntityManager.System<AirAlarmSystem>();
|
||||
}
|
||||
|
||||
public override bool Cut(EntityUid user, Wire wire)
|
||||
public override bool Cut(EntityUid user, Wire wire, AirAlarmComponent comp)
|
||||
{
|
||||
base.Cut(user, wire);
|
||||
if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet))
|
||||
{
|
||||
_airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false);
|
||||
@@ -56,28 +38,22 @@ public sealed class AirAlarmPanicWire : BaseWireAction
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire)
|
||||
public override bool Mend(EntityUid user, Wire wire, AirAlarmComponent alarm)
|
||||
{
|
||||
base.Mend(user, wire);
|
||||
if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet)
|
||||
&& EntityManager.TryGetComponent<AirAlarmComponent>(wire.Owner, out var alarm)
|
||||
&& alarm.CurrentMode == AirAlarmMode.Panic)
|
||||
{
|
||||
_airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Filtering, false, alarm);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Pulse(EntityUid user, Wire wire)
|
||||
public override void Pulse(EntityUid user, Wire wire, AirAlarmComponent comp)
|
||||
{
|
||||
base.Pulse(user, wire);
|
||||
if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet))
|
||||
{
|
||||
_airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user