AtmosAlarmableComponent.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using Content.Shared.Atmos.Monitor;
  2. using Content.Shared.Tag;
  3. using Robust.Shared.Audio;
  4. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
  5. namespace Content.Server.Atmos.Monitor.Components;
  6. // AtmosAlarmables are entities that can be alarmed
  7. // by a linked AtmosMonitor (alarmer?) if a threshold
  8. // is passed in some way. The intended use is to
  9. // do something in case something dangerous happens,
  10. // e.g., activate firelocks in case a temperature
  11. // threshold is reached
  12. //
  13. // It goes:
  14. //
  15. // AtmosMonitor -> AtmosDeviceUpdateEvent
  16. // -> Threshold calculation
  17. // -> AtmosAlarmEvent
  18. // -> Everything linked to that monitor (targetted)
  19. /// <summary>
  20. /// A component to add to device network devices if you want them to be alarmed
  21. /// by an atmospheric alarmer. This will store every single alert received, and
  22. /// calculate the highest alert based on the alerts received. Equally, if you
  23. /// link other alarmables to this, it will store the alerts from them to
  24. /// calculate the highest network alert.
  25. /// </summary>
  26. [RegisterComponent]
  27. public sealed partial class AtmosAlarmableComponent : Component
  28. {
  29. [ViewVariables]
  30. public readonly Dictionary<string, AtmosAlarmType> NetworkAlarmStates = new();
  31. [ViewVariables] public AtmosAlarmType LastAlarmState = AtmosAlarmType.Invalid;
  32. [ViewVariables] public bool IgnoreAlarms { get; set; } = false;
  33. [DataField("alarmSound")]
  34. public SoundSpecifier AlarmSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/alarm.ogg");
  35. [DataField("alarmVolume")]
  36. public float AlarmVolume { get; set; } = -10;
  37. /// <summary>
  38. /// List of tags to check for when synchronizing alarms.
  39. /// </summary>
  40. [DataField("syncWith", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<TagPrototype>))]
  41. public HashSet<string> SyncWithTags { get; private set; } = new();
  42. [DataField("monitorAlertTypes")]
  43. public HashSet<AtmosMonitorThresholdType>? MonitorAlertTypes { get; private set; }
  44. /// <summary>
  45. /// If this device should receive only. If it can only
  46. /// receive, that means that attempting to sync outwards
  47. /// will result in nothing happening.
  48. /// </summary>
  49. [DataField("receiveOnly")]
  50. public bool ReceiveOnly { get; private set; }
  51. }