# SPDX-FileCopyrightText: 2020 DrSmugleaf <DrSmugleaf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2020 ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
# SPDX-FileCopyrightText: 2020 Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
# SPDX-FileCopyrightText: 2020 Víctor Aguilera Puerto <zddm@outlook.es>
# SPDX-FileCopyrightText: 2021 20kdc <asdd2808@gmail.com>
# SPDX-FileCopyrightText: 2021 Julian Giebel <j.giebel@netrocks.info>
# SPDX-FileCopyrightText: 2021 Paul <ritter.paul1+git@googlemail.com>
# SPDX-FileCopyrightText: 2021 Paul Ritter <ritter.paul1@googlemail.com>
# SPDX-FileCopyrightText: 2021 Swept <sweptwastaken@protonmail.com>
# SPDX-FileCopyrightText: 2022 Jack Fox <35575261+DubiousDoggo@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Peptide90 <78795277+Peptide90@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Steven K <84935671+ModeratelyAware@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 AJCM-git <60196617+AJCM-git@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 ElectroJr <leonsfriedrich@gmail.com>
# SPDX-FileCopyrightText: 2023 Julian Giebel <juliangiebel@live.de>
# SPDX-FileCopyrightText: 2023 Velcroboy <107660393+ChilbroBaggins@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Visne <39844191+Visne@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Vordenburg <114301317+Vordenburg@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 AJCM <AJCM@tutanota.com>
# SPDX-FileCopyrightText: 2024 Aiden <aiden@djkraz.com>
# SPDX-FileCopyrightText: 2024 Alex Evgrashin <aevgrashin@yandex.ru>
# SPDX-FileCopyrightText: 2024 Alex Pavlenko <diraven@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Alice "Arimah" Heurlin <30327355+arimah@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 ArkiveDev <95712736+ArkiveDev@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Boaz1111 <149967078+Boaz1111@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Brandon Hu <103440971+Brandon-Huu@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Cojoke <83733158+Cojoke-dot@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Doomsdrayk <robotdoughnut@comcast.net>
# SPDX-FileCopyrightText: 2024 DrEnzyme <DrEnzyme@gmail.com>
# SPDX-FileCopyrightText: 2024 DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Ed <96445749+TheShuEd@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Elysium206 <151651971+Elysium206@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Emisse <99158783+Emisse@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Eoin Mcloughlin <helloworld@eoinrul.es>
# SPDX-FileCopyrightText: 2024 Errant <35878406+Errant-4@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Flareguy <78941145+Flareguy@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Floofi <126319569+Shadowtheprotogen546@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Ghagliiarghii <68826635+Ghagliiarghii@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 HS <81934438+HolySSSS@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Jeff <velcroboy333@hotmail.com>
# SPDX-FileCopyrightText: 2024 JustCone <141039037+JustCone14@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 K-Dynamic <20566341+K-Dynamic@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2024 Kevin Zheng <kevinz5000@gmail.com>
# SPDX-FileCopyrightText: 2024 Ko4ergaPunk <62609550+Ko4ergaPunk@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Mervill <mervills.email@gmail.com>
# SPDX-FileCopyrightText: 2024 MetalSage <74924875+MetalSage@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 MetalSage <metalsage.official@gmail.com>
# SPDX-FileCopyrightText: 2024 MilenVolf <63782763+MilenVolf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 MureixloI <132683811+MureixloI@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 PJBot <pieterjan.briers+bot@gmail.com>
# SPDX-FileCopyrightText: 2024 Partmedia <kevinz5000@gmail.com>
# SPDX-FileCopyrightText: 2024 Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
# SPDX-FileCopyrightText: 2024 Piras314 <p1r4s@proton.me>
# SPDX-FileCopyrightText: 2024 Plykiya <58439124+Plykiya@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 PopGamer46 <yt1popgamer@gmail.com>
# SPDX-FileCopyrightText: 2024 Redfire1331 <125223432+Redfire1331@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Rouge2t7 <81053047+Sarahon@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Spessmann <156740760+Spessmann@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Tayrtahn <tayrtahn@gmail.com>
# SPDX-FileCopyrightText: 2024 Truoizys <153248924+Truoizys@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 TsjipTsjip <19798667+TsjipTsjip@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Ubaser <134914314+UbaserB@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Vasilis <vasilis@pikachu.systems>
# SPDX-FileCopyrightText: 2024 Velcroboy <107660393+IamVelcroboy@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 WarMechanic <69510347+WarMechanic@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Winkarst <74284083+Winkarst-cpu@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 beck-thompson <107373427+beck-thompson@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 coolboy911 <85909253+coolboy911@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 deathride58 <deathride58@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 deltanedas <39013340+deltanedas@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 deltanedas <@deltanedas:kde.org>
# SPDX-FileCopyrightText: 2024 eoineoineoin <github@eoinrul.es>
# SPDX-FileCopyrightText: 2024 github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 lapatison <100279397+lapatison@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 lunarcomets <140772713+lunarcomets@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 lzk <124214523+lzk228@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 marbow <152051971+marboww@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 metalgearsloth <comedian_vs_clown@hotmail.com>
# SPDX-FileCopyrightText: 2024 mhamster <81412348+mhamsterr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 neutrino <67447925+neutrino-laser@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 nikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 osjarw <62134478+osjarw@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 plykiya <plykiya@protonmail.com>
# SPDX-FileCopyrightText: 2024 redfire1331 <Redfire1331@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 rosieposie <52761126+rosieposieeee@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 saintmuntzer <47153094+saintmuntzer@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Арт <123451459+JustArt1m@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 War Pigeon <54217755+minus1over12@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 slarticodefast <161409025+slarticodefast@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  id: SignalSwitch
  name: signal switch
  description: It's a switch for toggling power to things.
  placement:
    mode: SnapgridCenter
    snap:
    - Wallmount
  components:
  - type: StationAiWhitelist
  - type: WallMount
    arc: 360
  - type: Clickable
  - type: InteractionOutline
  - type: Physics
    canCollide: false
  - type: Sprite
    drawdepth: SmallObjects
    sprite: Structures/Wallmounts/switch.rsi
    # CorvaxGoob-ButtonsVisuals-Start
    layers:
    - state: dead
    - state: on
      map: ["on"]
      shader: unshaded
    - state: off
      map: ["off"]
      shader: unshaded
  - type: Appearance
  - type: GenericVisualizer
    visuals:
      enum.SignalSwitchVisuals.State:
        off:
          On: { visible: false }
          Off: { visible: true }
        on:
          On: { visible: true }
          Off: { visible: false }
  # CorvaxGoob-ButtonsVisuals-End
  - type: SignalSwitch
  - type: UseDelay
    delay: 0.5 # prevent light-toggling auto-clickers.
  - type: Rotatable
  - type: Construction
    graph: SignalSwitchGraph
    node: SignalSwitchNode
  - type: Fixtures
  - type: DeviceNetwork
    deviceNetId: Wireless
  - type: WirelessNetworkConnection
    range: 200
  - type: DeviceLinkSource
    ports:
    - On
    - Off
    - Status
    lastSignals:
      Status: false
  - type: Tag
    tags:
    - Structure

