# SPDX-FileCopyrightText: 2023 DrSmugleaf <DrSmugleaf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Morb <14136326+Morb0@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 qwerltaz <69696513+qwerltaz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Andrew <blackledgecreates@gmail.com>
# SPDX-FileCopyrightText: 2024 Emisse <99158783+Emisse@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Errant <35878406+Errant-4@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Ilya246 <57039557+Ilya246@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 JustCone <141039037+JustCone14@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2024 Mervill <mervills.email@gmail.com>
# SPDX-FileCopyrightText: 2024 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 PJBot <pieterjan.briers+bot@gmail.com>
# SPDX-FileCopyrightText: 2024 Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
# SPDX-FileCopyrightText: 2024 Piras314 <p1r4s@proton.me>
# SPDX-FileCopyrightText: 2024 PopGamer46 <yt1popgamer@gmail.com>
# SPDX-FileCopyrightText: 2024 Spessmann <156740760+Spessmann@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Tayrtahn <tayrtahn@gmail.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 deltanedas <39013340+deltanedas@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 deltanedas <@deltanedas:kde.org>
# SPDX-FileCopyrightText: 2024 lunarcomets <140772713+lunarcomets@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 lzk <124214523+lzk228@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 saintmuntzer <47153094+saintmuntzer@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Minemoder5000 <minemoder50000@gmail.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  id: BaseIntercom
  name: intercom
  description: An intercom. For when the station just needs to know something.
  abstract: true
  components:
  - type: StationAiWhitelist
  - type: WallMount
  - type: ApcPowerReceiver
  - type: Electrified
    enabled: false
    usesApcPower: true
  - type: TelecomExempt
  - type: EncryptionKeyHolder
    keySlots: 3
    keysExtractionMethod: Prying
  - type: RadioMicrophone
    powerRequired: true
    unobstructedRequired: true
    listenRange: 2
    toggleOnInteract: false
  - type: RadioSpeaker
    toggleOnInteract: false
  - type: ListenBlacklist # Goobstation - its annoying as shit
    blacklist:
      components:
      - Advertise
  - type: Intercom
  - type: Speech
    speechVerb: Robotic
  - type: VoiceOverride # This is for the wire that makes an electricity zapping noise.
    speechVerbOverride: Electricity
    enabled: false
  - type: ExtensionCableReceiver
  - type: Clickable
  - type: InteractionOutline
  - type: Appearance
  - type: WiresVisuals
  - type: WiresPanelSecurity
  - type: ContainerFill
    containers:
      board: [ IntercomElectronics ]
  - type: ContainerContainer
    containers:
      board: !type:Container
      key_slots: !type:Container
  - type: Sprite
    noRot: false
    drawdepth: SmallObjects
    sprite: Structures/Wallmounts/intercom.rsi
    layers:
    - state: base
    - state: unshaded
      map: ["enum.PowerDeviceVisualLayers.Powered"]
      shader: unshaded
    - state: broadcasting
      map: ["enum.RadioDeviceVisualLayers.Broadcasting"]
      shader: unshaded
      visible: false
    - state: speaker
      map: ["enum.RadioDeviceVisualLayers.Speaker"]
      shader: unshaded
      visible: false
    - state: panel
      map: ["enum.WiresVisualLayers.MaintenancePanel"]
      visible: false
  - type: Transform
    noRot: false
    anchored: true
  - type: WiresPanel
  - type: Wires
    boardName: wires-board-name-intercom
    layoutId: Intercom
  - type: ActivatableUIRequiresPower
  - type: ActivatableUI
    key: enum.IntercomUiKey.Key
    singleUser: true
  - type: UserInterface
    interfaces:
      enum.IntercomUiKey.Key:
        type: IntercomBoundUserInterface
      enum.WiresUiKey.Key:
        type: WiresBoundUserInterface
  - type: Construction
    graph: Intercom
    node: intercom
    containers:
    - board
    - key_slots
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: StructuralMetallic
  - type: Destructible
    thresholds:
      - trigger:
          !type:DamageTrigger
          damage: 200
        behaviors:
          - !type:DoActsBehavior
            acts: [ "Destruction" ]
      - trigger:
          !type:DamageTrigger
          damage: 100
        behaviors:
          - !type:DoActsBehavior
            acts: [ "Destruction" ]
          - !type:PlaySoundBehavior
            sound:
              collection: MetalGlassBreak
              params:
                volume: -4
  - type: GenericVisualizer
    visuals:
      enum.WiresVisualLayers.MaintenancePanel:
        enum.WiresVisualLayers.MaintenancePanel:
          True: { visible: true }
          False: { visible: false }
      enum.PowerDeviceVisuals.Powered:
        enum.PowerDeviceVisualLayers.Powered:
          True: { visible: true }
          False: { visible: false }
      enum.RadioDeviceVisuals.Broadcasting:
        enum.RadioDeviceVisualLayers.Broadcasting:
          True: { visible: true }
          False: { visible: false }
      enum.RadioDeviceVisuals.Speaker:
        enum.RadioDeviceVisualLayers.Speaker:
          True: { visible: true }
          False: { visible: false }
  placement:
    mode: SnapgridCenter
    snap:
    - Wallmount

