Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas pipe sensors #33128

Merged
merged 10 commits into from
Nov 22, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public sealed partial class AtmosMonitorComponent : Component
[DataField("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]
public GasMixture? TileGas;

Expand All @@ -65,4 +67,19 @@ public sealed partial class AtmosMonitorComponent : Component
/// </summary>
[DataField("registeredDevices")]
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";
}
29 changes: 28 additions & 1 deletion Content.Server/Atmos/Monitor/Systems/AtmosMonitoringSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using Content.Server.Atmos.Piping.EntitySystems;
using Content.Server.DeviceNetwork;
using Content.Server.DeviceNetwork.Systems;
using Content.Server.NodeContainer;
using Content.Server.NodeContainer.Nodes;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Atmos;
Expand Down Expand Up @@ -56,8 +58,15 @@ private void OnAtmosDeviceLeaveAtmosphere(EntityUid uid, AtmosMonitorComponent a

private void OnAtmosDeviceEnterAtmosphere(EntityUid uid, AtmosMonitorComponent atmosMonitor, ref AtmosDeviceEnabledEvent args)
{
if (atmosMonitor.MonitorsPipeNet)
{
atmosMonitor.TileGas = GetGasPipeAirMixture(uid, atmosMonitor);
return;
chromiumboy marked this conversation as resolved.
Show resolved Hide resolved
}

atmosMonitor.TileGas = _atmosphereSystem.GetContainingMixture(uid, true);
}

private void OnMapInit(EntityUid uid, AtmosMonitorComponent component, MapInitEvent args)
{
if (component.TemperatureThresholdId != null)
Expand Down Expand Up @@ -206,7 +215,7 @@ private void OnAtmosUpdate(EntityUid uid, AtmosMonitorComponent component, ref A
if (!this.IsPowered(uid, EntityManager))
return;

if (args.Grid == null)
if (args.Grid == null)
return;

// if we're not monitoring atmos, don't bother
Expand All @@ -215,9 +224,27 @@ private void OnAtmosUpdate(EntityUid uid, AtmosMonitorComponent component, ref A
&& component.GasThresholds == null)
return;

// If monitoring a pipe network, get its most recent gas mixture
if (component.MonitorsPipeNet)
component.TileGas = GetGasPipeAirMixture(uid, component);
chromiumboy marked this conversation as resolved.
Show resolved Hide resolved

UpdateState(uid, component.TileGas, component);
}

private GasMixture? GetGasPipeAirMixture(EntityUid uid, AtmosMonitorComponent component)
{
if (!TryComp<NodeContainerComponent>(uid, out var nodeContainer))
return null;

if (nodeContainer.Nodes.TryGetValue(component.NodeNameMonitoredPipe, out var node) &&
node is PipeNode { } pipeNode)
{
return pipeNode.Air;
}

return null;
}

// Update checks the current air if it exceeds thresholds of
// any kind.
//
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/Atmos/Components/GasPipeSensorComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Atmos.Components;

[RegisterComponent, NetworkedComponent]
public sealed partial class GasPipeSensorComponent : Component;
chromiumboy marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
- type: entity
chromiumboy marked this conversation as resolved.
Show resolved Hide resolved
parent: GasPipeBase
id: GasPipeSensorAssembly
name: gas pipe sensor assembly
description: When assembled, this device will report on the characteristics of the gas in the attached pipe network.
components:
- type: Sprite
sprite: Structures/Specific/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.ConstructionVisuals.Layer" ]
state: cavity
- type: Appearance
- type: GenericVisualizer
visuals:
enum.ConstructionVisuals.Key:
enum.ConstructionVisuals.Layer:
assembly: { state: cavity }
wiredAssembly: { state: wires }
- type: Construction
graph: GasPipeSensor
node: assembly
- type: NodeContainer
nodes:
monitored:
!type:PipeNode
nodeGroupID: Pipe
pipeDirection: Longitudinal
- type: Tag
tags:
- Unstackable
chromiumboy marked this conversation as resolved.
Show resolved Hide resolved

- type: entity
parent: [AirSensorBase, GasPipeSensorAssembly]
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/Specific/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.ConstructionVisuals.Layer" ]
state: blank
- map: [ "enum.PowerDeviceVisualLayers.Powered" ]
state: lights
- type: Appearance
- type: GenericVisualizer
visuals:
enum.ConstructionVisuals.Key:
enum.ConstructionVisuals.Layer:
wiredSensor: { state: wires_connected }
sensor: { state: blank }
enum.PowerDeviceVisuals.Powered:
enum.PowerDeviceVisualLayers.Powered:
False: { state: blank, shader: shaded }
True: { state: lights, shader: unshaded }
- type: GasPipeSensor
- type: AtmosMonitor
monitorsPipeNet: true
- type: ApcPowerReceiver
- type: ExtensionCableReceiver
- type: Construction
graph: GasPipeSensor
node: sensor

- type: entity
parent: GasPipeSensor
id: GasPipeSensorDistribution
suffix: Distribution
components:
- type: Label
currentLabel: Distribution loop
chromiumboy marked this conversation as resolved.
Show resolved Hide resolved

- type: entity
parent: GasPipeSensor
id: GasPipeSensorWaste
suffix: Waste
components:
- type: Label
currentLabel: Waste loop

- type: entity
parent: GasPipeSensor
id: GasPipeSensorMixedAir
suffix: Mixed air
components:
- type: Label
currentLabel: Mixed air

- type: entity
parent: GasPipeSensor
id: GasPipeSensorTEGHot
suffix: TEG hot
components:
- type: Label
currentLabel: TEG hot loop

- type: entity
parent: GasPipeSensor
id: GasPipeSensorTEGCold
suffix: TEG cold
components:
- type: Label
currentLabel: TEG cold loop
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
- type: constructionGraph
id: GasPipeSensor
start: start
graph:
- node: start
chromiumboy marked this conversation as resolved.
Show resolved Hide resolved
edges:
- to: assembly
steps:
- material: Steel
amount: 2
doAfter: 1

- node: assembly
entity: GasPipeSensorAssembly
actions:
- !type:AppearanceChange {}
chromiumboy marked this conversation as resolved.
Show resolved Hide resolved
edges:
- to: start
completed:
- !type:SpawnPrototype
prototype: SheetSteel1
amount: 2
- !type:DeleteEntity {}
conditions:
- !type:EntityAnchored
anchored: false
steps:
- tool: Screwing
doAfter: 2

- to: wiredAssembly
conditions:
- !type:EntityAnchored {}
steps:
- material: Cable
amount: 2
doAfter: 1

- node: wiredAssembly
actions:
- !type:AppearanceChange {}
edges:
- to: assembly
completed:
- !type:GivePrototype
prototype: CableApcStack1
amount: 2
conditions:
- !type:EntityAnchored
anchored: false
steps:
- tool: Cutting
doAfter: 1

- to: sensor
completed:
- !type:SetAnchor
value: false
conditions:
- !type:EntityAnchored {}
steps:
- tool: Screwing
doAfter: 2

- node: wiredSensor
actions:
- !type:AppearanceChange {}
edges:
- to: assembly
completed:
- !type:GivePrototype
prototype: CableApcStack1
amount: 2
conditions:
- !type:EntityAnchored
anchored: false
steps:
- tool: Cutting
doAfter: 1

- to: sensor
conditions:
- !type:EntityAnchored {}
steps:
- tool: Screwing
doAfter: 2

- node: sensor
entity: GasPipeSensor
actions:
- !type:AppearanceChange {}
- !type:SetAnchor {}
edges:
- to: wiredSensor
conditions:
- !type:EntityAnchored
anchored: false
steps:
- tool: Screwing
doAfter: 2
15 changes: 15 additions & 0 deletions Resources/Prototypes/Recipes/Construction/utilities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,21 @@
objectType: Structure
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/Specific/Atmospherics/gas_pipe_sensor.rsi
state: icon
placementMode: SnapgridCenter
objectType: Structure
canRotate: true

# ATMOS PIPES
- type: construction
name: gas pipe half
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
chromiumboy marked this conversation as resolved.
Show resolved Hide resolved
"version": 1,
"license": "CC0-1.0",
chromiumboy marked this conversation as resolved.
Show resolved Hide resolved
"copyright": "Created by chromiumboy (github) for SS14, based on the digital valve from /tg/",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "base"
},
{
"name": "cavity"
},
{
"name": "wires"
},
{
"name": "wires_connected"
},
{
"name": "blank"
chromiumboy marked this conversation as resolved.
Show resolved Hide resolved
},
{
"name": "lights",
"delays": [
[
1.0,
0.25
]
]
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading