sync alarms, reset all, etc

This commit is contained in:
vulppine
2022-08-22 04:21:20 -07:00
parent 14669f1521
commit 550ea771a7
4 changed files with 56 additions and 74 deletions

View File

@@ -28,13 +28,10 @@ namespace Content.Server.Atmos.Monitor.Components
public sealed class AtmosAlarmableComponent : Component
{
[ViewVariables]
public List<EntityUid> LinkedMonitors { get; set; } = new();
[ViewVariables]
public Dictionary<string, AtmosMonitorAlarmType> NetworkAlarmStates = new();
public readonly Dictionary<string, AtmosMonitorAlarmType> NetworkAlarmStates = new();
[ViewVariables] public AtmosMonitorAlarmType LastAlarmState = AtmosMonitorAlarmType.Normal;
[ViewVariables] public AtmosMonitorAlarmType HighestNetworkState = AtmosMonitorAlarmType.Normal;
[ViewVariables] public bool IgnoreAlarms { get; set; } = false;
[DataField("alarmSound")]
@@ -44,11 +41,19 @@ namespace Content.Server.Atmos.Monitor.Components
public float AlarmVolume { get; set; } = -10;
/// <summary>
/// List of prototypes that this alarmable can be
/// alarmed by - must be a prototype with AtmosMonitor
/// attached to it
/// List of prototypes that this alarmable can
/// sync with - this is so that you can sync without
/// having to worry about cross-contamination.
/// </summary>
[DataField("alarmedBy")]
public List<string> AlarmedByPrototypes { get; } = new();
[DataField("syncWith")]
public List<string> SyncWithPrototypes { get; } = new();
/// <summary>
/// If this device should receive only. If it can only
/// receive, that means that attempting to sync outwards
/// will result in nothing happening.
/// </summary>
[DataField("receiveOnly")]
public bool ReceiveOnly { get; }
}
}

View File

@@ -22,11 +22,6 @@ namespace Content.Server.Atmos.Monitor.Components
[ViewVariables]
public bool NetEnabled = true;
// Entities that the monitor will alarm. Stores only EntityUids, is populated
// when this component starts up.
[ViewVariables]
public List<EntityUid> LinkedEntities = new();
[DataField("temperatureThreshold", customTypeSerializer: (typeof(PrototypeIdSerializer<AtmosAlarmThreshold>)))]
public readonly string? TemperatureThresholdId;
@@ -64,34 +59,10 @@ namespace Content.Server.Atmos.Monitor.Components
[ViewVariables]
public AtmosMonitorAlarmType LastAlarmState = AtmosMonitorAlarmType.Normal;
// feeling real dirty about this one
// Caches the alarm states it recieves from the rest of the network.
// This is so that the highest alarm in the network can be calculated
// from any monitor without having to reping every alarm.
[ViewVariables]
public Dictionary<string, AtmosMonitorAlarmType> NetworkAlarmStates = new();
/// <summary>
/// Registered devices in this atmos monitor. Alerts will be sent directly
/// to these devices.
/// </summary>
[ViewVariables] public HashSet<string> RegisteredDevices = new();
// Calculates the highest alarm in the network, including itself.
[ViewVariables]
public AtmosMonitorAlarmType HighestAlarmInNetwork
{
get
{
var state = AtmosMonitorAlarmType.Normal;
foreach (var (_, netState) in NetworkAlarmStates)
if (state < netState)
state = netState;
if (LastAlarmState > state) state = LastAlarmState;
return state;
}
}
}
}