- type: entity
  id: SignalButton
  name: signal button
  description: It's a button for activating something.
  placement:
    mode: SnapgridCenter
    snap:
    - Wallmount
  components:
  - type: StationAiWhitelist
  - type: WallMount
    arc: 360
  - type: Clickable
  - type: InteractionOutline
  - type: Physics
    canCollide: false
  - type: Sprite
    drawdepth: SmallObjects
    sprite: Structures/Wallmounts/switch.rsi
    state: dead
  - type: UseDelay
    delay: 0.5 # prevent light-toggling auto-clickers.
  - type: SignalSwitch
    onPort: Pressed
    offPort: Pressed
    statusPort: Pressed
  - type: Rotatable
  - type: Construction
    graph: SignalButtonGraph
    node: SignalButtonNode
  - type: Fixtures
  - type: DeviceNetwork
    deviceNetId: Wireless
  - type: WirelessNetworkConnection
    range: 200
  - type: DeviceLinkSource
    ports:
      - Pressed
  - type: Damageable
    damageContainer: Inorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
      - trigger:
          !type:DamageTrigger
          damage: 80
        behaviors:
          - !type:DoActsBehavior
            acts: [ "Destruction" ]
      - trigger:
          !type:DamageTrigger
          damage: 40
        behaviors:
          - !type:DoActsBehavior
            acts: [ "Destruction" ]
          - !type:PlaySoundBehavior
            sound:
              collection: MetalBreak
              params:
                volume: -8
  - type: Tag
    tags:
    - Structure

