# SPDX-FileCopyrightText: 2021 20kdc <asdd2808@gmail.com>
# SPDX-FileCopyrightText: 2021 Julian Giebel <j.giebel@netrocks.info>
# SPDX-FileCopyrightText: 2021 Julian Giebel <juliangiebel@live.de>
# SPDX-FileCopyrightText: 2021 Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
# SPDX-FileCopyrightText: 2021 Swept <sweptwastaken@protonmail.com>
# SPDX-FileCopyrightText: 2022 Alex Evgrashin <aevgrashin@yandex.ru>
# SPDX-FileCopyrightText: 2022 ElectroJr <leonsfriedrich@gmail.com>
# SPDX-FileCopyrightText: 2022 Kai Shiba <100050424+KaiShibaa@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Mervill <mervills.email@gmail.com>
# SPDX-FileCopyrightText: 2022 Peptide90 <78795277+Peptide90@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 T-Stalker <43253663+DogZeroX@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 T-Stalker <le0nel_1van@hotmail.com>
# SPDX-FileCopyrightText: 2022 metalgearsloth <metalgearsloth@gmail.com>
# SPDX-FileCopyrightText: 2022 themias <89101928+themias@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Alekshhh <44923899+Alekshhh@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Doru991 <75124791+Doru991@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 DrSmugleaf <DrSmugleaf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 MilenVolf <63782763+MilenVolf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Segonist <74138556+Segonist@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 TemporalOroboros <TemporalOroboros@gmail.com>
# SPDX-FileCopyrightText: 2023 deltanedas <39013340+deltanedas@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 deltanedas <@deltanedas:kde.org>
# SPDX-FileCopyrightText: 2023 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Cojoke <83733158+Cojoke-dot@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Ed <96445749+TheShuEd@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2024 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Tayrtahn <tayrtahn@gmail.com>
# SPDX-FileCopyrightText: 2024 gluesniffler <159397573+gluesniffler@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 lapatison <100279397+lapatison@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 metalgearsloth <comedian_vs_clown@hotmail.com>
# SPDX-FileCopyrightText: 2024 yglop <95057024+yglop@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <aiden@djkraz.com>
# SPDX-FileCopyrightText: 2025 Aviu00 <93730715+Aviu00@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 BombasterDS <115770678+BombasterDS@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 BombasterDS <deniskaporoshok@gmail.com>
# SPDX-FileCopyrightText: 2025 BombasterDS2 <shvalovdenis.workmail@gmail.com>
# SPDX-FileCopyrightText: 2025 CerberusWolfie <wb.johnb.willis@gmail.com>
# SPDX-FileCopyrightText: 2025 Eris <eris@erisws.com>
# SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
# SPDX-FileCopyrightText: 2025 John Willis <143434770+CerberusWolfie@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 RatherUncreative <RatherUncreativeName@proton.me>
# SPDX-FileCopyrightText: 2025 Ted Lukin <66275205+pheenty@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 pheenty <fedorlukin2006@gmail.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  abstract: true
  parent: [BaseMachinePowered, ConstructibleMachine]
  id: BaseRecharger
  placement:
    mode: SnapgridCenter
  components:
  - type: Transform
    anchored: true
    noRot: false
  - type: Sprite
    snapCardinals: true
  - type: Appearance
  - type: Charger
    slotId: charger_slot
  - type: Anchorable
    delay: 1
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 80
      behaviors:
      - !type:DoActsBehavior
        acts: ["Destruction"]
    - trigger:
        !type:DamageTrigger
        damage: 40
      behaviors:
      - !type:EmptyAllContainersBehaviour
      - !type:DoActsBehavior
        acts: ["Destruction"]
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
  - type: StaticPrice
    price: 75

- type: entity
  abstract: true
  parent: BaseRecharger
  id: BaseItemRecharger
  components:
  - type: Sprite
    drawdepth: SmallObjects
    layers:
    - map: ["enum.PowerChargerVisualLayers.Base"]
      state: "empty"
    - map: ["enum.PowerChargerVisualLayers.Light"]
      state: "light-off"
      shader: "unshaded"
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.10,-0.10,0.10,0.10"
        density: 500
        mask:
        - TabletopMachineMask
        layer:
        - BulletImpassable
  - type: PowerChargerVisuals
  - type: ContainerContainer
    containers:
      charger_slot: !type:ContainerSlot
      machine_board: !type:Container
      machine_parts: !type:Container
  - type: RequireProjectileTarget

