# SPDX-FileCopyrightText: 2020 Exp <theexp111@gmail.com>
# SPDX-FileCopyrightText: 2020 L.E.D <10257081+unusualcrow@users.noreply.github.com>
# SPDX-FileCopyrightText: 2020 Peter Wedder <burneddi@gmail.com>
# SPDX-FileCopyrightText: 2020 Remie Richards <remierichards@gmail.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: 2020 Ygg01 <daniel.fath7@gmail.com>
# SPDX-FileCopyrightText: 2020 juliangiebel <juliangiebel@live.de>
# SPDX-FileCopyrightText: 2020 lajolico <55922029+lajolico@users.noreply.github.com>
# SPDX-FileCopyrightText: 2020 unusualcrow <unusualcrow@protonmail.com>
# SPDX-FileCopyrightText: 2021 20kdc <asdd2808@gmail.com>
# SPDX-FileCopyrightText: 2021 Acruid <shatter66@gmail.com>
# SPDX-FileCopyrightText: 2021 Alex Evgrashin <aevgrashin@yandex.ru>
# SPDX-FileCopyrightText: 2021 DrSmugleaf <DrSmugleaf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Flipp Syder <76629141+vulppine@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Julian Giebel <j.giebel@netrocks.info>
# SPDX-FileCopyrightText: 2021 Julian Giebel <juliangiebel@live.de>
# SPDX-FileCopyrightText: 2021 Metal Gear Sloth <metalgearsloth@gmail.com>
# SPDX-FileCopyrightText: 2021 Paul <ritter.paul1+git@googlemail.com>
# SPDX-FileCopyrightText: 2021 Paul Ritter <ritter.paul1@googlemail.com>
# SPDX-FileCopyrightText: 2021 Peptide90 <78795277+Peptide90@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
# SPDX-FileCopyrightText: 2021 Pieter-Jan Briers <pieterjan.briers@gmail.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 <zddm@outlook.es>
# SPDX-FileCopyrightText: 2021 Visne <39844191+Visne@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 metalgearsloth <comedian_vs_clown@hotmail.com>
# SPDX-FileCopyrightText: 2021 mirrorcult <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2021 py01 <60152240+collinlunn@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 py01 <pyronetics01@gmail.com>
# SPDX-FileCopyrightText: 2022 Jacob Tong <10494922+ShadowCommander@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Júlio César Ueti <52474532+Mirino97@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: 2023 AJCM-git <60196617+AJCM-git@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 lzk <124214523+lzk228@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2024 chromiumboy <50505512+chromiumboy@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-License-Identifier: AGPL-3.0-or-later

- type: entity
  abstract: true
  id: CableBase
  placement:
    mode: SnapgridCenter
  components:
  - type: Visibility
    layer: 1
  - type: Cable
    cuttingDelay: 1
  - type: Clickable
  - type: InteractionOutline
  - type: Transform
    anchored: true
    noRot: true
  # TODO: Remove both of these, same with CollideOnAnchor
  - type: Physics
    bodyType: Static
    canCollide: false
  - type: Fixtures
  - type: Sprite
    drawdepth: ThinWire
    visible: false
  - type: Damageable
    damageContainer: Inorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:DoActsBehavior
        acts: ["Destruction"]
  - type: SubFloorHide
  - type: CollideOnAnchor
  - type: Appearance
  - type: Electrified
    onHandInteract: false
    onInteractUsing: false # wire-cutting handled separately.
    onBump: false
    requirePower: true
    highVoltageNode: power
    mediumVoltageNode: power
    lowVoltageNode: power
  - type: CableVis
    node: power
  - type: RCDDeconstructable
    cost: 2
    delay: 0
    fx: EffectRCDConstruct0

- type: entity
  parent: CableBase
  id: CableHV
  name: HV power cable
  description: An orange high voltage power cable.
  components:
  - type: Sprite
    sprite: Structures/Power/Cables/hv_cable.rsi
    state: hvcable_0
    drawdepth: ThickWire
  - type: Icon
    sprite: Structures/Power/Cables/hv_cable.rsi
    state: hvcable_4
  - type: NodeContainer
    nodes:
      power:
        !type:CableNode
        nodeGroupID: HVPower
  - type: Cable
    cableDroppedOnCutPrototype: CableHVStack1
    cableType: HighVoltage
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors: #excess damage (nuke?). avoid computational cost of spawning entities.
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          CableHVStack1:
            min: 1
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: CableVisualizer
    statePrefix: hvcable_
  # TODO make this change on power
  - type: AmbientSound
    enabled: false
    volume: -14
    range: 2
    sound:
      path: /Audio/Ambience/Objects/emf_buzz.ogg

- type: entity
  id: CableHVUncuttable
  parent: CableHV
  suffix: uncuttable
  components:
  - type: Cable
    cuttingQuality: null

- type: entity
  parent: CableBase
  id: CableMV
  name: MV power cable
  description: A medium voltage power cable.
  components:
  - type: Sprite
    sprite: Structures/Power/Cables/mv_cable.rsi
    layers:
    - state: mvcable_0
      color: Yellow
    - state: mvstripes_0
  - type: Icon
    sprite: Structures/Power/Cables/mv_cable.rsi
    state: mvcable_4
  - type: NodeContainer
    nodes:
      power:
        !type:CableNode
        nodeGroupID: MVPower
  - type: Cable
    cableDroppedOnCutPrototype: CableMVStack1
    cableType: MediumVoltage
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors: #excess damage (nuke?). avoid computational cost of spawning entities.
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          CableMVStack1:
            min: 1
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: CableVisualizer
    statePrefix: mvcable_
    extraLayerPrefix: mvstripes_

- type: entity
  id: CableMVUncuttable
  parent: CableMV
  suffix: uncuttable
  components:
  - type: Cable
    cuttingQuality: null

- type: entity
  parent: CableBase
  id: CableApcExtension
  name: LV power cable
  description: A cable used to connect machines to an APC. #APCs aren't area defined anymore so need this cable to connect things to the APC. This description should be dynamic in future.
  components:
  - type: Sprite
    color: Green
    sprite: Structures/Power/Cables/lv_cable.rsi
    state: lvcable_0
  - type: Icon
    sprite: Structures/Power/Cables/lv_cable.rsi
    state: lvcable_4
  - type: NodeContainer
    nodes:
      power:
        !type:CableNode
        nodeGroupID: Apc
  - type: PowerProvider
    voltage: Apc
  - type: ExtensionCableProvider
  - type: Cable
    cableDroppedOnCutPrototype: CableApcStack1
    cableType: Apc
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors: #excess damage (nuke?). avoid computational cost of spawning entities.
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          CableApcStack1:
            min: 1
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: CableVisualizer
    statePrefix: lvcable_

- type: entity
  id: CableApcExtensionUncuttable
  parent: CableApcExtension
  suffix: uncuttable
  components:
  - type: Cable
    cuttingQuality: null