fixes up air alarm modes
This commit is contained in:
@@ -98,7 +98,13 @@ namespace Content.Server.Atmos.Monitor
|
|||||||
if (!EntityManager.TryGetComponent(uid, out AirAlarmComponent? alarm))
|
if (!EntityManager.TryGetComponent(uid, out AirAlarmComponent? alarm))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var (addr, device) in alarm.DeviceData)
|
foreach (var (addr, device) in alarm.VentData)
|
||||||
|
{
|
||||||
|
device.Enabled = false;
|
||||||
|
AirAlarmSystem.SetData(uid, addr, device);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (addr, device) in alarm.ScrubberData)
|
||||||
{
|
{
|
||||||
device.Enabled = false;
|
device.Enabled = false;
|
||||||
AirAlarmSystem.SetData(uid, addr, device);
|
AirAlarmSystem.SetData(uid, addr, device);
|
||||||
@@ -113,17 +119,14 @@ namespace Content.Server.Atmos.Monitor
|
|||||||
if (!EntityManager.TryGetComponent(uid, out AirAlarmComponent? alarm))
|
if (!EntityManager.TryGetComponent(uid, out AirAlarmComponent? alarm))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var (addr, device) in alarm.DeviceData)
|
foreach (var (addr, device) in alarm.VentData)
|
||||||
{
|
{
|
||||||
switch (device)
|
AirAlarmSystem.SetData(uid, addr, GasVentPumpData.FilterModePreset);
|
||||||
{
|
}
|
||||||
case GasVentPumpData pumpData:
|
|
||||||
AirAlarmSystem.SetData(uid, addr, GasVentPumpData.FilterModePreset);
|
foreach (var (addr, device) in alarm.ScrubberData)
|
||||||
break;
|
{
|
||||||
case GasVentScrubberData scrubberData:
|
AirAlarmSystem.SetData(uid, addr, GasVentScrubberData.FilterModePreset);
|
||||||
AirAlarmSystem.SetData(uid, addr, GasVentScrubberData.FilterModePreset);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,17 +138,14 @@ namespace Content.Server.Atmos.Monitor
|
|||||||
if (!EntityManager.TryGetComponent(uid, out AirAlarmComponent? alarm))
|
if (!EntityManager.TryGetComponent(uid, out AirAlarmComponent? alarm))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var (addr, device) in alarm.DeviceData)
|
foreach (var (addr, device) in alarm.VentData)
|
||||||
{
|
{
|
||||||
switch (device)
|
AirAlarmSystem.SetData(uid, addr, GasVentPumpData.PanicModePreset);
|
||||||
{
|
}
|
||||||
case GasVentPumpData pumpData:
|
|
||||||
AirAlarmSystem.SetData(uid, addr, GasVentPumpData.PanicModePreset);
|
foreach (var (addr, device) in alarm.ScrubberData)
|
||||||
break;
|
{
|
||||||
case GasVentScrubberData scrubberData:
|
AirAlarmSystem.SetData(uid, addr, GasVentScrubberData.PanicModePreset);
|
||||||
AirAlarmSystem.SetData(uid, addr, GasVentScrubberData.PanicModePreset);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -157,81 +157,58 @@ namespace Content.Server.Atmos.Monitor
|
|||||||
if (!EntityManager.TryGetComponent(uid, out AirAlarmComponent? alarm))
|
if (!EntityManager.TryGetComponent(uid, out AirAlarmComponent? alarm))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var (addr, device) in alarm.DeviceData)
|
foreach (var (addr, device) in alarm.VentData)
|
||||||
{
|
{
|
||||||
switch (device)
|
AirAlarmSystem.SetData(uid, addr, GasVentPumpData.FillModePreset);
|
||||||
{
|
}
|
||||||
case GasVentPumpData pumpData:
|
|
||||||
AirAlarmSystem.SetData(uid, addr, GasVentPumpData.FillModePreset);
|
foreach (var (addr, device) in alarm.ScrubberData)
|
||||||
break;
|
{
|
||||||
case GasVentScrubberData scrubberData:
|
AirAlarmSystem.SetData(uid, addr, GasVentScrubberData.FillModePreset);
|
||||||
AirAlarmSystem.SetData(uid, addr, GasVentScrubberData.FillModePreset);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class AirAlarmReplaceMode : AirAlarmModeExecutor, IAirAlarmModeUpdate
|
public sealed class AirAlarmReplaceMode : AirAlarmModeExecutor, IAirAlarmModeUpdate
|
||||||
{
|
{
|
||||||
private Dictionary<string, IAtmosDeviceData> _devices = new();
|
private AirAlarmComponent? _alarm;
|
||||||
private float _lastPressure = Atmospherics.OneAtmosphere;
|
private float _lastPressure = Atmospherics.OneAtmosphere;
|
||||||
private AtmosMonitorComponent? _monitor;
|
|
||||||
private AtmosAlarmableComponent? _alarmable;
|
|
||||||
|
|
||||||
public string NetOwner { get; set; } = string.Empty;
|
public string NetOwner { get; set; } = string.Empty;
|
||||||
|
|
||||||
public override void Execute(EntityUid uid)
|
public override void Execute(EntityUid uid)
|
||||||
{
|
{
|
||||||
if (!EntityManager.TryGetComponent(uid, out AirAlarmComponent? alarm)
|
if (!EntityManager.TryGetComponent(uid, out _alarm))
|
||||||
|| !EntityManager.TryGetComponent(uid, out AtmosMonitorComponent? monitor)
|
|
||||||
|| !EntityManager.TryGetComponent(uid, out AtmosAlarmableComponent? alarmable))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_devices = alarm.DeviceData;
|
|
||||||
_monitor = monitor;
|
|
||||||
_alarmable = alarmable;
|
|
||||||
_alarmable.IgnoreAlarms = true;
|
|
||||||
SetSiphon(uid);
|
SetSiphon(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(EntityUid uid)
|
public void Update(EntityUid uid)
|
||||||
{
|
{
|
||||||
if (_monitor == null
|
if (_alarm == null)
|
||||||
|| _alarmable == null
|
|
||||||
|| _monitor.TileGas == null)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// just a little pointer
|
// just a little pointer
|
||||||
var mixture = _monitor.TileGas;
|
|
||||||
|
|
||||||
_lastPressure = mixture.Pressure;
|
_lastPressure = AirAlarmSystem.CalculatePressureAverage(_alarm);
|
||||||
if (_lastPressure <= 0.2f) // anything below and it might get stuck
|
if (_lastPressure <= 0.2f) // anything below and it might get stuck
|
||||||
{
|
{
|
||||||
_alarmable.IgnoreAlarms = false;
|
|
||||||
AirAlarmSystem.SetMode(uid, NetOwner!, AirAlarmMode.Filtering, false, false);
|
AirAlarmSystem.SetMode(uid, NetOwner!, AirAlarmMode.Filtering, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetSiphon(EntityUid uid)
|
private void SetSiphon(EntityUid uid)
|
||||||
{
|
{
|
||||||
foreach (var (addr, device) in _devices)
|
foreach (var (addr, device) in _alarm!.VentData)
|
||||||
{
|
{
|
||||||
switch (device)
|
AirAlarmSystem.SetData(uid, addr, GasVentPumpData.ReplaceModePreset);
|
||||||
{
|
}
|
||||||
case GasVentPumpData pumpData:
|
|
||||||
pumpData = GasVentPumpData.PanicModePreset;
|
foreach (var (addr, device) in _alarm!.ScrubberData)
|
||||||
pumpData.IgnoreAlarms = true;
|
{
|
||||||
AirAlarmSystem.SetData(uid, addr, pumpData);
|
AirAlarmSystem.SetData(uid, addr, GasVentScrubberData.ReplaceModePreset);
|
||||||
break;
|
|
||||||
case GasVentScrubberData scrubberData:
|
|
||||||
scrubberData = GasVentScrubberData.PanicModePreset;
|
|
||||||
scrubberData.IgnoreAlarms = true;
|
|
||||||
AirAlarmSystem.SetData(uid, addr, scrubberData);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -514,14 +514,14 @@ namespace Content.Server.Atmos.Monitor.Systems
|
|||||||
alarm.CurrentModeUpdater.Update(uid);
|
alarm.CurrentModeUpdater.Update(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float CalculatePressureAverage(AirAlarmComponent alarm)
|
public float CalculatePressureAverage(AirAlarmComponent alarm)
|
||||||
{
|
{
|
||||||
return alarm.SensorData.Count != 0
|
return alarm.SensorData.Count != 0
|
||||||
? alarm.SensorData.Values.Select(v => v.Pressure).Average()
|
? alarm.SensorData.Values.Select(v => v.Pressure).Average()
|
||||||
: 0f;
|
: 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float CalculateTemperatureAverage(AirAlarmComponent alarm)
|
public float CalculateTemperatureAverage(AirAlarmComponent alarm)
|
||||||
{
|
{
|
||||||
return alarm.SensorData.Count != 0
|
return alarm.SensorData.Count != 0
|
||||||
? alarm.SensorData.Values.Select(v => v.Temperature).Average()
|
? alarm.SensorData.Values.Select(v => v.Temperature).Average()
|
||||||
|
|||||||
@@ -44,6 +44,17 @@ namespace Content.Shared.Atmos.Piping.Unary.Components
|
|||||||
ExternalPressureBound = Atmospherics.OneAtmosphere,
|
ExternalPressureBound = Atmospherics.OneAtmosphere,
|
||||||
InternalPressureBound = 0f
|
InternalPressureBound = 0f
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static GasVentPumpData ReplaceModePreset = new GasVentPumpData
|
||||||
|
{
|
||||||
|
Enabled = false,
|
||||||
|
IgnoreAlarms = true,
|
||||||
|
Dirty = true,
|
||||||
|
PumpDirection = VentPumpDirection.Releasing,
|
||||||
|
PressureChecks = VentPressureBound.ExternalBound,
|
||||||
|
ExternalPressureBound = Atmospherics.OneAtmosphere,
|
||||||
|
InternalPressureBound = 0f
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -55,6 +55,17 @@ namespace Content.Shared.Atmos.Piping.Unary.Components
|
|||||||
VolumeRate = 200f,
|
VolumeRate = 200f,
|
||||||
WideNet = false
|
WideNet = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static GasVentScrubberData ReplaceModePreset = new GasVentScrubberData
|
||||||
|
{
|
||||||
|
Enabled = true,
|
||||||
|
IgnoreAlarms = true,
|
||||||
|
Dirty = true,
|
||||||
|
FilterGases = GasVentScrubberData.DefaultFilterGases,
|
||||||
|
PumpDirection = ScrubberPumpDirection.Siphoning,
|
||||||
|
VolumeRate = 200f,
|
||||||
|
WideNet = false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
Reference in New Issue
Block a user