- type: entity
  parent: [RecyclableItemSteelSmall, GasPipeBase] # Frontier: add RecyclableItemSteelSmall
  abstract: true
  id: GasUnaryBase
  placement:
    mode: SnapgridCenter
  components:
    - type: AtmosDevice
    - type: Tag
      tags:
        - Unstackable
    - type: SubFloorHide
      blockInteractions: false
      blockAmbience: false
    - type: NodeContainer
      nodes:
        pipe:
          !type:PipeNode
          nodeGroupID: Pipe
          pipeDirection: South
    - type: CollideOnAnchor

- type: entity
  parent: [GasUnaryBase, AirSensorBase]
  id: GasVentPump
  name: air vent
  description: Has a valve and a pump attached to it.
  placement:
    mode: SnapgridCenter
  components:
    - type: ApcPowerReceiver
    - type: ExtensionCableReceiver
    - type: DeviceNetwork
      prefix: device-address-prefix-vent
    - type: Tag
      tags:
        - GasVent
        - Unstackable
    - type: SubFloorHide
      visibleLayers:
      - enum.SubfloorLayers.FirstLayer
    - type: Sprite
      drawdepth: FloorObjects
      sprite: _NF/Structures/Piping/Atmospherics/vent.rsi # Frontier
      noRot: true # Frontier
      layers:
        - sprite: Structures/Piping/Atmospherics/pipe.rsi
          state: pipeUnaryConnectors
          map: [ "enum.PipeVisualLayers.Pipe" ]
        - state: vent_off
          map: [ "enabled", "enum.SubfloorLayers.FirstLayer" ]
    - type: Appearance
    - type: PipeColorVisuals
    - type: GenericVisualizer
      visuals:
        enum.VentPumpVisuals.State:
          enabled:
            Off: { state: vent_off }
            In: { state: vent_in }
            Out: { state: vent_out }
            Welded: { state: vent_welded }
            Lockout: { state: vent_lockout }
    - type: GasVentPump
    - type: Construction
      graph: GasUnary
      node: ventpump
    - type: VentCritterSpawnLocation
    - type: AmbientSound
      enabled: true
      volume: -12
      range: 5
      sound:
        path: /Audio/Ambience/Objects/gas_vent.ogg
    - type: Weldable
    - type: AtmosMonitoringConsoleDevice
      navMapBlip: GasVentOpening
    - type: GuideHelp
      guides:
      - AirVent
      - DeviceMonitoringAndControl

- type: entity
  parent: GasUnaryBase
  id: GasPassiveVent
  name: passive vent
  description: It's an open vent.
  placement:
    mode: SnapgridCenter
  components:
    - type: SubFloorHide
      visibleLayers:
      - enum.SubfloorLayers.FirstLayer
    - type: Sprite
      drawdepth: FloorObjects
      sprite: _NF/Structures/Piping/Atmospherics/vent.rsi # Frontier
      noRot: true # Frontier
      layers:
        - sprite: Structures/Piping/Atmospherics/pipe.rsi
          state: pipeUnaryConnectors
          map: [ "enum.PipeVisualLayers.Pipe" ]
        - state: vent_passive
          map: [ "enum.SubfloorLayers.FirstLayer" ]
    - type: Appearance
    - type: PipeColorVisuals
    - type: GasPassiveVent
    - type: Construction
      graph: GasUnary
      node: passivevent
    - type: AtmosMonitoringConsoleDevice
      navMapBlip: GasVentOpening
    - type: GuideHelp
      guides:
      - PassiveVent

