Gas pipe sensors (#33128)

* Initial commit

* Monitored pipe node is now referenced by name

* Review changes

* Simplified construction

* Tweaked deconstruction to match other binary atmos devices

* Helper function removal

* Updated attribution
This commit is contained in:
chromiumboy
2024-11-21 21:46:10 -06:00
committed by GitHub
parent 38c70d6c9b
commit 403528cbf3
11 changed files with 196 additions and 2 deletions

View File

@@ -48,7 +48,9 @@ public sealed partial class AtmosMonitorComponent : Component
[DataField("gasThresholds")] [DataField("gasThresholds")]
public Dictionary<Gas, AtmosAlarmThreshold>? GasThresholds; public Dictionary<Gas, AtmosAlarmThreshold>? GasThresholds;
// Stores a reference to the gas on the tile this is on. /// <summary>
/// Stores a reference to the gas on the tile this entity is on (or the pipe network it monitors; see <see cref="MonitorsPipeNet"/>).
/// </summary>
[ViewVariables] [ViewVariables]
public GasMixture? TileGas; public GasMixture? TileGas;
@@ -65,4 +67,19 @@ public sealed partial class AtmosMonitorComponent : Component
/// </summary> /// </summary>
[DataField("registeredDevices")] [DataField("registeredDevices")]
public HashSet<string> RegisteredDevices = new(); public HashSet<string> RegisteredDevices = new();
/// <summary>
/// Specifies whether this device monitors its own internal pipe network rather than the surrounding atmosphere.
/// </summary>
/// <remarks>
/// If 'true', the entity will require a NodeContainerComponent with one or more PipeNodes to function.
/// </remarks>
[DataField]
public bool MonitorsPipeNet = false;
/// <summary>
/// Specifies the name of the pipe node that this device is monitoring.
/// </summary>
[DataField]
public string NodeNameMonitoredPipe = "monitored";
} }

View File

@@ -4,6 +4,9 @@ using Content.Server.Atmos.Piping.Components;
using Content.Server.Atmos.Piping.EntitySystems; using Content.Server.Atmos.Piping.EntitySystems;
using Content.Server.DeviceNetwork; using Content.Server.DeviceNetwork;
using Content.Server.DeviceNetwork.Systems; using Content.Server.DeviceNetwork.Systems;
using Content.Server.NodeContainer;
using Content.Server.NodeContainer.EntitySystems;
using Content.Server.NodeContainer.Nodes;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems; using Content.Server.Power.EntitySystems;
using Content.Shared.Atmos; using Content.Shared.Atmos;
@@ -25,6 +28,7 @@ public sealed class AtmosMonitorSystem : EntitySystem
[Dependency] private readonly AtmosDeviceSystem _atmosDeviceSystem = default!; [Dependency] private readonly AtmosDeviceSystem _atmosDeviceSystem = default!;
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!; [Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly NodeContainerSystem _nodeContainerSystem = default!;
// Commands // Commands
public const string AtmosMonitorSetThresholdCmd = "atmos_monitor_set_threshold"; public const string AtmosMonitorSetThresholdCmd = "atmos_monitor_set_threshold";
@@ -56,8 +60,15 @@ public sealed class AtmosMonitorSystem : EntitySystem
private void OnAtmosDeviceEnterAtmosphere(EntityUid uid, AtmosMonitorComponent atmosMonitor, ref AtmosDeviceEnabledEvent args) private void OnAtmosDeviceEnterAtmosphere(EntityUid uid, AtmosMonitorComponent atmosMonitor, ref AtmosDeviceEnabledEvent args)
{ {
if (atmosMonitor.MonitorsPipeNet && _nodeContainerSystem.TryGetNode<PipeNode>(uid, atmosMonitor.NodeNameMonitoredPipe, out var pipeNode))
{
atmosMonitor.TileGas = pipeNode.Air;
return;
}
atmosMonitor.TileGas = _atmosphereSystem.GetContainingMixture(uid, true); atmosMonitor.TileGas = _atmosphereSystem.GetContainingMixture(uid, true);
} }
private void OnMapInit(EntityUid uid, AtmosMonitorComponent component, MapInitEvent args) private void OnMapInit(EntityUid uid, AtmosMonitorComponent component, MapInitEvent args)
{ {
if (component.TemperatureThresholdId != null) if (component.TemperatureThresholdId != null)
@@ -215,6 +226,10 @@ public sealed class AtmosMonitorSystem : EntitySystem
&& component.GasThresholds == null) && component.GasThresholds == null)
return; return;
// If monitoring a pipe network, get its most recent gas mixture
if (component.MonitorsPipeNet && _nodeContainerSystem.TryGetNode<PipeNode>(uid, component.NodeNameMonitoredPipe, out var pipeNode))
component.TileGas = pipeNode.Air;
UpdateState(uid, component.TileGas, component); UpdateState(uid, component.TileGas, component);
} }

