AtmosAlertsComputerComponent.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. using Content.Shared.Atmos.Consoles;
  2. using Content.Shared.Atmos.Monitor;
  3. using Robust.Shared.GameStates;
  4. using Robust.Shared.Map;
  5. using Robust.Shared.Serialization;
  6. namespace Content.Shared.Atmos.Components;
  7. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  8. [Access(typeof(SharedAtmosAlertsComputerSystem))]
  9. public sealed partial class AtmosAlertsComputerComponent : Component
  10. {
  11. /// <summary>
  12. /// The current entity of interest (selected via the console UI)
  13. /// </summary>
  14. [ViewVariables]
  15. public NetEntity? FocusDevice;
  16. /// <summary>
  17. /// A list of all the atmos devices that will be used to populate the nav map
  18. /// </summary>
  19. [ViewVariables, AutoNetworkedField]
  20. public HashSet<AtmosAlertsDeviceNavMapData> AtmosDevices = new();
  21. /// <summary>
  22. /// A list of all the air alarms that have had their alerts silenced on this particular console
  23. /// </summary>
  24. [ViewVariables, AutoNetworkedField]
  25. public HashSet<NetEntity> SilencedDevices = new();
  26. }
  27. [Serializable, NetSerializable]
  28. public struct AtmosAlertsDeviceNavMapData
  29. {
  30. /// <summary>
  31. /// The entity in question
  32. /// </summary>
  33. public NetEntity NetEntity;
  34. /// <summary>
  35. /// Location of the entity
  36. /// </summary>
  37. public NetCoordinates NetCoordinates;
  38. /// <summary>
  39. /// Used to determine what map icons to use
  40. /// </summary>
  41. public AtmosAlertsComputerGroup Group;
  42. /// <summary>
  43. /// Populate the atmos monitoring console nav map with a single entity
  44. /// </summary>
  45. public AtmosAlertsDeviceNavMapData(NetEntity netEntity, NetCoordinates netCoordinates, AtmosAlertsComputerGroup group)
  46. {
  47. NetEntity = netEntity;
  48. NetCoordinates = netCoordinates;
  49. Group = group;
  50. }
  51. }
  52. [Serializable, NetSerializable]
  53. public struct AtmosAlertsFocusDeviceData
  54. {
  55. /// <summary>
  56. /// Focus entity
  57. /// </summary>
  58. public NetEntity NetEntity;
  59. /// <summary>
  60. /// Temperature (K) and related alert state
  61. /// </summary>
  62. public (float, AtmosAlarmType) TemperatureData;
  63. /// <summary>
  64. /// Pressure (kPA) and related alert state
  65. /// </summary>
  66. public (float, AtmosAlarmType) PressureData;
  67. /// <summary>
  68. /// Moles, percentage, and related alert state, for all detected gases
  69. /// </summary>
  70. public Dictionary<Gas, (float, float, AtmosAlarmType)> GasData;
  71. /// <summary>
  72. /// Populates the atmos monitoring console focus entry with atmospheric data
  73. /// </summary>
  74. public AtmosAlertsFocusDeviceData
  75. (NetEntity netEntity,
  76. (float, AtmosAlarmType) temperatureData,
  77. (float, AtmosAlarmType) pressureData,
  78. Dictionary<Gas, (float, float, AtmosAlarmType)> gasData)
  79. {
  80. NetEntity = netEntity;
  81. TemperatureData = temperatureData;
  82. PressureData = pressureData;
  83. GasData = gasData;
  84. }
  85. }
  86. [Serializable, NetSerializable]
  87. public sealed class AtmosAlertsComputerBoundInterfaceState : BoundUserInterfaceState
  88. {
  89. /// <summary>
  90. /// A list of all air alarms
  91. /// </summary>
  92. public AtmosAlertsComputerEntry[] AirAlarms;
  93. /// <summary>
  94. /// A list of all fire alarms
  95. /// </summary>
  96. public AtmosAlertsComputerEntry[] FireAlarms;
  97. /// <summary>
  98. /// Data for the UI focus (if applicable)
  99. /// </summary>
  100. public AtmosAlertsFocusDeviceData? FocusData;
  101. /// <summary>
  102. /// Sends data from the server to the client to populate the atmos monitoring console UI
  103. /// </summary>
  104. public AtmosAlertsComputerBoundInterfaceState(AtmosAlertsComputerEntry[] airAlarms, AtmosAlertsComputerEntry[] fireAlarms, AtmosAlertsFocusDeviceData? focusData)
  105. {
  106. AirAlarms = airAlarms;
  107. FireAlarms = fireAlarms;
  108. FocusData = focusData;
  109. }
  110. }
  111. [Serializable, NetSerializable]
  112. public struct AtmosAlertsComputerEntry
  113. {
  114. /// <summary>
  115. /// The entity in question
  116. /// </summary>
  117. public NetEntity NetEntity;
  118. /// <summary>
  119. /// Location of the entity
  120. /// </summary>
  121. public NetCoordinates Coordinates;
  122. /// <summary>
  123. /// The type of entity
  124. /// </summary>
  125. public AtmosAlertsComputerGroup Group;
  126. /// <summary>
  127. /// Current alarm state
  128. /// </summary>
  129. public AtmosAlarmType AlarmState;
  130. /// <summary>
  131. /// Localised device name
  132. /// </summary>
  133. public string EntityName;
  134. /// <summary>
  135. /// Device network address
  136. /// </summary>
  137. public string Address;
  138. /// <summary>
  139. /// Used to populate the atmos monitoring console UI with data from a single air alarm
  140. /// </summary>
  141. public AtmosAlertsComputerEntry
  142. (NetEntity entity,
  143. NetCoordinates coordinates,
  144. AtmosAlertsComputerGroup group,
  145. AtmosAlarmType alarmState,
  146. string entityName,
  147. string address)
  148. {
  149. NetEntity = entity;
  150. Coordinates = coordinates;
  151. Group = group;
  152. AlarmState = alarmState;
  153. EntityName = entityName;
  154. Address = address;
  155. }
  156. }
  157. [Serializable, NetSerializable]
  158. public sealed class AtmosAlertsComputerFocusChangeMessage : BoundUserInterfaceMessage
  159. {
  160. public NetEntity? FocusDevice;
  161. /// <summary>
  162. /// Used to inform the server that the specified focus for the atmos monitoring console has been changed by the client
  163. /// </summary>
  164. public AtmosAlertsComputerFocusChangeMessage(NetEntity? focusDevice)
  165. {
  166. FocusDevice = focusDevice;
  167. }
  168. }
  169. [Serializable, NetSerializable]
  170. public sealed class AtmosAlertsComputerDeviceSilencedMessage : BoundUserInterfaceMessage
  171. {
  172. public NetEntity AtmosDevice;
  173. public bool SilenceDevice = true;
  174. /// <summary>
  175. /// Used to inform the server that the client has silenced alerts from the specified device to this atmos monitoring console
  176. /// </summary>
  177. public AtmosAlertsComputerDeviceSilencedMessage(NetEntity atmosDevice, bool silenceDevice = true)
  178. {
  179. AtmosDevice = atmosDevice;
  180. SilenceDevice = silenceDevice;
  181. }
  182. }
  183. /// <summary>
  184. /// List of all the different atmos device groups
  185. /// </summary>
  186. public enum AtmosAlertsComputerGroup
  187. {
  188. Invalid,
  189. AirAlarm,
  190. FireAlarm,
  191. }
  192. [NetSerializable, Serializable]
  193. public enum AtmosAlertsComputerVisuals
  194. {
  195. ComputerLayerScreen,
  196. }
  197. /// <summary>
  198. /// UI key associated with the atmos monitoring console
  199. /// </summary>
  200. [Serializable, NetSerializable]
  201. public enum AtmosAlertsComputerUiKey
  202. {
  203. Key
  204. }