- type: entity
  parent: [GasUnaryBase, AirSensorBase]
  id: GasVentScrubber
  name: air scrubber
  description: Has a valve and pump attached to it.
  placement:
    mode: SnapgridCenter
  components:
    - type: ApcPowerReceiver
    - type: ExtensionCableReceiver
    - type: DeviceNetwork
      prefix: device-address-prefix-scrubber
    - type: Tag
      tags:
        - GasScrubber
        - Unstackable
    - type: SubFloorHide
      visibleLayers:
      - enum.SubfloorLayers.FirstLayer
    - type: Sprite
      drawdepth: FloorObjects
      sprite: _NF/Structures/Piping/Atmospherics/scrubber.rsi # Frontier
      noRot: true # Frontier
      layers:
        - sprite: Structures/Piping/Atmospherics/pipe.rsi
          state: pipeUnaryConnectors
          map: [ "enum.PipeVisualLayers.Pipe" ]
        - state: scrub_off
          map: [ "enabled", "enum.SubfloorLayers.FirstLayer" ]
    - type: Appearance
    - type: PipeColorVisuals
    - type: GenericVisualizer
      visuals:
        enum.ScrubberVisuals.State:
          enabled:
            Off: { state: scrub_off }
            Scrub: { state: scrub_on }
            Siphon: { state: scrub_purge }
            WideScrub: { state: scrub_wide }
            Welded: { state: scrub_welded }
    - type: AtmosDevice
    - type: GasVentScrubber
    - type: Construction
      graph: GasUnary
      node: ventscrubber
    - type: AmbientSound
      enabled: true
      volume: -12
      range: 5
      sound:
        path: /Audio/Ambience/Objects/gas_vent.ogg
    - type: Weldable
    - type: AtmosMonitoringConsoleDevice
      navMapBlip: GasVentScrubber
    - type: GuideHelp
      guides:
      - AirScrubber
      - DeviceMonitoringAndControl

- type: entity
  parent: GasUnaryBase
  id: GasOutletInjector
  name: air injector
  description: Has a valve and pump attached to it.
  placement:
    mode: SnapgridCenter
  components:
    - type: Sprite
      drawdepth: FloorObjects
      sprite: Structures/Piping/Atmospherics/outletinjector.rsi
      layers:
        - state: pipeUnaryConnectors
          sprite: Structures/Piping/Atmospherics/pipe.rsi
          map: [ "enum.PipeVisualLayers.Pipe" ]
        - state: injector
          map: [ "enum.SubfloorLayers.FirstLayer" ]
        - state: injector-unshaded
          shader: unshaded
          map: [ "enum.LightLayers.Unshaded" ]
          color: "#990000"
    - type: Appearance
    - type: GenericVisualizer
      visuals:
       # toggle color of the unshaded light:
       enum.OutletInjectorVisuals.Enabled:
         enum.LightLayers.Unshaded:
           True: { color: "#5eff5e" }
           False: { color: "#990000" }
    - type: PipeColorVisuals
    - type: GasOutletInjector
    - type: Construction
      graph: GasUnary
      node: outletinjector
    - type: SubFloorHide
      visibleLayers:
      - enum.SubfloorLayers.FirstLayer
      - enum.LightLayers.Unshaded
    - type: AtmosMonitoringConsoleDevice
      navMapBlip: GasVentOpening
    - type: GuideHelp
      guides:
      - AirInjector

