]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
add signal valve (#14830)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Sat, 25 Mar 2023 23:16:27 +0000 (23:16 +0000)
committerGitHub <noreply@github.com>
Sat, 25 Mar 2023 23:16:27 +0000 (16:16 -0700)
Co-authored-by: deltanedas <@deltanedas:kde.org>
Content.Server/Atmos/Piping/Binary/Components/SignalControlledValveComponent.cs [new file with mode: 0644]
Content.Server/Atmos/Piping/Binary/EntitySystems/SignalControlledValveSystem.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Structures/Piping/Atmospherics/binary.yml
Resources/Prototypes/Recipes/Construction/Graphs/utilities/atmos_binary.yml
Resources/Prototypes/Recipes/Construction/utilities.yml
Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/meta.json
Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/pumpSignalValve.png [new file with mode: 0644]
Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/pumpSignalValveOn.png [new file with mode: 0644]

diff --git a/Content.Server/Atmos/Piping/Binary/Components/SignalControlledValveComponent.cs b/Content.Server/Atmos/Piping/Binary/Components/SignalControlledValveComponent.cs
new file mode 100644 (file)
index 0000000..b5a5939
--- /dev/null
@@ -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<ReceiverPortPrototype>))]
+    public string OpenPort = "Open";
+
+    [DataField("closePort", customTypeSerializer: typeof(PrototypeIdSerializer<ReceiverPortPrototype>))]
+    public string ClosePort = "Close";
+
+    [DataField("togglePort", customTypeSerializer: typeof(PrototypeIdSerializer<ReceiverPortPrototype>))]
+    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 (file)
index 0000000..600671c
--- /dev/null
@@ -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<SignalControlledValveComponent, ComponentInit>(OnInit);
+        SubscribeLocalEvent<SignalControlledValveComponent, SignalReceivedEvent>(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<GasValveComponent>(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);
+        }
+    }
+}
index 42a022d8848dade3cd8382ceb6987eeceab48c13..c6995778342447d4ae5a90de4cbf94139ce4feba 100644 (file)
       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
index ff6c97c5d2fbb0739e05bc4b23a2fda0af6cbcbc..26db6533bfeb1a615d6433b8f64fd343d5d0d984 100644 (file)
         amount: 2
         doAfter: 1
 
+    - to: signalvalve
+      steps:
+      - material: Steel
+        amount: 2
+        doAfter: 1
+
     - to: port
       steps:
       - material: Steel
       - 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:
index 29a4e92828fbf39934c706eca070fa4b1feb50dc..835ad8b6bf33be55781b561a8658166f360dc6f9 100644 (file)
   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
   canRotate: true
   canBuildInImpassable: true
   conditions:
-  - !type:WallmountCondition {}
\ No newline at end of file
+  - !type:WallmountCondition {}
index 2d84c00953d126be29d8b0a37b2d0007c05879dc..d3d3ce6ba993e533051d9b4f5bb731da12d0caf1 100644 (file)
@@ -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",
          "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 (file)
index 0000000..6b8d498
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 (file)
index 0000000..cc19d3c
Binary files /dev/null and b/Resources/Textures/Structures/Piping/Atmospherics/pump.rsi/pumpSignalValveOn.png differ