- type: entity
  parent: [ BaseWallmount, StructureHealthMachineWeak ]
  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: 3.0
    color: "#3db83b"
    castShadows: false
    netsync: false
  - type: AccessReader
    access: [["Engineering"]]
  - type: Sprite
    drawdepth: WallMountedItems
    sprite: Structures/Wallmounts/apc.rsi
    offset: 0, -0.25
    layers:
    - state: base
    - state: panel
      map: ["enum.WiresVisualLayers.MaintenancePanel"]
      visible: false
    - state: display-charging
      shader: unshaded
      map: ["enum.ApcVisualLayers.ChargeState"]
    - state: channel-on
      shader: unshaded
      map: ["enum.ApcVisualLayers.Equipment"]
      visible: false
  - type: Appearance
  - type: ApcVisuals
  - type: Battery
    # Very important:
    # Disable networking to prevent the battery getting continuously dirtied every tick as it interacts with the power network.
    # This can not be done by changing the charge rate as the power supply ramps up over time.
    # This disables prediction for this battery.
    netsync: false
    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/Wallmounts/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
    damageModifierSet: SteelMod
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          SheetSteel1:
            min: 0
            max: 2
      - !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: PowerGridCheckNotify
  - type: GuideHelp
    guides:
    - VoltageNetworks
    - Power

# APC under construction
- type: entity
  parent: [ BaseWallmountMetallic, StructureHealthMachineFlimsy ]
  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: Sprite
    sprite: Structures/Wallmounts/apc.rsi
    state: frame
  - type: Construction
    graph: APC
    node: apcFrame
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          SheetSteel1:
            min: 0
            max: 2
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
# 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: entity
  parent: BaseAPC
  id: APCHighCapacity
  suffix: High Capacity, 100kJ
  components:
  - type: Battery
    maxCharge: 100000
    startingCharge: 100000

- type: entity
  parent: BaseAPC
  id: APCSuperCapacity
  suffix: Super Capacity, 150kJ
  components:
  - type: Battery
    maxCharge: 150000
    startingCharge: 150000

- type: entity
  parent: BaseAPC
  id: APCHyperCapacity
  suffix: Hyper Capacity, 200kJ
  components:
  - type: Battery
    maxCharge: 200000
    startingCharge: 200000

- type: entity
  parent: BaseAPC
  id: APCXenoborg
  suffix: Basic, 50kJ, Xenoborg
  components:
  - type: Battery
    maxCharge: 50000
    startingCharge: 50000
  - type: AccessReader
    access: [["Xenoborg"]]