- type: entity
  id: ApcNetSwitch
  name: apc net switch
  description: It's a switch for toggling lights that are connected to the same apc.
  placement:
    mode: SnapgridCenter
    snap:
      - Wallmount
  components:
    - type: WallMount
      arc: 360
    - type: Clickable
    - type: InteractionOutline
    - type: Physics
      canCollide: false
    - type: Transform
      anchored: true
    - type: Sprite
      drawdepth: SmallObjects
      sprite: Structures/Wallmounts/switch.rsi
      # CorvaxGoob-ButtonsVisuals-End
      layers:
      - state: dead
      - state: on
      # CorvaxGoob-ButtonsVisuals-End
    - type: Rotatable
    - type: ExtensionCableReceiver
    - type: DeviceNetwork
      deviceNetId: Apc
      transmitFrequencyId: SmartLight # assuming people want to use it for light switches.
    - type: ApcNetworkConnection
    - type: ApcNetSwitch
    - type: Construction
      graph: LightSwitchGraph
      node: LightSwitchNode
    - type: Fixtures
    - type: Tag
      tags:
      - Structure

- type: entity
  id: TwoWayLever
  name: two way lever
  description: A two way lever.
  placement:
    mode: SnapgridCenter
  components:
    - type: StationAiWhitelist
    - type: Clickable
    - type: InteractionOutline
    - type: Sprite
      drawdepth: HighFloorObjects
      sprite: Structures/conveyor.rsi
      noRot: true
      layers:
        - state: switch-off
          map: ["enabled", "enum.TwoWayLeverState.Middle"]
    - type: TwoWayLever
    - type: UseDelay
      delay: 0.2 # prevent light-toggling auto-clickers.
    - type: Appearance
    - type: GenericVisualizer
      visuals:
        enum.TwoWayLeverVisuals.State:
          enabled:
            Right: { state: switch-fwd }
            Middle: { state: switch-off }
            Left: { state: switch-rev }
    - type: Damageable
      damageContainer: Inorganic
      damageModifierSet: Metallic
    - type: Destructible
      thresholds:
      - trigger:
          !type:DamageTrigger
          damage: 100
        behaviors:
        - !type:DoActsBehavior
          acts: [ "Destruction" ]
    - type: Construction
      graph: LeverGraph
      node: LeverNode
    - type: DeviceNetwork
      deviceNetId: Wireless
    - type: WirelessNetworkConnection
      range: 200
    - type: DeviceLinkSource
      ports:
        - Left
        - Right
        - Middle
    - type: Tag
      tags:
      - Structure

#directional

- type: entity
  id: SignalSwitchDirectional
  name: signal switch
  suffix: directional
  parent: SignalSwitch
  components:
  - type: WallMount
    arc: 175
  - type: Construction
    graph: SignalSwitchDirectionalGraph
    node: SignalSwitchDirectionalNode

- type: entity
  id: SignalButtonDirectional
  name: signal button
  suffix: directional
  parent: SignalButton
  components:
  - type: WallMount
    arc: 175
  - type: Construction
    graph: SignalButtonDirectionalGraph
    node: SignalButtonDirectionalNode

- type: entity
  id: ApcNetSwitchDirectional
  name: apc net switch
  suffix: directional
  parent: ApcNetSwitch
  components:
  - type: WallMount
    arc: 175
  - type: Construction
    graph: LightSwitchDirectionalGraph
    node: LightSwitchDirectionalNode

# lockable buttons

- type: entity
  id: LockableButton
  name: lockable button
  parent: SignalButtonDirectional
  categories: [ HideSpawnMenu ]
  components:
  - type: Appearance
  - type: Lock
  - type: LockVisuals
  - type: AccessReader
  - type: Sprite
    drawdepth: WallMountedItems
    sprite: Structures/Wallmounts/locked_switch.rsi
    layers:
    - state: base
    - state: locked
      map: ["enum.LockVisualLayers.Lock"]
      shader: unshaded

- type: entity
  id: LockableButtonCaptain
  suffix: Captain
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Captain"]]

- type: entity
  id: LockableButtonHeadOfPersonnel
  suffix: HeadOfPersonnel
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["HeadOfPersonnel"]]

- type: entity
  id: LockableButtonChiefEngineer
  suffix: ChiefEngineer
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["ChiefEngineer"]]

- type: entity
  id: LockableButtonChiefMedicalOfficer
  suffix: ChiefMedicalOfficer
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["ChiefMedicalOfficer"]]

- type: entity
  id: LockableButtonHeadOfSecurity
  suffix: HeadOfSecurity
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["HeadOfSecurity"]]