- type: entity
  parent: [ BaseMachinePowered, ConstructibleMachine ]
  id: BaseGasThermoMachine
  name: thermomachine
  abstract: true
  placement:
    mode: SnapgridCenter
  components:
    - type: Sprite
      sprite: Structures/Piping/Atmospherics/thermomachine.rsi
      snapCardinals: true
    - type: Appearance
    - type: PipeColorVisuals
    - type: Rotatable
    - type: GasThermoMachine
    - type: AtmosPipeColor
    - type: AtmosPipeLayers
      spriteLayersRsiPaths:
        enum.PipeVisualLayers.Pipe:
          Primary: Structures/Piping/Atmospherics/thermomachine.rsi
          Secondary: Structures/Piping/Atmospherics/thermomachine_alt1.rsi
          Tertiary: Structures/Piping/Atmospherics/thermomachine_alt2.rsi
    - type: AtmosDevice
    - type: UserInterface
      interfaces:
        enum.ThermomachineUiKey.Key:
          type: GasThermomachineBoundUserInterface
    - type: ActivatableUI
      inHandsOnly: false
      key: enum.ThermomachineUiKey.Key
    - type: WiresPanel
    - type: WiresVisuals
    - type: PipeRestrictOverlap
    - type: NodeContainer
      nodes:
        pipe:
          !type:PipeNode
          nodeGroupID: Pipe
          pipeDirection: South
    - type: Transform
      noRot: false
    - type: DeviceNetwork
      deviceNetId: AtmosDevices
      receiveFrequencyId: AtmosMonitor
      transmitFrequencyId: AtmosMonitor
      sendBroadcastAttemptEvent: true
      examinableAddress: true
    - type: WiredNetworkConnection
    - type: PowerSwitch
    - type: AtmosMonitoringConsoleDevice
      navMapBlip: Thermoregulator
    - type: GuideHelp
      guides:
      - Thermomachines

- type: entity
  parent: BaseGasThermoMachine
  id: GasThermoMachineFreezer
  name: freezer
  description: Cools gas in connected pipes.
  placement:
    mode: SnapgridCenter
  components:
    - type: StationAiWhitelist
    - type: Sprite
      granularLayersRendering: true
      layers:
        - state: freezerOff
          map: [ "enum.PowerDeviceVisualLayers.Powered" ]
        - state: freezerPanelOpen
          map: [ "enum.WiresVisualLayers.MaintenancePanel" ]
        - state: pipe
          map: [ "enum.PipeVisualLayers.Pipe" ]
          renderingStrategy: Default
    - type: GenericVisualizer
      visuals:
        enum.PowerDeviceVisuals.Powered:
          enum.PowerDeviceVisualLayers.Powered:
            True: { state: freezerOn }
            False: { state: freezerOff }
    - type: GasThermoMachine
      coefficientOfPerformance: -3.9
    - type: ApcPowerReceiver
      powerDisabled: true #starts off
    - type: Machine
      board: ThermomachineFreezerMachineCircuitBoard
    - type: DeviceNetwork
      prefix: device-address-prefix-freezer
    - type: StealTarget
      stealGroup: FreezerHeater

- type: entity
  parent: GasThermoMachineFreezer
  id: GasThermoMachineFreezerEnabled
  suffix: Enabled
  components:
  - type: GasThermoMachine
  - type: ApcPowerReceiver
    powerDisabled: false

- type: entity
  parent: BaseGasThermoMachine
  id: GasThermoMachineHeater
  name: heater
  description: Heats gas in connected pipes.
  placement:
    mode: SnapgridCenter
  components:
    - type: StationAiWhitelist
    - type: Sprite
      granularLayersRendering : true
      layers:
        - state: heaterOff
          map: [ "enum.PowerDeviceVisualLayers.Powered" ]
        - state: heaterPanelOpen
          map: ["enum.WiresVisualLayers.MaintenancePanel"]
        - state: pipe
          map: [ "enum.PipeVisualLayers.Pipe" ]
          renderingStrategy: Default
    - type: GenericVisualizer
      visuals:
        enum.PowerDeviceVisuals.Powered:
          enum.PowerDeviceVisualLayers.Powered:
            True: { state: heaterOn }
            False: { state: heaterOff }
    - type: GasThermoMachine
      coefficientOfPerformance: 0.95
    - type: ApcPowerReceiver
      powerDisabled: true #starts off
    - type: Machine
      board: ThermomachineHeaterMachineCircuitBoard
    - type: DeviceNetwork
      prefix: device-address-prefix-heater
    - type: StealTarget
      stealGroup: FreezerHeater

- type: entity
  parent: GasThermoMachineHeater
  id: GasThermoMachineHeaterEnabled
  suffix: Enabled
  components:
  - type: GasThermoMachine
  - type: ApcPowerReceiver
    powerDisabled: false

