number of things, fixing warnings, AtmosAlarmType instead of AtmosMonitorAlarmType

This commit is contained in:
vulppine
2022-08-29 07:37:26 -07:00
parent cb5ffe0f3d
commit e0bf77490d
24 changed files with 177 additions and 148 deletions

View File

@@ -9,11 +9,11 @@ namespace Content.Shared.Atmos.Monitor;
[Serializable, NetSerializable]
public sealed class AtmosAlarmThreshold : IPrototype, ISerializationHooks
{
[IdDataFieldAttribute]
[IdDataField]
public string ID { get; } = default!;
[ViewVariables]
[DataField("ignore")]
public bool Ignore = false;
public bool Ignore;
// zero bounds are not allowed - just
// set the bound to null if you want
@@ -41,19 +41,14 @@ public sealed class AtmosAlarmThreshold : IPrototype, ISerializationHooks
public float? LowerWarningPercentage { get; private set; }
[ViewVariables]
public float? UpperWarningBound
{
get => CalculateWarningBound(AtmosMonitorThresholdBound.Upper);
}
public float? UpperWarningBound => CalculateWarningBound(AtmosMonitorThresholdBound.Upper);
[ViewVariables]
public float? LowerWarningBound
{
get => CalculateWarningBound(AtmosMonitorThresholdBound.Lower);
}
public float? LowerWarningBound => CalculateWarningBound(AtmosMonitorThresholdBound.Lower);
public AtmosAlarmThreshold()
{}
{
}
public AtmosAlarmThreshold(AtmosAlarmThreshold other)
{
@@ -80,19 +75,22 @@ public sealed class AtmosAlarmThreshold : IPrototype, ISerializationHooks
}
// utility function to check a threshold against some calculated value
public bool CheckThreshold(float value, out AtmosMonitorAlarmType state)
public bool CheckThreshold(float value, out AtmosAlarmType state)
{
state = AtmosMonitorAlarmType.Normal;
if (Ignore) return false;
state = AtmosAlarmType.Normal;
if (Ignore)
{
return false;
}
if (value >= UpperBound || value <= LowerBound)
{
state = AtmosMonitorAlarmType.Danger;
state = AtmosAlarmType.Danger;
return true;
}
if (value >= UpperWarningBound || value <= LowerWarningBound)
{
state = AtmosMonitorAlarmType.Warning;
state = AtmosAlarmType.Warning;
return true;
}
@@ -117,7 +115,7 @@ public sealed class AtmosAlarmThreshold : IPrototype, ISerializationHooks
return true;
}
float value = (float) input;
var value = (float) input;
if (value <= 0f || float.IsNaN(value))
return false;
@@ -141,7 +139,7 @@ public sealed class AtmosAlarmThreshold : IPrototype, ISerializationHooks
break;
}
bool isValid = true;
var isValid = true;
if (targetValue != null)
{
var result = targetValue.Value.target.CompareTo(value);
@@ -191,8 +189,8 @@ public sealed class AtmosAlarmThreshold : IPrototype, ISerializationHooks
if (UpperBound == null)
return false;
float upperWarning = (float) (input / UpperBound);
float upperTestValue = (upperWarning * (float) UpperBound);
var upperWarning = (float) (input / UpperBound);
var upperTestValue = upperWarning * (float) UpperBound;
if (upperWarning > 1f
|| upperTestValue < LowerWarningBound
@@ -206,8 +204,8 @@ public sealed class AtmosAlarmThreshold : IPrototype, ISerializationHooks
if (LowerBound == null)
return false;
float lowerWarning = (float) (input / LowerBound);
float testValue = (lowerWarning * (float) LowerBound);
var lowerWarning = (float) (input / LowerBound);
var testValue = lowerWarning * (float) LowerBound;
if (lowerWarning < 1f
|| testValue > UpperWarningBound
@@ -265,6 +263,5 @@ public enum AtmosMonitorThresholdType
[Serializable, NetSerializable]
public enum AtmosMonitorVisuals : byte
{
Offset,
AlarmType,
}

View File

@@ -3,10 +3,10 @@ using Robust.Shared.Serialization;
namespace Content.Shared.Atmos.Monitor;
[Serializable, NetSerializable]
public enum AtmosMonitorAlarmType : sbyte
public enum AtmosAlarmType : sbyte
{
Normal = 0,
Warning = 1,
Danger = 2, // 1 << 1 is the exact same thing and we're not really doing **bitmasking** are we?
Emagged = 3,
}
}

View File

@@ -6,7 +6,7 @@ namespace Content.Shared.Atmos.Monitor;
[Serializable, NetSerializable]
public sealed class AtmosSensorData : IAtmosDeviceData
{
public AtmosSensorData(float pressure, float temperature, float totalMoles, AtmosMonitorAlarmType alarmState, Dictionary<Gas, float> gases, AtmosAlarmThreshold pressureThreshold, AtmosAlarmThreshold temperatureThreshold, Dictionary<Gas, AtmosAlarmThreshold> gasThresholds)
public AtmosSensorData(float pressure, float temperature, float totalMoles, AtmosAlarmType alarmState, Dictionary<Gas, float> gases, AtmosAlarmThreshold pressureThreshold, AtmosAlarmThreshold temperatureThreshold, Dictionary<Gas, AtmosAlarmThreshold> gasThresholds)
{
Pressure = pressure;
Temperature = temperature;
@@ -39,7 +39,7 @@ public sealed class AtmosSensorData : IAtmosDeviceData
/// <summary>
/// Current alarm state of this sensor. Does not reflect the highest alarm state on the network.
/// </summary>
public AtmosMonitorAlarmType AlarmState { get; }
public AtmosAlarmType AlarmState { get; }
/// <summary>
/// Current number of gases on this sensor.
/// </summary>

View File

@@ -36,7 +36,7 @@ public interface IAtmosDeviceData
[Serializable, NetSerializable]
public sealed class AirAlarmUIState : BoundUserInterfaceState
{
public AirAlarmUIState(string address, int deviceCount, float pressureAverage, float temperatureAverage, Dictionary<string, IAtmosDeviceData> deviceData, AirAlarmMode mode, AirAlarmTab tab, AtmosMonitorAlarmType alarmType)
public AirAlarmUIState(string address, int deviceCount, float pressureAverage, float temperatureAverage, Dictionary<string, IAtmosDeviceData> deviceData, AirAlarmMode mode, AirAlarmTab tab, AtmosAlarmType alarmType)
{
Address = address;
DeviceCount = deviceCount;
@@ -61,7 +61,7 @@ public sealed class AirAlarmUIState : BoundUserInterfaceState
public Dictionary<string, IAtmosDeviceData> DeviceData { get; }
public AirAlarmMode Mode { get; }
public AirAlarmTab Tab { get; }
public AtmosMonitorAlarmType AlarmType { get; }
public AtmosAlarmType AlarmType { get; }
}
[Serializable, NetSerializable]

View File

@@ -1,10 +0,0 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Atmos.Monitor.Components;
[Serializable, NetSerializable]
public enum FireAlarmWireStatus
{
Power,
Alarm
}