# SPDX-FileCopyrightText: 2021 20kdc <asdd2808@gmail.com>
# SPDX-FileCopyrightText: 2021 Acruid <shatter66@gmail.com>
# SPDX-FileCopyrightText: 2021 Julian Giebel <j.giebel@netrocks.info>
# SPDX-FileCopyrightText: 2021 Julian Giebel <juliangiebel@live.de>
# SPDX-FileCopyrightText: 2021 Swept <sweptwastaken@protonmail.com>
# SPDX-FileCopyrightText: 2021 Vera Aguilera Puerto <gradientvera@outlook.com>
# SPDX-FileCopyrightText: 2022 CommieFlowers <rasmus.cedergren@hotmail.com>
# SPDX-FileCopyrightText: 2022 Jacob Tong <10494922+ShadowCommander@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Moony <moonheart08@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Paul Ritter <ritter.paul1@googlemail.com>
# SPDX-FileCopyrightText: 2022 Peptide90 <78795277+Peptide90@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Visne <39844191+Visne@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 mirrorcult <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2022 rolfero <45628623+rolfero@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Cody ~ Aexxie <125095677+Aexxie@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 DrSmugleaf <DrSmugleaf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Ed <96445749+TheShuEd@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 Slava0135 <40753025+Slava0135@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 TemporalOroboros <TemporalOroboros@gmail.com>
# SPDX-FileCopyrightText: 2023 Tom Leys <tom@crump-leys.com>
# SPDX-FileCopyrightText: 2023 chromiumboy <50505512+chromiumboy@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 metalgearsloth <comedian_vs_clown@hotmail.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 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 Plykiya <58439124+Plykiya@users.noreply.github.com>
# 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 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 eoineoineoin <github@eoinrul.es>
# SPDX-FileCopyrightText: 2024 gluesniffler <159397573+gluesniffler@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 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 plykiya <plykiya@protonmail.com>
# SPDX-FileCopyrightText: 2024 saintmuntzer <47153094+saintmuntzer@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
  categories: [ HideSpawnMenu ]
  id: BaseAPC
  name: APC
  description: A control terminal for the area's electrical systems.
  placement:
    mode: SnapgridCenter
  components:
  - type: StationAiWhitelist
  - type: AmbientOnPowered
  - type: AmbientSound
    volume: -9
    range: 2
    sound:
      path: /Audio/Ambience/Objects/hdd_buzz.ogg
  - type: PointLight
    radius: 1.5
    energy: 1.6
    color: "#3db83b"
    castShadows: false
    netsync: false
  - type: Clickable
  - type: AccessReader
    access: [["Engineering"]]
  - type: InteractionOutline
  - type: Transform
    anchored: true
  - type: Sprite
    drawdepth: WallMountedItems
    sprite: Structures/Power/apc.rsi
    layers:
    - state: base
    - state: panel
      map: ["enum.WiresVisualLayers.MaintenancePanel"]
      visible: false
    - state: display-charging
      shader: unshaded
      map: ["enum.ApcVisualLayers.ChargeState"]
    - state: lock0-locked
      shader: unshaded
      map: ["enum.ApcVisualLayers.InterfaceLock"]
      visible: false
    - state: lock1-locked
      shader: unshaded
      map: ["enum.ApcVisualLayers.PanelLock"]
      visible: false
    - state: lock1-locked #when these are implemented get actual sprites.
      shader: unshaded
      map: ["enum.ApcVisualLayers.Equipment"]
      visible: false
    - state: lock1-locked
      shader: unshaded
      map: ["enum.ApcVisualLayers.Lighting"]
      visible: false
    - state: lock1-locked
      shader: unshaded
      map: ["enum.ApcVisualLayers.Environment"]
      visible: false
  - type: Appearance
  - type: ApcVisuals
  - type: Battery
    maxCharge: 50000
    startingCharge: 0
  - type: ExaminableBattery
  - type: NodeContainer
    examinable: true
    nodes:
      input:
        !type:CableDeviceNode
        nodeGroupID: MVPower
      output:
        !type:CableDeviceNode
        nodeGroupID: Apc
  - type: PowerMonitoringDevice
    group: APC
    sourceNode: input
    loadNode: output
    collectionName: apc
    sprite: Structures/Power/apc.rsi
    state: static
  - type: BatteryCharger
    voltage: Medium
  - type: PowerProvider
    voltage: Apc
  - type: Apc
    voltage: Apc
  - type: ExtensionCableProvider
  - type: UserInterface
    interfaces:
      enum.ApcUiKey.Key:
        type: ApcBoundUserInterface
      enum.WiresUiKey.Key:
        type: WiresBoundUserInterface
  - type: ActivatableUI
    inHandsOnly: false
    key: enum.ApcUiKey.Key
  - type: Construction
    graph: APC
    node: apc
  - type: PowerNetworkBattery
    maxSupply: 10000
    maxChargeRate: 5000
    supplyRampTolerance: 1000
    supplyRampRate: 500
  - type: WallMount
  - type: WiresPanel
  - type: Wires
    alwaysRandomize: true
    boardName: wires-board-name-apc
    layoutId: APC
  - type: WiresVisuals
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: StructuralMetallicStrong
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 200
      behaviors: #excess damage, don't spawn entities.
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
      - !type:PlaySoundBehavior
        sound:
          collection: MetalGlassBreak
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          SheetSteel1:
            min: 1
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
      - !type:PlaySoundBehavior
        sound:
          collection: MetalGlassBreak
  - type: StationInfiniteBatteryTarget
  - type: Electrified
    onHandInteract: false
    onInteractUsing: false
    onBump: false
    requirePower: true
    mediumVoltageNode: input
    lowVoltageNode: output
  - type: LightningTarget
    priority: 1
  - type: StaticPrice
    price: 500
  - type: GuideHelp
    guides:
    - VoltageNetworks
    - Power
  - type: BatteryDrinkerSource # EE IPCs
    maxAmount: 10000

