@@ -22,6 +22,7 @@ public sealed partial class ShipyardSystem
2222{
2323 [ Dependency ] private readonly GasMixerSystem _gasMixerSystem = default ! ;
2424 [ Dependency ] private readonly AtmosMonitorSystem _atmosMonitorSystem = default ! ;
25+ [ Dependency ] private readonly GasVentScrubberSystem _gasVentScrubberSystem = default ! ;
2526
2627 /// <summary>
2728 /// Sets up the atmosphere of a shuttle from the given prototype.
@@ -107,27 +108,31 @@ private void SetupShuttleDistroAtmosAlarms(
107108 ShuttleGridEntity shuttleGrid ,
108109 ShuttleAtmospherePrototype atmos )
109110 {
110- if ( atmos . Alarms == null )
111+ if ( atmos . Alarms == null && atmos . FilterGases == null )
112+ {
113+ // Nothing to do
111114 return ;
115+ }
112116
113- var pressureThreshold = atmos . Alarms . PressureThreshold ;
117+ // Prepare alarm thresholds, if set
118+ var pressureThreshold = atmos . Alarms ? . PressureThreshold ;
114119 AtmosAlarmThresholdPrototype ? thresholdPrototype ;
115- if ( pressureThreshold == null && _prototypeManager . TryIndex ( atmos . Alarms . PressureThresholdId , out thresholdPrototype ) )
120+ if ( pressureThreshold == null && _prototypeManager . TryIndex ( atmos . Alarms ? . PressureThresholdId , out thresholdPrototype ) )
116121 {
117122 pressureThreshold = new AtmosAlarmThreshold ( thresholdPrototype ) ;
118123 }
119124
120- var temperatureThreshold = atmos . Alarms . TemperatureThreshold ;
121- if ( temperatureThreshold == null && _prototypeManager . TryIndex ( atmos . Alarms . TemperatureThresholdId , out thresholdPrototype ) )
125+ var temperatureThreshold = atmos . Alarms ? . TemperatureThreshold ;
126+ if ( temperatureThreshold == null && _prototypeManager . TryIndex ( atmos . Alarms ? . TemperatureThresholdId , out thresholdPrototype ) )
122127 {
123128 temperatureThreshold = new AtmosAlarmThreshold ( thresholdPrototype ) ;
124129 }
125130
126- var gasThresholds = atmos . Alarms . GasThresholds ;
131+ var gasThresholds = atmos . Alarms ? . GasThresholds ;
127132 if ( gasThresholds == null )
128133 {
129134 gasThresholds = new Dictionary < Gas , AtmosAlarmThreshold > ( ) ;
130- foreach ( var ( gas , protoId ) in atmos . Alarms . GasThresholdPrototypes )
135+ foreach ( var ( gas , protoId ) in atmos . Alarms ? . GasThresholdPrototypes ?? [ ] )
131136 {
132137 if ( _prototypeManager . Resolve ( protoId , out var gasThresholdPrototype ) )
133138 {
@@ -142,11 +147,18 @@ private void SetupShuttleDistroAtmosAlarms(
142147 // settings to. We can't use this here because at this point, no game tick has happened yet, so no sensor data
143148 // is available.
144149 var enumerator = EntityQueryEnumerator < AirAlarmComponent , DeviceListComponent > ( ) ;
145- while ( enumerator . MoveNext ( out var entity , out _ , out var deviceList ) )
150+ while ( enumerator . MoveNext ( out var entity , out var alarm , out var deviceList ) )
146151 {
147152 if ( Transform ( entity ) . GridUid != shuttleGrid . Owner )
148153 continue ;
149154
155+ if ( atmos . FilterGases != null )
156+ {
157+ // Air alarms use a hard-coded gas list in automatic mode, which is very stupid and will discard our
158+ // overrides
159+ alarm . AutoMode = false ;
160+ }
161+
150162 foreach ( var device in deviceList . Devices )
151163 {
152164 if ( HasComp < AtmosMonitorComponent > ( device ) )
@@ -174,6 +186,11 @@ private void SetupShuttleDistroAtmosAlarms(
174186 _atmosMonitorSystem . SetThreshold ( device , AtmosMonitorThresholdType . Gas , threshold , gas ) ;
175187 }
176188 }
189+
190+ if ( atmos . FilterGases != null && TryComp < GasVentScrubberComponent > ( device , out var comp ) )
191+ {
192+ _gasVentScrubberSystem . SetFilterGases ( device , atmos . FilterGases , comp ) ;
193+ }
177194 }
178195 }
179196 }
0 commit comments