- type: entity
  id: LockableButtonResearchDirector
  suffix: ResearchDirector
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["ResearchDirector"]]

- type: entity
  id: LockableButtonCommand
  suffix: Command
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Command"]]

- type: entity
  id: LockableButtonCryogenics
  suffix: Cryogenics
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Cryogenics"]]

- type: entity
  id: LockableButtonSecurity
  suffix: Security
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Security"]]

- type: entity
  id: LockableButtonDetective
  suffix: Detective
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Detective"]]

- type: entity
  id: LockableButtonArmory
  suffix: Armory
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Armory"]]

- type: entity
  id: LockableButtonBrig
  suffix: Brig
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Brig"]]

- type: entity
  id: LockableButtonLawyer
  suffix: Lawyer
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Lawyer"]]

- type: entity
  id: LockableButtonEngineering
  suffix: Engineering
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Engineering"]]

- type: entity
  id: LockableButtonMedical
  suffix: Medical
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Medical"]]

- type: entity
  id: LockableButtonQuartermaster
  suffix: Quartermaster
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Quartermaster"]]

- type: entity
  id: LockableButtonSalvage
  suffix: Salvage
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Salvage"]]

- type: entity
  id: LockableButtonCargo
  suffix: Cargo
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Cargo"]]

- type: entity
  id: LockableButtonResearch
  suffix: Research
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Research"]]

- type: entity
  id: LockableButtonService
  suffix: Service
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Service"]]

- type: entity
  id: LockableButtonMaintenance
  suffix: Maintenance
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Maintenance"]]

- type: entity
  id: LockableButtonExternal
  suffix: External
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["External"]]

- type: entity
  id: LockableButtonJanitor
  suffix: Janitor
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Janitor"]]

- type: entity
  id: LockableButtonTheatre
  suffix: Theatre
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Theatre"]]

- type: entity
  id: LockableButtonBar
  suffix: Bar
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Bar"]]

- type: entity
  id: LockableButtonChemistry
  suffix: Chemistry
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Chemistry"]]

- type: entity
  id: LockableButtonKitchen
  suffix: Kitchen
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Kitchen"]]

- type: entity
  id: LockableButtonChapel
  suffix: Chapel
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Chapel"]]

- type: entity
  id: LockableButtonHydroponics
  suffix: Hydroponics
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Hydroponics"]]

- type: entity
  id: LockableButtonAtmospherics
  suffix: Atmospherics
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["Atmospherics"]]

- type: entity
  id: LockableButtonCentcomm
  suffix: CentComm
  parent: LockableButton
  components:
  - type: AccessReader
    access: [["CentralCommand"]]

# button frames

- type: entity
  id: ButtonFrame
  name: button frame
  categories: [ HideSpawnMenu ]
  description: It's a frame to help distinguish switches visually.
  placement:
    mode: SnapgridCenter
    snap:
    - Wallmount
  components:
  - type: Clickable
  - type: WallMount
    arc: 360
  - type: Physics
    canCollide: false
  - type: Sprite
    drawdepth: SmallObjects
    sprite: Structures/Wallmounts/switch_frame.rsi
    state: grey
  - type: Rotatable
  - type: Fixtures

- type: entity
  id: ButtonFrameGrey
  parent: ButtonFrame
  suffix: grey
  components:
  - type: Sprite
    drawdepth: SmallObjects
    sprite: Structures/Wallmounts/switch_frame.rsi
    state: grey

- type: entity
  id: ButtonFrameCaution
  parent: ButtonFrame
  suffix: caution
  components:
  - type: Sprite
    drawdepth: SmallObjects
    sprite: Structures/Wallmounts/switch_frame.rsi
    state: caution

- type: entity
  id: ButtonFrameCautionSecurity
  parent: ButtonFrame
  suffix: caution
  components:
  - type: Sprite
    drawdepth: SmallObjects
    sprite: Structures/Wallmounts/switch_frame.rsi
    state: caution_security

- type: entity
  id: ButtonFrameExit
  parent: ButtonFrame
  suffix: exit
  components:
  - type: Sprite
    drawdepth: SmallObjects
    sprite: Structures/Wallmounts/switch_frame.rsi
    state: exit

- type: entity
  id: ButtonFrameJanitor
  parent: ButtonFrame
  suffix: janitor
  components:
  - type: Sprite
    drawdepth: SmallObjects
    sprite: Structures/Wallmounts/switch_frame.rsi
    state: janitor