- type: entity
  parent: BaseItemRecharger
  id: PowerCellRecharger
  name: cell recharger
  components:
  - type: Sprite
    sprite: Structures/Power/cell_recharger.rsi
    layers:
    - map: ["enum.PowerChargerVisualLayers.Base"]
      state: "empty"
    - map: ["enum.PowerChargerVisualLayers.Light"]
      state: "light-off"
      shader: "unshaded"
    - state: open
      map: ["enum.WiresVisualLayers.MaintenancePanel"]
      visible: false
  - type: Machine
    board: CellRechargerCircuitboard
  - type: WiresPanel
  - type: GenericVisualizer
    visuals:
      enum.WiresVisuals.MaintenancePanelState:
        enum.WiresVisualLayers.MaintenancePanel:
          True: { visible: true }
          False: { visible: false }
  - type: PowerCellSlot
    cellSlotId: charger_slot
    # fitsInCharger is true i dont think this will ever affect anything negatively but it lets it function
  - type: ItemSlots
    slots:
      charger_slot:
        ejectOnInteract: true
        name: power-cell-slot-component-slot-name-default
        whitelist:
          tags:
          - PowerCell
          - PowerCellSmall

- type: entity
  parent: [ BaseItemRecharger, ConstructibleMachine ]
  id: PowerCageRecharger
  name: cage recharger
  components:
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.25,-0.35,0.25,0.35"
        density: 190
        mask:
        - MachineMask
        layer:
        - MachineLayer
  - type: LitOnPowered
  - type: PointLight
    radius: 1.5
    color: "#03fc4e"
    energy: 0.7
  - type: Charger
    chargeRate: 50
  - type: Sprite
    sprite: Structures/Power/cage_recharger.rsi
  - type: PowerCellSlot
    cellSlotId: charger_slot
  - type: ItemSlots
    slots:
      charger_slot:
        ejectOnInteract: true
        name: Power cage
        whitelist:
          tags:
          - PowerCage
  - type: Machine
    board: PowerCageRechargerCircuitboard
  - type: StaticPrice
    price: 500

- type: entity
  parent: BaseItemRecharger
  id: WeaponCapacitorRecharger
  name: recharger
  components:
  - type: Sprite
    sprite: Structures/Power/recharger.rsi
    layers:
    # WWDP Edit begin
    - map: ["enum.PowerChargerVisualLayers.Base"]
      state: "empty"
    - map: ["enum.PowerChargerVisualLayers.Light"]
      state: "light-off"
      shader: "unshaded"
    - map: ["enum.PowerChargerVisualLayers.ItemDisplay"]
      shader: "FlickerHologram"
      color: "#ffffffaa"
      offset: 0,0.45
      scale: 0.5,0.5
    # WWDP Edit end
  - type: Machine
    board: WeaponCapacitorRechargerCircuitboard
  # no powercellslot since stun baton etc arent powercells
  - type: ItemSlots
    slots:
      charger_slot:
        ejectOnInteract: true
        whitelist:
          components:
          - HitscanBatteryAmmoProvider
          - ProjectileBatteryAmmoProvider
          - Stunbaton
        # Goobstation
          tags:
          - FitsInCharger
        blacklist:
          tags:
          - WizardWand
          components:
          - MaterialEnergy
  - type: ItemSlotRenderer # WWDP
    mapping:
      charger_slot: enum.PowerChargerVisualLayers.ItemDisplay