- type: entity
  parent: GasThermoMachineFreezer
  id: GasThermoMachineHellfireFreezer
  name: hellfire freezer
  description: An advanced machine that cools gas in connected pipes. Has the side effect of chilling the surrounding area. Cold as Hell!
  components:
  - type: Sprite
    sprite: Structures/Piping/Atmospherics/hellfirethermomachine.rsi
  - type: GasThermoMachine
    minTemperature: 23.15
    heatCapacity: 40000
    energyLeakPercentage: 0.15
  - type: Machine
    board: HellfireFreezerMachineCircuitBoard

- type: entity
  parent: GasThermoMachineHeater
  id: GasThermoMachineHellfireHeater
  name: hellfire heater
  description: An advanced machine that heats gas in connected pipes. Has the side effect of leaking heat into the surrounding area. Hot as Hell!
  components:
  - type: Sprite
    sprite: Structures/Piping/Atmospherics/hellfirethermomachine.rsi
  - type: GasThermoMachine
    maxTemperature: 1193.15
    heatCapacity: 40000
    energyLeakPercentage: 0.15
  - type: Machine
    board: HellfireHeaterMachineCircuitBoard

- type: entity
  parent: [ BaseMachinePowered, SmallConstructibleMachine ]
  id: BaseGasCondenser
  name: condenser
  description: Condenses gases into liquids. Now we just need some plumbing.
  placement:
    mode: SnapgridCenter
  components:
  - type: Sprite
    sprite: Structures/Piping/Atmospherics/condenser.rsi
    snapCardinals: true
    granularLayersRendering: true
    layers:
    - state: off
      map: [ "enum.PowerDeviceVisualLayers.Powered" ]
    - state: panel
      map: ["enum.WiresVisualLayers.MaintenancePanel"]
    - state: pipe
      map: [ "enum.PipeVisualLayers.Pipe" ]
      renderingStrategy: Default
    - state: fill-1
      map: ["enum.SolutionContainerLayers.Fill"]
      visible: false
    - state: trans
  - type: Appearance
  - type: GenericVisualizer
    visuals:
      enum.PowerDeviceVisuals.Powered:
        enum.PowerDeviceVisualLayers.Powered:
          True: { state: on }
          False: { state: off }
  - type: SolutionContainerVisuals
    maxFillLevels: 7
    fillBaseName: fill-
  - type: PipeColorVisuals
  - type: Rotatable
  - type: GasCondenser
  - type: AtmosPipeColor
  - type: AtmosPipeLayers
    spriteLayersRsiPaths:
      enum.PipeVisualLayers.Pipe:
        Primary: Structures/Piping/Atmospherics/condenser.rsi
        Secondary: Structures/Piping/Atmospherics/condenser_alt1.rsi
        Tertiary: Structures/Piping/Atmospherics/condenser_alt2.rsi
  - type: AtmosDevice
  - type: PipeRestrictOverlap
  - type: ApcPowerReceiver
    powerLoad: 3000 # Frontier 10000<3000
  - type: Machine
    board: CondenserMachineCircuitBoard
  - type: WiresPanel
  - type: WiresVisuals
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 200
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
      - !type:SpillBehavior
        solution: tank
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
  - type: NodeContainer
    nodes:
      pipe:
        !type:PipeNode
        nodeGroupID: Pipe
        pipeDirection: South
  - type: Transform
    noRot: false
  - type: SolutionContainerManager
    solutions:
      tank:
        maxVol: 400
  - type: MixableSolution
    solution: tank
  - type: DrainableSolution
    solution: tank
  - type: ExaminableSolution
    solution: tank
  - type: PowerSwitch
  - type: AtmosMonitoringConsoleDevice
    navMapBlip: Thermoregulator
  - type: GuideHelp
    guides:
    - GasCondensing