# APC under construction
- type: entity
  categories: [ HideSpawnMenu ]
  id: APCFrame
  name: APC frame
  description: A control terminal for the area's electrical systems, lacking the electronics.
  placement:
    mode: SnapgridCenter
  components:
  - type: Clickable
  - type: InteractionOutline
  - type: Transform
    anchored: true
  - type: Sprite
    drawdepth: WallMountedItems
    sprite: Structures/Power/apc.rsi
    state: frame
  - type: Construction
    graph: APC
    node: apcFrame
  - type: WallMount
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: StructuralMetallic
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 200
      behaviors: #excess damage, don't spawn entities.
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          SheetSteel1:
            min: 1
            max: 1
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
      - !type:DoActsBehavior
        acts: [ "Destruction" ]

# Constructed APC
- type: entity
  parent: BaseAPC
  id: APCConstructed
  suffix: Open
  components:
  - type: WiresPanel
    open: true

# APCs in use
- type: entity
  parent: BaseAPC
  id: APCBasic
  suffix: Basic, 50kJ
  components:
  - type: Battery
    maxCharge: 50000
    startingCharge: 50000
  - type: BatteryDrinkerSource # EE IPCs
    maxAmount: 5000

- type: entity
  parent: BaseAPC
  id: APCHighCapacity
  suffix: High Capacity, 100kJ
  components:
  - type: Battery
    maxCharge: 100000
    startingCharge: 100000
  - type: BatteryDrinkerSource # EE IPCs
    maxAmount: 12000

- type: entity
  parent: BaseAPC
  id: APCSuperCapacity
  suffix: Super Capacity, 150kJ
  components:
  - type: Battery
    maxCharge: 150000
    startingCharge: 150000
  - type: BatteryDrinkerSource # EE IPCs
    maxAmount: 18000

- type: entity
  parent: BaseAPC
  id: APCHyperCapacity
  suffix: Hyper Capacity, 200kJ
  components:
  - type: Battery
    maxCharge: 200000
    startingCharge: 200000
  - type: BatteryDrinkerSource # EE IPCs
    maxAmount: 26000