- type: entity
  parent: BaseItemRecharger
  id: TurboItemRecharger
  name: turbo recharger
  description: An overclocked recharger that's been adapted with a global port.
  components:
  - type: Sprite
    sprite: Structures/Power/turbo_recharger.rsi
    layers:
    # WWDP Edit begin
    - map: ["enum.PowerChargerVisualLayers.Base"]
      state: "empty"
    - map: ["enum.PowerChargerVisualLayers.Light"]
      state: "light-off"
      shader: "unshaded"
    - map: ["enum.PowerChargerVisualLayers.ItemDisplay"]
      shader: "FlickerHologram"
      color: "#ffffffaa"
      offset: 0,0.45
      scale: 0.5,0.5
    # WWDP Edit end
  - type: Machine
    board: TurboItemRechargerCircuitboard
  - type: Charger
    chargeRate: 100
  - type: ItemSlots
    slots:
      charger_slot:
        ejectOnInteract: true
        whitelist:
          components:
          - HitscanBatteryAmmoProvider
          - ProjectileBatteryAmmoProvider
          - Stunbaton
          - PowerCell
          tags:
          - FitsInCharger # Goobstation
        blacklist:
          tags:
          - PotatoBattery
          - WizardWand # Goobstation
          components:  # Goobstation
          - MaterialEnergy
  - type: ItemSlotRenderer # WWDP
    mapping:
      charger_slot: enum.PowerChargerVisualLayers.ItemDisplay

- type: entity
  parent: BaseItemRecharger
  id: WallWeaponCapacitorRecharger
  name: wall recharger
  components:
  - type: Sprite
    sprite: Structures/Power/wall_recharger.rsi
    layers:
    - map: ["enum.PowerChargerVisualLayers.Base"]
      state: "empty"
    - map: ["enum.PowerChargerVisualLayers.Light"]
      state: "light-off"
      shader: "unshaded"
      # WWDP Edit begin
    - map: ["enum.PowerChargerVisualLayers.ItemDisplay"]
      shader: "FlickerHologram"
      color: "#ffffffaa"
      offset: 0,0.45
      scale: 0.5,0.5
      # WWDP Edit end
  - type: WallMount
  - type: Charger
    chargeRate: 25
  - type: ItemSlots
    slots:
      charger_slot:
        ejectOnInteract: true
        whitelist:
          components:
          - HitscanBatteryAmmoProvider
          - ProjectileBatteryAmmoProvider
          - Stunbaton
        blacklist:  # Goobstation
          tags:
          - WizardWand
  - type: ItemSlotRenderer # WWDP
    mapping:
      charger_slot: enum.PowerChargerVisualLayers.ItemDisplay

- type: entity
  parent: BaseRecharger
  id: BorgCharger
  name: cyborg recharging station
  description: A stationary charger for various robotic and cyborg entities. Surprisingly spacious.
  components:
  - type: Sprite
    sprite: Structures/Power/borg_charger.rsi
    layers:
      - state: borgcharger-u1
        map: ["base"]
      - state: borgcharger0
        map: ["enum.PowerDeviceVisualLayers.Powered"]
        shader: "unshaded"
      - state: borgcharger1
        map: ["charged"]
        shader: "unshaded"
        visible: false
      - state: borgdecon1
        map: ["enum.WiresVisualLayers.MaintenancePanel"]
        visible: false
  - type: Charger
    chargeRate: 30
    slotId: entity_storage
    whitelist:
      components:
      - BorgChassis
      - Silicon # EE IPCs
      - Inventory #Goobstation - Modsuits
  - type: Construction
    containers:
    - machine_parts
    - machine_board
    - entity_storage
  - type: WiresPanel
  - type: WiresVisuals
  - type: Machine
    board: BorgChargerCircuitboard
  - type: GenericVisualizer
    visuals:
      enum.StorageVisuals.Open:
        base:
          True: { state: borgcharger-u0 }
          False: { state: borgcharger-u1 }
        enum.PowerDeviceVisualLayers.Powered:
          True: { state: borgcharger0 }
          False: { state: borgcharger2 }
        charged:
          True: { visible: false }
          False: { visible: true }
      enum.PowerDeviceVisuals.Powered:
        enum.PowerDeviceVisualLayers.Powered:
          True: { visible: true }
          False: { visible: false }
        charged:
          True: { visible: true }
          False: { visible: false }
      enum.CellVisual.Light:
        charged:
          Off: { visible: false }
          Empty: { visible: false }
          Charging:
            visible: true
            state: borgcharger3
          Charged:
            visible: true
            state: borgcharger1
  - type: EntityStorage
    capacity: 1
    whitelist:
      components:
      - BorgChassis
      - Silicon #Goobstation, allows IPCs to use cyborg chargers
      - Inventory # Goobstation - Modsuits/Augments
  - type: ContainerContainer
    containers:
      entity_storage: !type:Container
      machine_board: !type:Container
      machine_parts: !type:Container
