From 3cd30c408b18dc5b7f8c7bc7590930d06cef13a3 Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Sat, 25 Mar 2023 23:16:27 +0000 Subject: [PATCH] add signal valve (#14830) Co-authored-by: deltanedas <@deltanedas:kde.org> --- .../SignalControlledValveComponent.cs | 18 ++++++ .../SignalControlledValveSystem.cs | 43 ++++++++++++++ .../Structures/Piping/Atmospherics/binary.yml | 54 ++++++++++++++++++ .../Graphs/utilities/atmos_binary.yml | 22 +++++++ .../Recipes/Construction/utilities.yml | 23 +++++++- .../Piping/Atmospherics/pump.rsi/meta.json | 10 +++- .../Atmospherics/pump.rsi/pumpSignalValve.png | Bin 0 -> 821 bytes .../pump.rsi/pumpSignalValveOn.png | Bin 0 -> 820 bytes 8 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 Content.Server/Atmos/Piping/Binary/Components/SignalControlledValveComponent.cs create mode 100644 Content.Server/Atmos/Piping/Binary/EntitySystems/SignalControlledValveSystem.cs create mode 100644 Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/pumpSignalValve.png create mode 100644 Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/pumpSignalValveOn.png diff --git a/Content.Server/Atmos/Piping/Binary/Components/SignalControlledValveComponent.cs b/Content.Server/Atmos/Piping/Binary/Components/SignalControlledValveComponent.cs new file mode 100644 index 0000000000..b5a59399f1 --- /dev/null +++ b/Content.Server/Atmos/Piping/Binary/Components/SignalControlledValveComponent.cs @@ -0,0 +1,18 @@ +using Content.Server.Atmos.Piping.Binary.EntitySystems; +using Content.Shared.MachineLinking; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; + +namespace Content.Server.Atmos.Piping.Binary.Components; + +[RegisterComponent, Access(typeof(SignalControlledValveSystem))] +public sealed class SignalControlledValveComponent : Component +{ + [DataField("openPort", customTypeSerializer: typeof(PrototypeIdSerializer))] + public string OpenPort = "Open"; + + [DataField("closePort", customTypeSerializer: typeof(PrototypeIdSerializer))] + public string ClosePort = "Close"; + + [DataField("togglePort", customTypeSerializer: typeof(PrototypeIdSerializer))] + public string TogglePort = "Toggle"; +} diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/SignalControlledValveSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/SignalControlledValveSystem.cs new file mode 100644 index 0000000000..600671c442 --- /dev/null +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/SignalControlledValveSystem.cs @@ -0,0 +1,43 @@ +using Content.Server.Atmos.Piping.Binary.Components; +using Content.Server.MachineLinking.Events; +using Content.Server.MachineLinking.System; + +namespace Content.Server.Atmos.Piping.Binary.EntitySystems; + +public sealed class SignalControlledValveSystem : EntitySystem +{ + [Dependency] private readonly SignalLinkerSystem _signal = default!; + [Dependency] private readonly GasValveSystem _valve = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnInit); + SubscribeLocalEvent(OnSignalReceived); + } + + private void OnInit(EntityUid uid, SignalControlledValveComponent comp, ComponentInit args) + { + _signal.EnsureReceiverPorts(uid, comp.OpenPort, comp.ClosePort, comp.TogglePort); + } + + private void OnSignalReceived(EntityUid uid, SignalControlledValveComponent comp, SignalReceivedEvent args) + { + if (!TryComp(uid, out var valve)) + return; + + if (args.Port == comp.OpenPort) + { + _valve.Set(uid, valve, true); + } + else if (args.Port == comp.ClosePort) + { + _valve.Set(uid, valve, false); + } + else if (args.Port == comp.TogglePort) + { + _valve.Toggle(uid, valve); + } + } +} diff --git a/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/binary.yml b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/binary.yml index 42a022d884..c699577834 100644 --- a/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/binary.yml +++ b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/binary.yml @@ -181,6 +181,60 @@ sound: path: /Audio/Ambience/Objects/gas_hiss.ogg +- type: entity + parent: GasBinaryBase + id: SignalControlledValve + name: signal valve + description: A pipe with a valve that can be controlled with signals. + placement: + mode: SnapgridCenter + components: + - type: Sprite + netsync: false + sprite: Structures/Piping/Atmospherics/pump.rsi + layers: + - sprite: Structures/Piping/Atmospherics/pipe.rsi + state: pipeStraight + map: [ "enum.PipeVisualLayers.Pipe" ] + - state: pumpSignalValve + map: [ "enum.SubfloorLayers.FirstLayer", "enabled" ] + - type: Appearance + - type: GenericVisualizer + visuals: + enum.FilterVisuals.Enabled: + enabled: + True: { state: pumpSignalValveOn } + False: { state: pumpSignalValve } + - type: PipeColorVisuals + - type: GasValve + - type: SignalControlledValve + - type: SignalReceiver + inputs: + Open: [] + Close: [] + Toggle: [] + - type: NodeContainer + nodes: + inlet: + !type:PipeNode + nodeGroupID: Pipe + pipeDirection: North + volume: 100 + outlet: + !type:PipeNode + nodeGroupID: Pipe + pipeDirection: South + volume: 100 + - type: Construction + graph: GasBinary + node: signalvalve + - type: AmbientSound + enabled: false + volume: -9 + range: 5 + sound: + path: /Audio/Ambience/Objects/gas_hiss.ogg + - type: entity parent: GasBinaryBase id: GasPort diff --git a/Resources/Prototypes/Recipes/Construction/Graphs/utilities/atmos_binary.yml b/Resources/Prototypes/Recipes/Construction/Graphs/utilities/atmos_binary.yml index ff6c97c5d2..26db6533bf 100644 --- a/Resources/Prototypes/Recipes/Construction/Graphs/utilities/atmos_binary.yml +++ b/Resources/Prototypes/Recipes/Construction/Graphs/utilities/atmos_binary.yml @@ -28,6 +28,12 @@ amount: 2 doAfter: 1 + - to: signalvalve + steps: + - material: Steel + amount: 2 + doAfter: 1 + - to: port steps: - material: Steel @@ -104,6 +110,22 @@ - tool: Welding doAfter: 1 + - node: signalvalve + entity: SignalControlledValve + edges: + - to: start + conditions: + - !type:EntityAnchored + anchored: false + completed: + - !type:SpawnPrototype + prototype: SheetSteel1 + amount: 2 + - !type:DeleteEntity + steps: + - tool: Welding + doAfter: 1 + - node: port entity: GasPort edges: diff --git a/Resources/Prototypes/Recipes/Construction/utilities.yml b/Resources/Prototypes/Recipes/Construction/utilities.yml index 29a4e92828..835ad8b6bf 100644 --- a/Resources/Prototypes/Recipes/Construction/utilities.yml +++ b/Resources/Prototypes/Recipes/Construction/utilities.yml @@ -547,6 +547,27 @@ conditions: - !type:TileNotBlocked {} +- type: construction + id: SignalControlledValve + name: signal valve + description: Valve controlled by signal inputs. + graph: GasBinary + startNode: start + targetNode: signalvalve + category: construction-category-utilities + placementMode: SnapgridCenter + canBuildInImpassable: false + icon: + sprite: Structures/Piping/Atmospherics/pump.rsi + state: pumpSignalValve + layers: + - sprite: Structures/Piping/Atmospherics/pipe.rsi + state: pipeStraight + - sprite: Structures/Piping/Atmospherics/pump.rsi + state: pumpSignalValve + conditions: + - !type:TileNotBlocked {} + - type: construction id: GasPort name: connector port @@ -655,4 +676,4 @@ canRotate: true canBuildInImpassable: true conditions: - - !type:WallmountCondition {} \ No newline at end of file + - !type:WallmountCondition {} diff --git a/Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/meta.json b/Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/meta.json index 2d84c00953..d3d3ce6ba9 100644 --- a/Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/meta.json +++ b/Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/meta.json @@ -5,7 +5,7 @@ "y":32 }, "license":"CC-BY-SA-3.0", - "copyright":"Taken from https://github.com/tgstation/tgstation at commit 57cd1d59ca019dd0e7811ac451f295f818e573da", + "copyright":"Taken from https://github.com/tgstation/tgstation at commit 57cd1d59ca019dd0e7811ac451f295f818e573da. Signal valve is a digital valve modified by deltanedas.", "states":[ { "name":"pumpDigitalValve", @@ -19,6 +19,14 @@ "name":"pumpManualValveOn", "directions":4 }, + { + "name":"pumpSignalValve", + "directions":4 + }, + { + "name":"pumpSignalValveOn", + "directions":4 + }, { "name":"pumpPassiveGate", "directions":4 diff --git a/Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/pumpSignalValve.png b/Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/pumpSignalValve.png new file mode 100644 index 0000000000000000000000000000000000000000..6b8d4988db195fbd6817225044921d2da9570286 GIT binary patch literal 821 zcmV-51Iqk~P)B%W)8inKS}oQL<`_i*wC!bwXncy*&tuuE=wBB9OB&1=zT zBD4{si;;}(Ib*3*lA7z|mXNA9eX3XOdsSEClHutPY7idM9k(Pb(~w*#If^%hTlIWq zN%%mx*OdWYaNs8jpn@4t3IbQ`|5eE;*%_rH!H@&M;{#b1=1hTlcss%V}2(7X<(7ZokL z17{o1cJE}|%#Re29X3sPIf14*Xt{>iLXg$(ImdS}y(Yit3U>FPTkbb6egjWdXf8i` z&Ak8s010qNS#tmY3labT3lag+-G2N400C`DL_t(|+U?q*PQySP$MJucN-7W}LoL-T zh%Ld^&h{O60tho`%mh!s3ry85MNW+%Cdg2TW>^HG4*y_aR+yTRJ|LEG?)`COiNyKm=C#$&l%EW8eakNmK0 zBTV?q@=6YpOG(qz9)H+uY$JURf_8rB(g+i7WLaj99S?`~_H;6lr|s73AZX@?u8k;) z!tTd$Z1?ZhYdMP|?>8^4{DEuu>ufJa*L#^&?`C7plcbZ*Yvns#0riOIBYDfK&6jVW zy8OI94K(vx4}iJbHh*)?$SMwrmB5)UMrvafVSb(2mG-<@0)hMdVN3_H1pN#1G=J>AG(H{_4(;kqB%W)8inKS}oQL<`_i*wC!bwXncy*&tuuE=wBB9OB&1=zT zBD4{si;;}(Ib*3*lA7z|mXNA9eX3XOdsSEClHutPY7idM9k(Pb(~w*#If^%hTlIWq zN%%mx*OdWYaNs8jpn@4t3IbQ`|5eE;*%_rH!H@&M;{#b1=1hTlcss%V}2(7X<(7ZokL z17{o1cJE}|%#Re29X3sPIf14*Xt{>iLXg$(ImdS}y(Yit3U>FPTkbb6egjWdXf8i` z&Ak8s010qNS#tmY3labT3lag+-G2N400C@CL_t(|+U?q*Ps2bI$MM&t0>Q)t$xur* z3u1GaA!qxqj4*@7Ozi(a)h)$=VWD+d=3#=QgogY*UpG>Fnyk37hchc|6d^R&31dIHzY9n0u z%gv=6jxHpQ3`U%ft{E?W7aZ@62Z9}Y$Gm!#Ld yTCV`jeD(T(I%wvr*9TbB&Zj;A0000$BYgs$0|SZM6dT6?0000