# SPDX-FileCopyrightText: 2022 Andreas Kämper <andreas@kaemper.tech>
# SPDX-FileCopyrightText: 2022 E F R <602406+Efruit@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Flipp Syder <76629141+vulppine@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Julian Giebel <juliangiebel@live.de>
# SPDX-FileCopyrightText: 2022 Mervill <mervills.email@gmail.com>
# SPDX-FileCopyrightText: 2022 Peptide90 <78795277+Peptide90@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Rane <60792108+Elijahrane@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 metalgearsloth <comedian_vs_clown@hotmail.com>
# SPDX-FileCopyrightText: 2022 vulppine <vulppine@gmail.com>
# SPDX-FileCopyrightText: 2022 wrexbe <81056464+wrexbe@users.noreply.github.com>
# 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: 2024 Ilya246 <57039557+Ilya246@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2024 Piras314 <p1r4s@proton.me>
# SPDX-FileCopyrightText: 2024 chromiumboy <50505512+chromiumboy@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 qwerltaz <69696513+qwerltaz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  parent: BaseWallmountMachine
  id: FireAlarm
  name: fire alarm
  description: A fire alarm. Spicy!
  components:
  - type: LightningTarget
    priority: 0
  - type: Electrified
    enabled: false
    usesApcPower: true
  - type: ExtensionCableReceiver
  - type: DeviceNetwork
    deviceNetId: AtmosDevices
    receiveFrequencyId: AtmosMonitor
    transmitFrequencyId: AtmosMonitor
    prefix: device-address-prefix-fire-alarm
    sendBroadcastAttemptEvent: true
    examinableAddress: true
  - type: DeviceList
  - type: WiredNetworkConnection
  - type: DeviceNetworkRequiresPower
  - type: AtmosDevice
  - type: AtmosAlarmable
    syncWith:
      - FireAlarm
      - AirSensor
      - GasVent
      - GasScrubber
    monitorAlertTypes:
      - Temperature
  - type: AtmosAlarmableVisuals
    layerMap: "fireAlarmState"
    alarmStates:
      Normal: fire_off
      Warning: fire_off # shouldn't be alarming at a warning
      Danger: fire_on
      Emagged: fire_emagged
    hideOnDepowered: [ "fireAlarmState" ]
  - type: Tag
    tags:
      - FireAlarm
  - type: FireAlarm
  - type: AtmosAlertsDevice
    group: FireAlarm
  - type: ContainerFill
    containers:
      board: [ FireAlarmElectronics ]
  - type: ContainerContainer
    containers:
      board: !type:Container
  - type: Appearance
  - type: WiresVisuals
  - type: AlertLevelDisplay
    alertVisuals:
      green: fire_0
      blue: fire_1
      red: fire_2
      violet: fire_1
      yellow: fire_1
      delta: fire_3
  - type: UserInterface
    interfaces:
      enum.WiresUiKey.Key:
        type: WiresBoundUserInterface
  - type: WiresPanel
  - type: Wires
    boardName: wires-board-name-firealarm
    layoutId: FireAlarm
  - type: Sprite
    sprite: Structures/Wallmounts/air_monitors.rsi
    layers:
    - state: fire0
      map: ["fireAlarmBase"]
    - state: fire_off
      map: ["fireAlarmState"]
    - state: fire_b2
      map: ["enum.WiresVisualLayers.MaintenancePanel"]
  - type: Transform
    anchored: true
  - type: Construction
    graph: FireAlarm
    node: fire_alarm
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Metallic
  - type: GuideHelp
    guides:
    - Networking
  - type: Destructible
    thresholds:
      - trigger:
          !type:DamageTrigger
          damage: 160
        behaviors:
          - !type:DoActsBehavior
            acts: [ "Destruction" ]
      - trigger:
          !type:DamageTrigger
          damage: 80
        behaviors:
          - !type:DoActsBehavior
            acts: [ "Destruction" ]
          - !type:PlaySoundBehavior
            sound:
              collection: MetalGlassBreak
              params:
                volume: -4
  - type: StationAiWhitelist

- type: entity
  parent: BaseWallmountMetallic
  id: FireAlarmAssembly
  name: fire alarm assembly
  description: A fire alarm assembly. Very mild.
  components:
  - type: Sprite
    sprite: Structures/Wallmounts/air_monitors.rsi
    layers:
    - state: fire_b1
      map: [ "enum.ConstructionVisuals.Layer" ]
  - type: Appearance
  - type: GenericVisualizer
    visuals:
      enum.ConstructionVisuals.Key:
        enum.ConstructionVisuals.Layer:
          assembly: { state: fire_b1 }
          electronics: { state: fire_b2 }
  - type: Construction
    graph: FireAlarm
    node: assembly
  - type: Destructible
    thresholds:
      - trigger:
          !type:DamageTrigger
          damage: 20
        behaviors:
          - !type:DoActsBehavior
            acts: [ "Destruction" ]
      - trigger:
          !type:DamageTrigger
          damage: 15
        behaviors:
          - !type:DoActsBehavior
            acts: [ "Destruction" ]
          - !type:PlaySoundBehavior
            sound:
              collection: MetalGlassBreak
              params:
                volume: -4

- type: entity
  id: FireAlarmXeno
  parent: FireAlarm
  name: fire alarm
  description: An alien fire alarm. Works just the same!
  components:
  - type: Sprite
    sprite: Structures/Wallmounts/air_monitors_xeno.rsi
    layers:
    - state: fire0
      map: ["fireAlarmBase"]
    - state: fire_off
      map: ["fireAlarmState"]
    - state: fire_b2
      map: ["enum.WiresVisualLayers.MaintenancePanel"]
    - type: Construction

- type: entity
  id: FireAlarmAssemblyXeno
  parent: FireAlarmAssembly
  name: fire alarm assembly
  description: An alien fire alarm assembly. Good luck with the wires.
  components:
  - type: Sprite
    sprite: Structures/Wallmounts/air_monitors_xeno.rsi
    layers:
    - state: fire_b1
      map: [ "enum.ConstructionVisuals.Layer" ]
  - type: Construction