View File

@@ -0,0 +1,5 @@
gas-pipe-sensor-distribution-loop = Distribution loop
gas-pipe-sensor-waste-loop = Waste loop
gas-pipe-sensor-mixed-air = Mixed air
gas-pipe-sensor-teg-hot-loop = TEG hot loop
gas-pipe-sensor-teg-cold-loop = TEG cold loop

View File

@@ -0,0 +1,84 @@
- type: entity
parent: [AirSensorBase, GasPipeBase]
id: GasPipeSensor
name: gas pipe sensor
description: Reports on the status of the gas in the attached pipe network.
placement:
mode: SnapgridCenter
components:
- type: Sprite
sprite: Structures/Piping/Atmospherics/gas_pipe_sensor.rsi
drawdepth: BelowFloor
layers:
- sprite: Structures/Piping/Atmospherics/pipe.rsi
map: [ "enum.PipeVisualLayers.Pipe" ]
state: pipeStraight
- map: ["base"]
state: base
- map: [ "enum.PowerDeviceVisualLayers.Powered" ]
state: lights
shader: unshaded
- type: Appearance
- type: GenericVisualizer
visuals:
enum.PowerDeviceVisuals.Powered:
enum.PowerDeviceVisualLayers.Powered:
False: { state: blank }
True: { state: lights }
- type: AtmosMonitor
monitorsPipeNet: true
- type: ApcPowerReceiver
- type: ExtensionCableReceiver
- type: Construction
graph: GasPipeSensor
node: sensor
- type: NodeContainer
nodes:
monitored:
!type:PipeNode
nodeGroupID: Pipe
pipeDirection: Longitudinal
- type: Tag
tags:
- AirSensor
- Unstackable
- type: entity
parent: GasPipeSensor
id: GasPipeSensorDistribution
suffix: Distribution
components:
- type: Label
currentLabel: gas-pipe-sensor-distribution-loop
- type: entity
parent: GasPipeSensor
id: GasPipeSensorWaste
suffix: Waste
components:
- type: Label
currentLabel: gas-pipe-sensor-waste-loop
- type: entity
parent: GasPipeSensor
id: GasPipeSensorMixedAir
suffix: Mixed air
components:
- type: Label
currentLabel: gas-pipe-sensor-mixed-air
- type: entity
parent: GasPipeSensor
id: GasPipeSensorTEGHot
suffix: TEG hot
components:
- type: Label
currentLabel: gas-pipe-sensor-teg-hot-loop
- type: entity
parent: GasPipeSensor
id: GasPipeSensorTEGCold
suffix: TEG cold
components:
- type: Label
currentLabel: gas-pipe-sensor-teg-cold-loop

View File

@@ -0,0 +1,29 @@
- type: constructionGraph
id: GasPipeSensor
start: start
graph:
- node: start
edges:
- to: sensor
steps:
- material: Steel
amount: 2
doAfter: 1
- node: sensor
entity: GasPipeSensor
actions:
- !type:SetAnchor
edges:
- to: start
completed:
- !type:SpawnPrototype
prototype: SheetSteel1
amount: 2
- !type:DeleteEntity
conditions:
- !type:EntityAnchored
anchored: false
steps:
- tool: Welding
doAfter: 1

View File

@@ -366,6 +366,21 @@
objectType: Structure objectType: Structure
canRotate: true canRotate: true
- type: construction
name: gas pipe sensor
id: GasPipeSensor
graph: GasPipeSensor
startNode: start
targetNode: sensor
category: construction-category-structures
description: Reports on the status of the gas within the attached pipe network.
icon:
sprite: Structures/Piping/Atmospherics/gas_pipe_sensor.rsi
state: icon
placementMode: SnapgridCenter
objectType: Structure
canRotate: true
# ATMOS PIPES # ATMOS PIPES
- type: construction - type: construction
name: gas pipe half name: gas pipe half

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

View File

@@ -0,0 +1,29 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Created by chromiumboy (github) for SS14, based on the digital valve from /tg/, taken from https://github.com/tgstation/tgstation at commit 57cd1d59ca019dd0e7811ac451f295f818e573da.",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "base"
},
{
"name": "blank"
},
{
"name": "lights",
"delays": [
[
1.0,
0.25
]
]
}
]
}