From 403528cbf344531fedd3b5038f6463ba12eea41a Mon Sep 17 00:00:00 2001 From: chromiumboy <50505512+chromiumboy@users.noreply.github.com> Date: Thu, 21 Nov 2024 21:46:10 -0600 Subject: [PATCH] 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 --- .../Components/AtmosMonitorComponent.cs | 19 +++- .../Monitor/Systems/AtmosMonitoringSystem.cs | 17 +++- .../Locale/en-US/atmos/gas-pipe-sensor.ftl | 5 ++ .../Piping/Atmospherics/gas_pipe_sensor.yml | 84 ++++++++++++++++++ .../Graphs/utilities/gas_pipe_sensor.yml | 29 ++++++ .../Recipes/Construction/utilities.yml | 15 ++++ .../Atmospherics/gas_pipe_sensor.rsi/base.png | Bin 0 -> 248 bytes .../gas_pipe_sensor.rsi/blank.png | Bin 0 -> 83 bytes .../Atmospherics/gas_pipe_sensor.rsi/icon.png | Bin 0 -> 523 bytes .../gas_pipe_sensor.rsi/lights.png | Bin 0 -> 183 bytes .../gas_pipe_sensor.rsi/meta.json | 29 ++++++ 11 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 Resources/Locale/en-US/atmos/gas-pipe-sensor.ftl create mode 100644 Resources/Prototypes/Entities/Structures/Piping/Atmospherics/gas_pipe_sensor.yml create mode 100644 Resources/Prototypes/Recipes/Construction/Graphs/utilities/gas_pipe_sensor.yml create mode 100644 Resources/Textures/Structures/Piping/Atmospherics/gas_pipe_sensor.rsi/base.png create mode 100644 Resources/Textures/Structures/Piping/Atmospherics/gas_pipe_sensor.rsi/blank.png create mode 100644 Resources/Textures/Structures/Piping/Atmospherics/gas_pipe_sensor.rsi/icon.png create mode 100644 Resources/Textures/Structures/Piping/Atmospherics/gas_pipe_sensor.rsi/lights.png create mode 100644 Resources/Textures/Structures/Piping/Atmospherics/gas_pipe_sensor.rsi/meta.json diff --git a/Content.Server/Atmos/Monitor/Components/AtmosMonitorComponent.cs b/Content.Server/Atmos/Monitor/Components/AtmosMonitorComponent.cs index cb6d4d1630..830479561d 100644 --- a/Content.Server/Atmos/Monitor/Components/AtmosMonitorComponent.cs +++ b/Content.Server/Atmos/Monitor/Components/AtmosMonitorComponent.cs @@ -48,7 +48,9 @@ public sealed partial class AtmosMonitorComponent : Component [DataField("gasThresholds")] public Dictionary? GasThresholds; - // Stores a reference to the gas on the tile this is on. + /// + /// Stores a reference to the gas on the tile this entity is on (or the pipe network it monitors; see ). + /// [ViewVariables] public GasMixture? TileGas; @@ -65,4 +67,19 @@ public sealed partial class AtmosMonitorComponent : Component /// [DataField("registeredDevices")] public HashSet RegisteredDevices = new(); + + /// + /// Specifies whether this device monitors its own internal pipe network rather than the surrounding atmosphere. + /// + /// + /// If 'true', the entity will require a NodeContainerComponent with one or more PipeNodes to function. + /// + [DataField] + public bool MonitorsPipeNet = false; + + /// + /// Specifies the name of the pipe node that this device is monitoring. + /// + [DataField] + public string NodeNameMonitoredPipe = "monitored"; } diff --git a/Content.Server/Atmos/Monitor/Systems/AtmosMonitoringSystem.cs b/Content.Server/Atmos/Monitor/Systems/AtmosMonitoringSystem.cs index fbe74cbab7..17a24b1b0c 100644 --- a/Content.Server/Atmos/Monitor/Systems/AtmosMonitoringSystem.cs +++ b/Content.Server/Atmos/Monitor/Systems/AtmosMonitoringSystem.cs @@ -4,6 +4,9 @@ using Content.Server.Atmos.Piping.Components; using Content.Server.Atmos.Piping.EntitySystems; using Content.Server.DeviceNetwork; 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.EntitySystems; using Content.Shared.Atmos; @@ -25,6 +28,7 @@ public sealed class AtmosMonitorSystem : EntitySystem [Dependency] private readonly AtmosDeviceSystem _atmosDeviceSystem = default!; [Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly NodeContainerSystem _nodeContainerSystem = default!; // Commands 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) { + if (atmosMonitor.MonitorsPipeNet && _nodeContainerSystem.TryGetNode(uid, atmosMonitor.NodeNameMonitoredPipe, out var pipeNode)) + { + atmosMonitor.TileGas = pipeNode.Air; + return; + } + atmosMonitor.TileGas = _atmosphereSystem.GetContainingMixture(uid, true); } + private void OnMapInit(EntityUid uid, AtmosMonitorComponent component, MapInitEvent args) { if (component.TemperatureThresholdId != null) @@ -206,7 +217,7 @@ public sealed class AtmosMonitorSystem : EntitySystem if (!this.IsPowered(uid, EntityManager)) return; - if (args.Grid == null) + if (args.Grid == null) return; // if we're not monitoring atmos, don't bother @@ -215,6 +226,10 @@ public sealed class AtmosMonitorSystem : EntitySystem && component.GasThresholds == null) return; + // If monitoring a pipe network, get its most recent gas mixture + if (component.MonitorsPipeNet && _nodeContainerSystem.TryGetNode(uid, component.NodeNameMonitoredPipe, out var pipeNode)) + component.TileGas = pipeNode.Air; + UpdateState(uid, component.TileGas, component); } diff --git a/Resources/Locale/en-US/atmos/gas-pipe-sensor.ftl b/Resources/Locale/en-US/atmos/gas-pipe-sensor.ftl new file mode 100644 index 0000000000..8c3b8962e3 --- /dev/null +++ b/Resources/Locale/en-US/atmos/gas-pipe-sensor.ftl @@ -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 diff --git a/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/gas_pipe_sensor.yml b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/gas_pipe_sensor.yml new file mode 100644 index 0000000000..08015abe7d --- /dev/null +++ b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/gas_pipe_sensor.yml @@ -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 \ No newline at end of file diff --git a/Resources/Prototypes/Recipes/Construction/Graphs/utilities/gas_pipe_sensor.yml b/Resources/Prototypes/Recipes/Construction/Graphs/utilities/gas_pipe_sensor.yml new file mode 100644 index 0000000000..bda6d036e9 --- /dev/null +++ b/Resources/Prototypes/Recipes/Construction/Graphs/utilities/gas_pipe_sensor.yml @@ -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 \ No newline at end of file diff --git a/Resources/Prototypes/Recipes/Construction/utilities.yml b/Resources/Prototypes/Recipes/Construction/utilities.yml index 5dc0168fd3..2dec0e4a7d 100644 --- a/Resources/Prototypes/Recipes/Construction/utilities.yml +++ b/Resources/Prototypes/Recipes/Construction/utilities.yml @@ -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/Piping/Atmospherics/gas_pipe_sensor.rsi + state: icon + placementMode: SnapgridCenter + objectType: Structure + canRotate: true + # ATMOS PIPES - type: construction name: gas pipe half diff --git a/Resources/Textures/Structures/Piping/Atmospherics/gas_pipe_sensor.rsi/base.png b/Resources/Textures/Structures/Piping/Atmospherics/gas_pipe_sensor.rsi/base.png new file mode 100644 index 0000000000000000000000000000000000000000..4a9a8f6f2069490a67965a5fdf60019008341678 GIT binary patch literal 248 zcmVuMTL$ yH{Ahdj(Z-x$LRe>F*Ot^?|}CAhG7_n0RRt>*hN^}z=Wm%0000B?Wc})uc*XMaS cfSB*u1QZw;r+*K>4&*R+y85}Sb4q9e0KdKysQ>@~ literal 0 HcmV?d00001 diff --git a/Resources/Textures/Structures/Piping/Atmospherics/gas_pipe_sensor.rsi/icon.png b/Resources/Textures/Structures/Piping/Atmospherics/gas_pipe_sensor.rsi/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..4ac9e76480361a744196e09cbc3edcfaa05f737d GIT binary patch literal 523 zcmV+m0`&cfP)4QFfKyZoFJf(g^&|8Oe4&~^=#%085CT*bCFYwkP}FRIzbjfqyss? zpdlL<4S}TSs#$0PPK2?mwfilrdG-JGzrWvm;1E(u8%2=?h@!|!DJ_n%=bG5-^#E+U z-6l`?u8Bej`u#q6!vZQgw}nfl`X&pTC|7{h2V0V`LDZ zlqzNz$spiibPd46Kj-%^YJB=M{2Kjur9hr=BJh?1o4CKbd$$3d2t3Z`TLT^*9li1f zkO|zW4}@X3t@AXFnZ_|nDZ(&xD#3^Lfvm50Qs5~`yhf|V_tR5;4~LvxT+li=a01WO ziZ^4ql!c^TucNi5*=&}x4`{6sLSU^ehrmYm)oNAVMg+V$jte2M0nTecX9B+Ovs^Bz z)oSH>z!2ZKR*f5CV>W;7aki^U=rfxil~y+@Q(CfWc1 N002ovPDHLkV1lGg_D%o* literal 0 HcmV?d00001 diff --git a/Resources/Textures/Structures/Piping/Atmospherics/gas_pipe_sensor.rsi/lights.png b/Resources/Textures/Structures/Piping/Atmospherics/gas_pipe_sensor.rsi/lights.png new file mode 100644 index 0000000000000000000000000000000000000000..6108d2b99492134bbeeb0d5f7bfc64256627e5a9 GIT binary patch literal 183 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3HE3&8=$zQgxm#jv*QM-d^6w+n^xQ^6+xR zZ7W7;i<#UTnTvNc3g6hpAm-(ybA_$*L;YE9(VgWAj0~@?P7z9(SmoK=x6?D~tYLmB z>r}}@+Ozt(GlWeZ8tW>w%+r6KFP`wJcJ+mCKeqi<;XaYk>y-ao(j#%xIsa=vqu#UY d11$!EKR5Zp#g)Ie6~!okxSp