# SPDX-FileCopyrightText: 2021 E F R <602406+Efruit@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Paul Ritter <ritter.paul1@googlemail.com>
# SPDX-FileCopyrightText: 2021 Swept <sweptwastaken@protonmail.com>
# SPDX-FileCopyrightText: 2021 Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Vera Aguilera Puerto <gradientvera@outlook.com>
# SPDX-FileCopyrightText: 2021 ike709 <ike709@github.com>
# SPDX-FileCopyrightText: 2021 ike709 <ike709@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 mirrorcult <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2022 Jack Fox <35575261+DubiousDoggo@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Kevin Zheng <kevinz5000@gmail.com>
# SPDX-FileCopyrightText: 2022 Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Moony <moonheart08@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 TekuNut <13456422+TekuNut@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Menshin <Menshin@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Tom Leys <tom@crump-leys.com>
# SPDX-FileCopyrightText: 2023 deltanedas <39013340+deltanedas@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 lzk <124214523+lzk228@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 metalgearsloth <comedian_vs_clown@hotmail.com>
# SPDX-FileCopyrightText: 2024 Tayrtahn <tayrtahn@gmail.com>
# SPDX-FileCopyrightText: 2024 chromiumboy <50505512+chromiumboy@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Łukasz Mędrek <lukasz@lukaszm.xyz>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <aiden@djkraz.com>
# SPDX-FileCopyrightText: 2025 ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Fishbait <Fishbait@git.ml>
# SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
# SPDX-FileCopyrightText: 2025 Ilya246 <57039557+Ilya246@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Ilya246 <ilyukarno@gmail.com>
# SPDX-FileCopyrightText: 2025 Rinary <72972221+Rinary1@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 fishbait <gnesse@gmail.com>
# SPDX-FileCopyrightText: 2025 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 ss14-Starlight <ss14-Starlight@outlook.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  parent: GasPipeBase
  abstract: true
  id: GasTrinaryBase
  placement:
    mode: SnapgridCenter
  components:
    - type: AtmosDevice
    - type: Tag
      tags:
        - Unstackable
    - type: SubFloorHide
      blockInteractions: false
      blockAmbience: false
    - type: NodeContainer
      nodes:
        inlet:
          !type:PipeNode
          nodeGroupID: Pipe
          pipeDirection: North
        filter:
          !type:PipeNode
          nodeGroupID: Pipe
          pipeDirection: West
        outlet:
          !type:PipeNode
          nodeGroupID: Pipe
          pipeDirection: South

- type: entity
  abstract: true
  id: GasTrinaryFlippedBase
  suffix: Flipped
  components:
  - type: NodeContainer
    nodes:
      inlet:
        !type:PipeNode
        nodeGroupID: Pipe
        pipeDirection: South
      filter:
        !type:PipeNode
        nodeGroupID: Pipe
        pipeDirection: West
      outlet:
        !type:PipeNode
        nodeGroupID: Pipe
        pipeDirection: North

# Goobstation
# a non-flippable filter
- type: entity
  abstract: true
  parent: GasTrinaryBase
  id: GasFilterBase
  components:
    - type: SubFloorHide
      visibleLayers:
      - enum.SubfloorLayers.FirstLayer
    - type: Sprite
      sprite: Structures/Piping/Atmospherics/gasfilter.rsi
      layers:
        - sprite: Structures/Piping/Atmospherics/pipe.rsi
          state: pipeTrinaryConnectors
          map: [ "enum.PipeVisualLayers.Pipe" ]
        - state: gasFilter
          map: [ "enum.SubfloorLayers.FirstLayer", "enabled" ]
    - type: Appearance
    - type: GenericVisualizer
      visuals:
        enum.FilterVisuals.Enabled:
          enabled:
            True: { state: gasFilterOn }
            False: { state: gasFilter }
    - type: PipeColorVisuals
    - type: UserInterface
      interfaces:
        enum.GasFilterUiKey.Key:
          type: GasFilterBoundUserInterface
    - type: GasFilter
      enabled: false
      transferRate: 1000
      maxTransferRate: 1000
    - type: Construction
      graph: GasTrinary
      node: filter
    - type: AmbientSound
      enabled: false
      volume: -9
      range: 5
      sound:
        path: /Audio/Ambience/Objects/gas_hiss.ogg
    - type: AtmosMonitoringConsoleDevice
      navMapBlip: GasFlowRegulator
    - type: GuideHelp
      guides:
      - MixingAndFiltering
    - type: VentCrawlerTube # Goobstation - ventcrawl
      containerId: VentCrawlerTube
    - type: VentCrawlerJunction # Goobstation - ventcrawl
      degrees:
        - 0
        - -90
        - 180
    - type: ContainerContainer # Goobstation - ventcrawl
      containers:
        VentCrawlerTube: !type:Container

