AtmosAlarmableAlarmWire.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Content.Server.Atmos.Monitor.Components;
  2. using Content.Server.Atmos.Monitor.Systems;
  3. using Content.Server.Wires;
  4. using Content.Shared.Atmos.Monitor;
  5. using Content.Shared.Wires;
  6. namespace Content.Server.Atmos.Monitor;
  7. public sealed partial class AtmosMonitorDeviceNetWire : ComponentWireAction<AtmosAlarmableComponent>
  8. {
  9. // whether or not this wire will send out an alarm upon
  10. // being pulsed
  11. [DataField("alarmOnPulse")]
  12. private bool _alarmOnPulse = false;
  13. public override string Name { get; set; } = "wire-name-device-net";
  14. public override Color Color { get; set; } = Color.Orange;
  15. private AtmosAlarmableSystem _atmosAlarmableSystem = default!;
  16. public override object StatusKey { get; } = AtmosMonitorAlarmWireActionKeys.Network;
  17. public override StatusLightState? GetLightState(Wire wire, AtmosAlarmableComponent comp)
  18. {
  19. if (!_atmosAlarmableSystem.TryGetHighestAlert(wire.Owner, out var alarm, comp))
  20. {
  21. alarm = AtmosAlarmType.Normal;
  22. }
  23. return alarm == AtmosAlarmType.Danger
  24. ? StatusLightState.BlinkingFast
  25. : StatusLightState.On;
  26. }
  27. public override void Initialize()
  28. {
  29. base.Initialize();
  30. _atmosAlarmableSystem = EntityManager.System<AtmosAlarmableSystem>();
  31. }
  32. public override bool Cut(EntityUid user, Wire wire, AtmosAlarmableComponent comp)
  33. {
  34. comp.IgnoreAlarms = true;
  35. return true;
  36. }
  37. public override bool Mend(EntityUid user, Wire wire, AtmosAlarmableComponent comp)
  38. {
  39. comp.IgnoreAlarms = false;
  40. return true;
  41. }
  42. public override void Pulse(EntityUid user, Wire wire, AtmosAlarmableComponent comp)
  43. {
  44. if (_alarmOnPulse)
  45. _atmosAlarmableSystem.ForceAlert(wire.Owner, AtmosAlarmType.Danger, comp);
  46. }
  47. }