Skip to content

Commit 0f22c2f

Browse files
committed
Configure scrubbers to selected atmosphere on shuttle purchase
1 parent 6c568bc commit 0f22c2f

File tree

4 files changed

+54
-8
lines changed

4 files changed

+54
-8
lines changed

Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,5 +250,21 @@ private void OnWeldChanged(EntityUid uid, GasVentScrubberComponent component, re
250250
{
251251
UpdateState(uid, component);
252252
}
253+
254+
// Frontier: Shipyard custom atmosphere initialization
255+
public void SetFilterGases(EntityUid uid, IEnumerable<Gas> gases, GasVentScrubberComponent? component)
256+
{
257+
if (!Resolve(uid, ref component))
258+
return;
259+
260+
// Match what GasVentScrubberComponent.FromAirAlarmData does, even though creating a new HashSet here should
261+
// be safe
262+
component.FilterGases.Clear();
263+
component.FilterGases.UnionWith(gases);
264+
265+
// Not strictly necessary because the gas filter isn't visible on the sprite, but let's be a good citizen
266+
UpdateState(uid, component);
267+
}
268+
// End Frontier: Shipyard custom atmosphere initialization
253269
}
254270
}

Content.Server/_NF/Shipyard/Systems/ShipyardSystem.CustomAtmos.cs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

Content.Shared/_NF/Shipyard/Prototypes/ShuttleAtmospherePrototype.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public sealed class ShuttleAtmospherePrototype : IPrototype
2222

2323
[DataField]
2424
public ShuttleAtmosphereAlarms? Alarms;
25+
26+
[DataField]
27+
public List<Gas>? FilterGases;
2528
}
2629

2730
[DataDefinition]

Resources/Prototypes/_NF/Shipyard/Base/atmos.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@
2323
gasThresholdPrototypes:
2424
Oxygen: voxOxygen
2525
Nitrogen: voxNitrogen
26+
filterGases:
27+
- Oxygen
28+
- CarbonDioxide
29+
- Plasma
30+
- Tritium
31+
- WaterVapor
32+
- Ammonia
33+
- NitrousOxide
34+
- Frezon
35+
- Helium

0 commit comments

Comments
 (0)