# Goobstation - reparent to new base filter proto
- type: entity
  parent: GasFilterBase
  id: GasFilter
  name: gas filter
  description: Very useful for filtering gases.
  components:
  - type: Flippable
    mirrorEntity: GasFilterFlipped
  # Goobstation - if you see a merge conflict here, move all new components to GasFilterBase

# Goobstation - reparent to new base protos
- type: entity
  parent: [GasTrinaryFlippedBase, GasFilter]
  id: GasFilterFlipped
  components:
  - type: SubFloorHide
    visibleLayers:
    - enum.SubfloorLayers.FirstLayer
  - type: Sprite
    layers:
    - sprite: Structures/Piping/Atmospherics/pipe.rsi
      state: pipeTrinaryConnectors
      map: [ "enum.PipeVisualLayers.Pipe" ]
    - state: gasFilterF
      map: [ "enum.SubfloorLayers.FirstLayer", "enabled" ]
  - type: Flippable
    mirrorEntity: GasFilter
  - type: GenericVisualizer
    visuals:
      enum.FilterVisuals.Enabled:
        enabled:
          True: { state: gasFilterFOn }
          False: { state: gasFilterF }
  - type: Construction
    node: filterflipped
  # Goobstation - if you see a merge conflict here, move all new components to GasFilterBase

- type: entity
  parent: GasTrinaryBase
  id: GasMixer
  name: gas mixer
  description: Very useful for mixing gases.
  placement:
    mode: SnapgridCenter
  components:
    - type: SubFloorHide
      visibleLayers:
      - enum.SubfloorLayers.FirstLayer
    - type: Sprite
      sprite: Structures/Piping/Atmospherics/gasmixer.rsi
      layers:
        - sprite: Structures/Piping/Atmospherics/pipe.rsi
          state: pipeTrinaryConnectors
          map: [ "enum.PipeVisualLayers.Pipe" ]
        - state: gasMixer
          map: [ "enum.SubfloorLayers.FirstLayer", "enabled" ]
    - type: Appearance
    - type: GenericVisualizer
      visuals:
        enum.FilterVisuals.Enabled:
          enabled:
            True: { state: gasMixerOn }
            False: { state: gasMixer }
    - type: PipeColorVisuals
    - type: UserInterface
      interfaces:
        enum.GasMixerUiKey.Key:
          type: GasMixerBoundUserInterface
    - type: GasMixer
      enabled: false
      inletOne: inlet
      inletTwo: filter
    - type: Flippable
      mirrorEntity: GasMixerFlipped
    - type: Construction
      graph: GasTrinary
      node: mixer
    - type: AmbientSound
      enabled: false
      volume: -9
      range: 5
      sound:
        path: /Audio/Ambience/Objects/gas_hiss.ogg
    - type: AtmosMonitoringConsoleDevice
      navMapBlip: GasFlowRegulator
    - type: GuideHelp
      guides:
      - MixingAndFiltering
    - type: VentCrawlerTube # Goobstation - ventcrawl
      containerId: VentCrawlerTube
    - type: VentCrawlerJunction # Goobstation - ventcrawl
      degrees:
        - 0
        - -90
        - 180
    - type: ContainerContainer # Goobstation - ventcrawl
      containers:
        VentCrawlerTube: !type:Container

