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 0000000000..6b8d4988db Binary files /dev/null and b/Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/pumpSignalValve.png differ diff --git a/Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/pumpSignalValveOn.png b/Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/pumpSignalValveOn.png new file mode 100644 index 0000000000..cc19d3cffb Binary files /dev/null and b/Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/pumpSignalValveOn.png differ