Add copy threshold button to air alarms (#34346)
This commit is contained in:
@@ -33,10 +33,11 @@ public sealed class AtmosMonitorSystem : EntitySystem
|
||||
|
||||
// Commands
|
||||
public const string AtmosMonitorSetThresholdCmd = "atmos_monitor_set_threshold";
|
||||
public const string AtmosMonitorSetAllThresholdsCmd = "atmos_monitor_set_all_thresholds";
|
||||
|
||||
// Packet data
|
||||
public const string AtmosMonitorThresholdData = "atmos_monitor_threshold_data";
|
||||
|
||||
public const string AtmosMonitorAllThresholdData = "atmos_monitor_all_threshold_data";
|
||||
public const string AtmosMonitorThresholdDataType = "atmos_monitor_threshold_type";
|
||||
|
||||
public const string AtmosMonitorThresholdGasType = "atmos_monitor_threshold_gas";
|
||||
@@ -138,7 +139,12 @@ public sealed class AtmosMonitorSystem : EntitySystem
|
||||
args.Data.TryGetValue(AtmosMonitorThresholdGasType, out Gas? gas);
|
||||
SetThreshold(uid, thresholdType.Value, thresholdData, gas);
|
||||
}
|
||||
|
||||
break;
|
||||
case AtmosMonitorSetAllThresholdsCmd:
|
||||
if (args.Data.TryGetValue(AtmosMonitorAllThresholdData, out AtmosSensorData? allThresholdData))
|
||||
{
|
||||
SetAllThresholds(uid, allThresholdData);
|
||||
}
|
||||
break;
|
||||
case AtmosDeviceNetworkSystem.SyncData:
|
||||
var payload = new NetworkPayload();
|
||||
@@ -403,4 +409,20 @@ public sealed class AtmosMonitorSystem : EntitySystem
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets all of a monitor's thresholds at once according to the incoming
|
||||
/// AtmosSensorData object's thresholds.
|
||||
/// </summary>
|
||||
/// <param name="uid">The entity's uid</param>
|
||||
/// <param name="allThresholdData">An AtmosSensorData object from which the thresholds will be loaded.</param>
|
||||
public void SetAllThresholds(EntityUid uid, AtmosSensorData allThresholdData)
|
||||
{
|
||||
SetThreshold(uid, AtmosMonitorThresholdType.Temperature, allThresholdData.TemperatureThreshold);
|
||||
SetThreshold(uid, AtmosMonitorThresholdType.Pressure, allThresholdData.PressureThreshold);
|
||||
foreach (var gas in Enum.GetValues<Gas>())
|
||||
{
|
||||
SetThreshold(uid, AtmosMonitorThresholdType.Gas, allThresholdData.GasThresholds[gas], gas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user