AirAlarmPanicWire.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Content.Server.Atmos.Monitor.Components;
  2. using Content.Server.Atmos.Monitor.Systems;
  3. using Content.Server.DeviceNetwork.Components;
  4. using Content.Server.Wires;
  5. using Content.Shared.Atmos.Monitor.Components;
  6. using Content.Shared.Wires;
  7. namespace Content.Server.Atmos.Monitor;
  8. public sealed partial class AirAlarmPanicWire : ComponentWireAction<AirAlarmComponent>
  9. {
  10. public override string Name { get; set; } = "wire-name-air-alarm-panic";
  11. public override Color Color { get; set; } = Color.Red;
  12. private AirAlarmSystem _airAlarmSystem = default!;
  13. public override object StatusKey { get; } = AirAlarmWireStatus.Panic;
  14. public override StatusLightState? GetLightState(Wire wire, AirAlarmComponent comp)
  15. => comp.CurrentMode == AirAlarmMode.Panic
  16. ? StatusLightState.On
  17. : StatusLightState.Off;
  18. public override void Initialize()
  19. {
  20. base.Initialize();
  21. _airAlarmSystem = EntityManager.System<AirAlarmSystem>();
  22. }
  23. public override bool Cut(EntityUid user, Wire wire, AirAlarmComponent comp)
  24. {
  25. if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet))
  26. {
  27. _airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false);
  28. }
  29. return true;
  30. }
  31. public override bool Mend(EntityUid user, Wire wire, AirAlarmComponent alarm)
  32. {
  33. if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet)
  34. && alarm.CurrentMode == AirAlarmMode.Panic)
  35. {
  36. _airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Filtering, false, alarm);
  37. }
  38. return true;
  39. }
  40. public override void Pulse(EntityUid user, Wire wire, AirAlarmComponent comp)
  41. {
  42. if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet))
  43. {
  44. _airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false);
  45. }
  46. }
  47. }