Air alarm fixes (again, oops) (#7715)
* fixes critical issue * alright, this might be the actual fix * removes useless null checks * couple more * removes default functions from unary device data
This commit is contained in:
@@ -111,8 +111,6 @@ namespace Content.Client.Atmos.Monitor.UI
|
||||
switch (device)
|
||||
{
|
||||
case GasVentPumpData pump:
|
||||
if (!pump.Dirty) pump = GasVentPumpData.Default();
|
||||
|
||||
if (!_pumps.TryGetValue(addr, out var pumpControl))
|
||||
{
|
||||
var control= new PumpControl(pump, addr);
|
||||
@@ -127,8 +125,6 @@ namespace Content.Client.Atmos.Monitor.UI
|
||||
|
||||
break;
|
||||
case GasVentScrubberData scrubber:
|
||||
if (!scrubber.Dirty) scrubber = GasVentScrubberData.Default();
|
||||
|
||||
if (!_scrubbers.TryGetValue(addr, out var scrubberControl))
|
||||
{
|
||||
var control = new ScrubberControl(scrubber, addr);
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Content.Client.Atmos.Monitor.UI.Widgets
|
||||
PumpDataChanged?.Invoke(_address, _data);
|
||||
};
|
||||
|
||||
_internalBound.Value = (float) _data.InternalPressureBound!;
|
||||
_internalBound.Value = (float) _data.InternalPressureBound;
|
||||
_internalBound.OnValueChanged += _ =>
|
||||
{
|
||||
_data.InternalPressureBound = _internalBound.Value;
|
||||
@@ -51,7 +51,7 @@ namespace Content.Client.Atmos.Monitor.UI.Widgets
|
||||
};
|
||||
_internalBound.IsValid += value => value >= 0;
|
||||
|
||||
_externalBound.Value = (float) _data.ExternalPressureBound!;
|
||||
_externalBound.Value = (float) _data.ExternalPressureBound;
|
||||
_externalBound.OnValueChanged += _ =>
|
||||
{
|
||||
_data.ExternalPressureBound = _externalBound.Value;
|
||||
@@ -62,7 +62,7 @@ namespace Content.Client.Atmos.Monitor.UI.Widgets
|
||||
foreach (var value in Enum.GetValues<VentPumpDirection>())
|
||||
_pumpDirection.AddItem(Loc.GetString($"{value}"), (int) value);
|
||||
|
||||
_pumpDirection.SelectId((int) _data.PumpDirection!);
|
||||
_pumpDirection.SelectId((int) _data.PumpDirection);
|
||||
_pumpDirection.OnItemSelected += args =>
|
||||
{
|
||||
_pumpDirection.SelectId(args.Id);
|
||||
@@ -73,7 +73,7 @@ namespace Content.Client.Atmos.Monitor.UI.Widgets
|
||||
foreach (var value in Enum.GetValues<VentPressureBound>())
|
||||
_pressureCheck.AddItem(Loc.GetString($"{value}"), (int) value);
|
||||
|
||||
_pressureCheck.SelectId((int) _data.PressureChecks!);
|
||||
_pressureCheck.SelectId((int) _data.PressureChecks);
|
||||
_pressureCheck.OnItemSelected += args =>
|
||||
{
|
||||
_pressureCheck.SelectId(args.Id);
|
||||
@@ -85,19 +85,19 @@ namespace Content.Client.Atmos.Monitor.UI.Widgets
|
||||
public void ChangeData(GasVentPumpData data)
|
||||
{
|
||||
_data.Enabled = data.Enabled;
|
||||
_enabled.Pressed = _data.Enabled!;
|
||||
_enabled.Pressed = _data.Enabled;
|
||||
|
||||
_data.PumpDirection = data.PumpDirection;
|
||||
_pumpDirection.SelectId((int) _data.PumpDirection!);
|
||||
_pumpDirection.SelectId((int) _data.PumpDirection);
|
||||
|
||||
_data.PressureChecks = data.PressureChecks;
|
||||
_pressureCheck.SelectId((int) _data.PressureChecks!);
|
||||
_pressureCheck.SelectId((int) _data.PressureChecks);
|
||||
|
||||
_data.ExternalPressureBound = data.ExternalPressureBound;
|
||||
_externalBound.Value = (float) _data.ExternalPressureBound!;
|
||||
_externalBound.Value = _data.ExternalPressureBound;
|
||||
|
||||
_data.InternalPressureBound = data.InternalPressureBound;
|
||||
_internalBound.Value = (float) _data.InternalPressureBound!;
|
||||
_internalBound.Value = _data.InternalPressureBound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Content.Client.Atmos.Monitor.UI.Widgets
|
||||
ScrubberDataChanged?.Invoke(_address, _data);
|
||||
};
|
||||
|
||||
_volumeRate.Value = (float) _data.VolumeRate!;
|
||||
_volumeRate.Value = _data.VolumeRate;
|
||||
_volumeRate.OnValueChanged += _ =>
|
||||
{
|
||||
_data.VolumeRate = _volumeRate.Value;
|
||||
@@ -66,7 +66,7 @@ namespace Content.Client.Atmos.Monitor.UI.Widgets
|
||||
foreach (var value in Enum.GetValues<ScrubberPumpDirection>())
|
||||
_pumpDirection.AddItem(Loc.GetString($"{value}"), (int) value);
|
||||
|
||||
_pumpDirection.SelectId((int) _data.PumpDirection!);
|
||||
_pumpDirection.SelectId((int) _data.PumpDirection);
|
||||
_pumpDirection.OnItemSelected += args =>
|
||||
{
|
||||
_pumpDirection.SelectId(args.Id);
|
||||
@@ -82,7 +82,7 @@ namespace Content.Client.Atmos.Monitor.UI.Widgets
|
||||
Text = Loc.GetString($"{value}"),
|
||||
ToggleMode = true,
|
||||
HorizontalExpand = true,
|
||||
Pressed = _data.FilterGases!.Contains(value)
|
||||
Pressed = _data.FilterGases.Contains(value)
|
||||
};
|
||||
gasButton.OnToggled += args =>
|
||||
{
|
||||
@@ -105,15 +105,15 @@ namespace Content.Client.Atmos.Monitor.UI.Widgets
|
||||
_enabled.Pressed = _data.Enabled;
|
||||
|
||||
_data.PumpDirection = data.PumpDirection;
|
||||
_pumpDirection.SelectId((int) _data.PumpDirection!);
|
||||
_pumpDirection.Select((int) _data.PumpDirection);
|
||||
|
||||
_data.VolumeRate = data.VolumeRate;
|
||||
_volumeRate.Value = (float) _data.VolumeRate!;
|
||||
_volumeRate.Value = _data.VolumeRate;
|
||||
|
||||
_data.WideNet = data.WideNet;
|
||||
_wideNet.Pressed = _data.WideNet;
|
||||
|
||||
var intersect = _data.FilterGases!.Intersect(data.FilterGases!);
|
||||
var intersect = _data.FilterGases.Intersect(data.FilterGases);
|
||||
|
||||
foreach (var value in Enum.GetValues<Gas>())
|
||||
if (!intersect.Contains(value))
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Content.Server.Atmos.Monitor.Components
|
||||
|
||||
private AirAlarmSystem? _airAlarmSystem;
|
||||
|
||||
[ViewVariables] public AirAlarmMode CurrentMode { get; set; }
|
||||
[ViewVariables] public AirAlarmMode CurrentMode { get; set; } = AirAlarmMode.Filtering;
|
||||
|
||||
// Remember to null this afterwards.
|
||||
[ViewVariables] public IAirAlarmModeUpdate? CurrentModeUpdater { get; set; }
|
||||
|
||||
@@ -74,8 +74,6 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
||||
|
||||
public GasVentPumpData ToAirAlarmData()
|
||||
{
|
||||
if (!IsDirty) return new GasVentPumpData { Dirty = IsDirty };
|
||||
|
||||
return new GasVentPumpData
|
||||
{
|
||||
Enabled = Enabled,
|
||||
@@ -91,10 +89,10 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
||||
{
|
||||
Enabled = data.Enabled;
|
||||
IsDirty = data.Dirty;
|
||||
PumpDirection = (VentPumpDirection) data.PumpDirection!;
|
||||
PressureChecks = (VentPressureBound) data.PressureChecks!;
|
||||
ExternalPressureBound = (float) data.ExternalPressureBound!;
|
||||
InternalPressureBound = (float) data.InternalPressureBound!;
|
||||
PumpDirection = data.PumpDirection;
|
||||
PressureChecks = data.PressureChecks;
|
||||
ExternalPressureBound = data.ExternalPressureBound;
|
||||
InternalPressureBound = data.InternalPressureBound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,8 +56,6 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
||||
|
||||
public GasVentScrubberData ToAirAlarmData()
|
||||
{
|
||||
if (!IsDirty) return new GasVentScrubberData { Dirty = IsDirty };
|
||||
|
||||
return new GasVentScrubberData
|
||||
{
|
||||
Enabled = Enabled,
|
||||
@@ -73,11 +71,11 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
||||
{
|
||||
Enabled = data.Enabled;
|
||||
IsDirty = data.Dirty;
|
||||
PumpDirection = (ScrubberPumpDirection) data.PumpDirection!;
|
||||
TransferRate = (float) data.VolumeRate!;
|
||||
PumpDirection = data.PumpDirection;
|
||||
TransferRate = data.VolumeRate;
|
||||
WideNet = data.WideNet;
|
||||
|
||||
if (!data.FilterGases!.SequenceEqual(FilterGases))
|
||||
if (!data.FilterGases.SequenceEqual(FilterGases))
|
||||
{
|
||||
FilterGases.Clear();
|
||||
foreach (var gas in data.FilterGases!)
|
||||
|
||||
@@ -10,10 +10,10 @@ namespace Content.Shared.Atmos.Piping.Unary.Components
|
||||
public bool Enabled { get; set; }
|
||||
public bool Dirty { get; set; }
|
||||
public bool IgnoreAlarms { get; set; } = false;
|
||||
public VentPumpDirection? PumpDirection { get; set; }
|
||||
public VentPressureBound? PressureChecks { get; set; }
|
||||
public float? ExternalPressureBound { get; set; }
|
||||
public float? InternalPressureBound { get; set; }
|
||||
public VentPumpDirection PumpDirection { get; set; } = VentPumpDirection.Releasing;
|
||||
public VentPressureBound PressureChecks { get; set; } = VentPressureBound.ExternalBound;
|
||||
public float ExternalPressureBound { get; set; } = Atmospherics.OneAtmosphere;
|
||||
public float InternalPressureBound { get; set; } = 0f;
|
||||
|
||||
// Presets for 'dumb' air alarm modes
|
||||
|
||||
@@ -45,18 +45,6 @@ namespace Content.Shared.Atmos.Piping.Unary.Components
|
||||
ExternalPressureBound = Atmospherics.OneAtmosphere,
|
||||
InternalPressureBound = 0f
|
||||
};
|
||||
|
||||
public static GasVentPumpData Default()
|
||||
{
|
||||
return new GasVentPumpData
|
||||
{
|
||||
Enabled = true,
|
||||
PumpDirection = VentPumpDirection.Releasing,
|
||||
PressureChecks = VentPressureBound.ExternalBound,
|
||||
ExternalPressureBound = Atmospherics.OneAtmosphere,
|
||||
InternalPressureBound = 0f
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
@@ -11,10 +11,10 @@ namespace Content.Shared.Atmos.Piping.Unary.Components
|
||||
public bool Enabled { get; set; }
|
||||
public bool Dirty { get; set; }
|
||||
public bool IgnoreAlarms { get; set; } = false;
|
||||
public HashSet<Gas>? FilterGases { get; set; }
|
||||
public ScrubberPumpDirection? PumpDirection { get; set; }
|
||||
public float? VolumeRate { get; set; }
|
||||
public bool WideNet { get; set; }
|
||||
public HashSet<Gas> FilterGases { get; set; } = new(DefaultFilterGases);
|
||||
public ScrubberPumpDirection PumpDirection { get; set; } = ScrubberPumpDirection.Scrubbing;
|
||||
public float VolumeRate { get; set; } = 200f;
|
||||
public bool WideNet { get; set; } = false;
|
||||
|
||||
public static HashSet<Gas> DefaultFilterGases = new()
|
||||
{
|
||||
@@ -54,18 +54,6 @@ namespace Content.Shared.Atmos.Piping.Unary.Components
|
||||
VolumeRate = 200f,
|
||||
WideNet = false
|
||||
};
|
||||
|
||||
public static GasVentScrubberData Default()
|
||||
{
|
||||
return new GasVentScrubberData
|
||||
{
|
||||
Enabled = true,
|
||||
FilterGases = GasVentScrubberData.DefaultFilterGases,
|
||||
PumpDirection = ScrubberPumpDirection.Scrubbing,
|
||||
VolumeRate = 200f,
|
||||
WideNet = false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
Reference in New Issue
Block a user