| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- using Content.Shared.Atmos.Consoles;
- using Content.Shared.Atmos.Monitor;
- using Robust.Shared.GameStates;
- using Robust.Shared.Map;
- using Robust.Shared.Serialization;
- namespace Content.Shared.Atmos.Components;
- [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
- [Access(typeof(SharedAtmosAlertsComputerSystem))]
- public sealed partial class AtmosAlertsComputerComponent : Component
- {
- /// <summary>
- /// The current entity of interest (selected via the console UI)
- /// </summary>
- [ViewVariables]
- public NetEntity? FocusDevice;
- /// <summary>
- /// A list of all the atmos devices that will be used to populate the nav map
- /// </summary>
- [ViewVariables, AutoNetworkedField]
- public HashSet<AtmosAlertsDeviceNavMapData> AtmosDevices = new();
- /// <summary>
- /// A list of all the air alarms that have had their alerts silenced on this particular console
- /// </summary>
- [ViewVariables, AutoNetworkedField]
- public HashSet<NetEntity> SilencedDevices = new();
- }
- [Serializable, NetSerializable]
- public struct AtmosAlertsDeviceNavMapData
- {
- /// <summary>
- /// The entity in question
- /// </summary>
- public NetEntity NetEntity;
- /// <summary>
- /// Location of the entity
- /// </summary>
- public NetCoordinates NetCoordinates;
- /// <summary>
- /// Used to determine what map icons to use
- /// </summary>
- public AtmosAlertsComputerGroup Group;
- /// <summary>
- /// Populate the atmos monitoring console nav map with a single entity
- /// </summary>
- public AtmosAlertsDeviceNavMapData(NetEntity netEntity, NetCoordinates netCoordinates, AtmosAlertsComputerGroup group)
- {
- NetEntity = netEntity;
- NetCoordinates = netCoordinates;
- Group = group;
- }
- }
- [Serializable, NetSerializable]
- public struct AtmosAlertsFocusDeviceData
- {
- /// <summary>
- /// Focus entity
- /// </summary>
- public NetEntity NetEntity;
- /// <summary>
- /// Temperature (K) and related alert state
- /// </summary>
- public (float, AtmosAlarmType) TemperatureData;
- /// <summary>
- /// Pressure (kPA) and related alert state
- /// </summary>
- public (float, AtmosAlarmType) PressureData;
- /// <summary>
- /// Moles, percentage, and related alert state, for all detected gases
- /// </summary>
- public Dictionary<Gas, (float, float, AtmosAlarmType)> GasData;
- /// <summary>
- /// Populates the atmos monitoring console focus entry with atmospheric data
- /// </summary>
- public AtmosAlertsFocusDeviceData
- (NetEntity netEntity,
- (float, AtmosAlarmType) temperatureData,
- (float, AtmosAlarmType) pressureData,
- Dictionary<Gas, (float, float, AtmosAlarmType)> gasData)
- {
- NetEntity = netEntity;
- TemperatureData = temperatureData;
- PressureData = pressureData;
- GasData = gasData;
- }
- }
- [Serializable, NetSerializable]
- public sealed class AtmosAlertsComputerBoundInterfaceState : BoundUserInterfaceState
- {
- /// <summary>
- /// A list of all air alarms
- /// </summary>
- public AtmosAlertsComputerEntry[] AirAlarms;
- /// <summary>
- /// A list of all fire alarms
- /// </summary>
- public AtmosAlertsComputerEntry[] FireAlarms;
- /// <summary>
- /// Data for the UI focus (if applicable)
- /// </summary>
- public AtmosAlertsFocusDeviceData? FocusData;
- /// <summary>
- /// Sends data from the server to the client to populate the atmos monitoring console UI
- /// </summary>
- public AtmosAlertsComputerBoundInterfaceState(AtmosAlertsComputerEntry[] airAlarms, AtmosAlertsComputerEntry[] fireAlarms, AtmosAlertsFocusDeviceData? focusData)
- {
- AirAlarms = airAlarms;
- FireAlarms = fireAlarms;
- FocusData = focusData;
- }
- }
- [Serializable, NetSerializable]
- public struct AtmosAlertsComputerEntry
- {
- /// <summary>
- /// The entity in question
- /// </summary>
- public NetEntity NetEntity;
- /// <summary>
- /// Location of the entity
- /// </summary>
- public NetCoordinates Coordinates;
- /// <summary>
- /// The type of entity
- /// </summary>
- public AtmosAlertsComputerGroup Group;
- /// <summary>
- /// Current alarm state
- /// </summary>
- public AtmosAlarmType AlarmState;
- /// <summary>
- /// Localised device name
- /// </summary>
- public string EntityName;
- /// <summary>
- /// Device network address
- /// </summary>
- public string Address;
- /// <summary>
- /// Used to populate the atmos monitoring console UI with data from a single air alarm
- /// </summary>
- public AtmosAlertsComputerEntry
- (NetEntity entity,
- NetCoordinates coordinates,
- AtmosAlertsComputerGroup group,
- AtmosAlarmType alarmState,
- string entityName,
- string address)
- {
- NetEntity = entity;
- Coordinates = coordinates;
- Group = group;
- AlarmState = alarmState;
- EntityName = entityName;
- Address = address;
- }
- }
- [Serializable, NetSerializable]
- public sealed class AtmosAlertsComputerFocusChangeMessage : BoundUserInterfaceMessage
- {
- public NetEntity? FocusDevice;
- /// <summary>
- /// Used to inform the server that the specified focus for the atmos monitoring console has been changed by the client
- /// </summary>
- public AtmosAlertsComputerFocusChangeMessage(NetEntity? focusDevice)
- {
- FocusDevice = focusDevice;
- }
- }
- [Serializable, NetSerializable]
- public sealed class AtmosAlertsComputerDeviceSilencedMessage : BoundUserInterfaceMessage
- {
- public NetEntity AtmosDevice;
- public bool SilenceDevice = true;
- /// <summary>
- /// Used to inform the server that the client has silenced alerts from the specified device to this atmos monitoring console
- /// </summary>
- public AtmosAlertsComputerDeviceSilencedMessage(NetEntity atmosDevice, bool silenceDevice = true)
- {
- AtmosDevice = atmosDevice;
- SilenceDevice = silenceDevice;
- }
- }
- /// <summary>
- /// List of all the different atmos device groups
- /// </summary>
- public enum AtmosAlertsComputerGroup
- {
- Invalid,
- AirAlarm,
- FireAlarm,
- }
- [NetSerializable, Serializable]
- public enum AtmosAlertsComputerVisuals
- {
- ComputerLayerScreen,
- }
- /// <summary>
- /// UI key associated with the atmos monitoring console
- /// </summary>
- [Serializable, NetSerializable]
- public enum AtmosAlertsComputerUiKey
- {
- Key
- }
|