- type: entity
  id: IntercomAssembly
  name: intercom assembly
  description: An intercom. It doesn't seem very helpful right now.
  components:
  - type: WallMount
  - type: Clickable
  - type: InteractionOutline
  - type: Sprite
    drawdepth: SmallObjects
    sprite: Structures/Wallmounts/intercom.rsi
    layers:
    - state: build
    - state: panel
      visible: false
      map: [ "wires" ]
  - type: Appearance
  - type: GenericVisualizer
    visuals:
      enum.ConstructionVisuals.Layer:
        wires:
          0: { visible: false }
          1: { visible: true }
  - type: Construction
    graph: Intercom
    node: assembly
  - type: Transform
    anchored: true
  placement:
    mode: SnapgridCenter
    snap:
    - Wallmount

# this weird inheritance BS exists for construction shitcode
- type: entity
  id: IntercomConstructed
  parent: BaseIntercom
  suffix: Empty, Panel Open
  components:
  - type: Sprite
    layers:
    - state: base
    - state: unshaded
      map: ["enum.PowerDeviceVisualLayers.Powered"]
      shader: unshaded
    - state: broadcasting
      map: ["enum.RadioDeviceVisualLayers.Broadcasting"]
      shader: unshaded
      visible: false
    - state: speaker
      map: ["enum.RadioDeviceVisualLayers.Speaker"]
      shader: unshaded
      visible: false
    - state: panel
      map: ["enum.WiresVisualLayers.MaintenancePanel"]
      visible: true
  - type: WiresPanel
    open: true

- type: entity
  id: Intercom
  parent: IntercomConstructed
  suffix: ""
  components:
  - type: Sprite
    layers:
    - state: base
    - state: unshaded
      map: ["enum.PowerDeviceVisualLayers.Powered"]
      shader: unshaded
    - state: broadcasting
      map: ["enum.RadioDeviceVisualLayers.Broadcasting"]
      shader: unshaded
      visible: false
    - state: speaker
      map: ["enum.RadioDeviceVisualLayers.Speaker"]
      shader: unshaded
      visible: false
    - state: panel
      map: ["enum.WiresVisualLayers.MaintenancePanel"]
  - type: WiresPanel
    open: false

- type: entity
  id: BaseIntercomSecure
  parent: Intercom
  abstract: true
  components:
  - type: WiresPanel
    openDelay: 5
  - type: WiresPanelSecurity
    examine: wires-panel-component-on-examine-security-level2
    wiresAccessible: false
  - type: Construction
    node: intercomReinforced

- type: entity
  id: IntercomCommon
  parent: Intercom
  suffix: Common
  components:
  - type: ContainerFill
    containers:
      board:
      - IntercomElectronics
      key_slots:
      - EncryptionKeyCommon

- type: entity
  id: IntercomCommand
  parent: BaseIntercomSecure
  suffix: Command
  description: An intercom. It's been reinforced with metal.
  components:
  - type: ContainerFill
    containers:
      board:
      - IntercomElectronics
      key_slots:
      - EncryptionKeyCommon
      - EncryptionKeyCommand

- type: entity
  id: IntercomEngineering
  parent: Intercom
  suffix: Engineering
  components:
  - type: ContainerFill
    containers:
      board:
      - IntercomElectronics
      key_slots:
      - EncryptionKeyCommon
      - EncryptionKeyEngineering

- type: entity
  id: IntercomMedical
  parent: Intercom
  suffix: Medical
  components:
  - type: ContainerFill
    containers:
      board:
      - IntercomElectronics
      key_slots:
      - EncryptionKeyCommon
      - EncryptionKeyMedical

- type: entity
  id: IntercomScience
  parent: Intercom
  suffix: Science
  components:
  - type: ContainerFill
    containers:
      board:
      - IntercomElectronics
      key_slots:
      - EncryptionKeyCommon
      - EncryptionKeyScience

- type: entity
  id: IntercomSecurity
  parent: BaseIntercomSecure
  suffix: Security
  description: An intercom. It's been reinforced with metal from security helmets, making it a bitch-and-a-half to open.
  components:
  - type: ContainerFill
    containers:
      board:
      - IntercomElectronics
      key_slots:
      - EncryptionKeyCommon
      - EncryptionKeySecurity

- type: entity
  id: IntercomService
  parent: Intercom
  suffix: Service
  components:
  - type: ContainerFill
    containers:
      board:
      - IntercomElectronics
      key_slots:
      - EncryptionKeyCommon
      - EncryptionKeyService

- type: entity
  id: IntercomSupply
  parent: Intercom
  suffix: Supply
  components:
  - type: ContainerFill
    containers:
      board:
      - IntercomElectronics
      key_slots:
      - EncryptionKeyCommon
      - EncryptionKeyCargo

- type: entity
  id: IntercomAll
  parent: Intercom
  suffix: All
  components:
  - type: ContainerFill
    containers:
      board:
      - IntercomElectronics
      key_slots:
      - EncryptionKeyCommon
      - EncryptionKeyStationMaster

- type: entity
  id: IntercomFreelance
  parent: Intercom
  suffix: Freelance
  components:
  - type: ContainerFill
    containers:
      board:
      - IntercomElectronics
      key_slots:
      - EncryptionKeyCommon
      - EncryptionKeyFreelance