- type: entity
  parent: GasMixer
  id: GasMixerFlipped
  name: gas mixer
  suffix: Flipped
  placement:
    mode: SnapgridCenter
  components:
  - type: Sprite
    sprite: Structures/Piping/Atmospherics/gasmixer.rsi
    layers:
    - sprite: Structures/Piping/Atmospherics/pipe.rsi
      state: pipeTrinaryConnectors
      map: [ "enum.PipeVisualLayers.Pipe" ]
    - state: gasMixerF
      map: [ "enum.SubfloorLayers.FirstLayer", "enabled" ]
  - type: Appearance
  - type: GenericVisualizer
    visuals:
      enum.FilterVisuals.Enabled:
        enabled:
          True: { state: gasMixerFOn }
          False: { state: gasMixerF }
  - type: PipeColorVisuals
  - type: Flippable
    mirrorEntity: GasMixer
  - type: NodeContainer
    nodes:
      inlet:
        !type:PipeNode
        nodeGroupID: Pipe
        pipeDirection: South
      filter:
        !type:PipeNode
        nodeGroupID: Pipe
        pipeDirection: West
      outlet:
        !type:PipeNode
        nodeGroupID: Pipe
        pipeDirection: North
  - type: Construction
    node: mixerflipped
  - type: VentCrawlerTube # Goobstation - ventcrawl
    containerId: VentCrawlerTube
  - type: VentCrawlerJunction # Goobstation - ventcrawl
    degrees:
      - 0
      - -90
      - 180
  - type: ContainerContainer # Goobstation - ventcrawl
    containers:
      VentCrawlerTube: !type:Container

- type: entity
  parent: GasPipeBase
  id: PressureControlledValve
  name: pneumatic valve
  description: A bidirectional valve controlled by pressure. Opens if the output pipe is lower than the pressure of the control pipe by 101.325 kPa.
  placement:
    mode: SnapgridCenter
  components:
    - type: AtmosDevice
    - type: Tag
      tags:
        - Unstackable
    - type: SubFloorHide
      blockInteractions: false
      blockAmbience: false
      visibleLayers:
      - enum.SubfloorLayers.FirstLayer
    - type: NodeContainer
      nodes:
        inlet:
          !type:PipeNode
          nodeGroupID: Pipe
          pipeDirection: North
        control:
          !type:PipeNode
          nodeGroupID: Pipe
          pipeDirection: West
        outlet:
          !type:PipeNode
          nodeGroupID: Pipe
          pipeDirection: South
    - type: Sprite
      sprite: Structures/Piping/Atmospherics/pneumaticvalve.rsi
      layers:
        - sprite: Structures/Piping/Atmospherics/pipe.rsi
          state: pipeTrinaryConnectors
          map: [ "enum.PipeVisualLayers.Pipe" ]
        - state: off
          map: [ "enum.SubfloorLayers.FirstLayer", "enabled" ]
    - type: Appearance
    - type: GenericVisualizer
      visuals:
        enum.FilterVisuals.Enabled:
          enabled:
            True: { state: on }
            False: { state: off }
    - type: PipeColorVisuals
    - type: PressureControlledValve
    - type: AmbientSound
      enabled: false
      volume: -9
      range: 5
      sound:
        path: /Audio/Ambience/Objects/gas_hiss.ogg
    - type: Construction
      graph: GasTrinary
      node: pneumaticvalve
    - type: AtmosMonitoringConsoleDevice
      navMapBlip: GasFlowRegulator
    - type: GuideHelp
      guides:
      - PneumaticValve
      - Pumps
      - Valves
    - type: VentCrawlerTube # Goobstation - ventcrawl
      containerId: VentCrawlerTube
    - type: VentCrawlerJunction # Goobstation - ventcrawl
      degrees:
        - 0
        - -90
        - 180
    - type: ContainerContainer # Goobstation - ventcrawl
      containers:
        VentCrawlerTube: !type:Container
