# SPDX-FileCopyrightText: 2021 20kdc <asdd2808@gmail.com>
# SPDX-FileCopyrightText: 2021 Acruid <shatter66@gmail.com>
# SPDX-FileCopyrightText: 2021 Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
# SPDX-FileCopyrightText: 2021 Swept <sweptwastaken@protonmail.com>
# SPDX-FileCopyrightText: 2021 mirrorcult <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2022 Jacob Tong <10494922+ShadowCommander@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Martin Petkovski <63034378+martin69420@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Peptide90 <78795277+Peptide90@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Profane McBane <profanedbane+github@gmail.com>
# SPDX-FileCopyrightText: 2022 Vera Aguilera Puerto <gradientvera@outlook.com>
# SPDX-FileCopyrightText: 2022 keronshb <54602815+keronshb@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 metalgearsloth <comedian_vs_clown@hotmail.com>
# SPDX-FileCopyrightText: 2023 778b <33431126+778b@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Tom Leys <tom@crump-leys.com>
# SPDX-FileCopyrightText: 2023 chromiumboy <50505512+chromiumboy@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 Cojoke <83733158+Cojoke-dot@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Ilya246 <57039557+Ilya246@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2024 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Plykiya <58439124+Plykiya@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 plykiya <plykiya@protonmail.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 CaasGit <87243814+CaasGit@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Fishbait <Fishbait@git.ml>
# SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
# SPDX-FileCopyrightText: 2025 Ilya246 <ilyukarno@gmail.com>
# SPDX-FileCopyrightText: 2025 fishbait <gnesse@gmail.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  id: SolarPanelBasePhysSprite
  categories: [ HideSpawnMenu ]
  name: solar panel
  placement:
    mode: SnapgridCenter
  components:
  - type: MeleeSound
    soundGroups:
      Brute:
        collection: GlassSmash
  - type: Clickable
  - type: InteractionOutline
  - type: Transform
    anchored: true
  - type: Physics
    bodyType: Static
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.45,-0.1,0.45,0.1"
        density: 550
        mask:
        - MachineMask
        layer:
        - MidImpassable, LowImpassable, BulletImpassable
  - type: Sprite
    sprite: Structures/Power/Generation/solar_panel.rsi
    state: solar_panel_glass
  - type: NodeContainer
    examinable: true
    nodes:
      output:
        !type:CableDeviceNode
        nodeGroupID: HVPower
  - type: PowerMonitoringDevice
    group: Generator
    loadNode: output
    sprite: Structures/Power/Generation/solar_panel.rsi
    state: solar_panel_glass
    collectionName: SolarPanel
  - type: Anchorable
  - type: Pullable
  - type: Electrified
    onHandInteract: false
    onInteractUsing: false
    onBump: false
    requirePower: true
    highVoltageNode: output
  - type: RequireProjectileTarget
  - type: GuideHelp
    guides:
    - SolarPanels

- type: entity
  id: SolarPanelPlasma
  parent: SolarPanelBasePhysSprite
  name: solar panel plasma
  description: A few sheets of plasma glass that generate electricity when hit by photons.
  components:
  - type: PowerSupplier
    supplyRampTolerance: 500
    supplyRampRate: 500
  - type: SolarPanel
    maxSupply: 1000
  - type: Sprite
    sprite: Structures/Power/Generation/solar_panel.rsi
    state: solar_panel_plasma
  - type: Damageable
    damageContainer: Inorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger: # Excess damage, don't spawn entities
        !type:DamageTrigger
        damage: 300
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:DoActsBehavior
        acts: ["Destruction"]
    - trigger:
        !type:DamageTrigger
        damage: 150
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:ChangeConstructionNodeBehavior
        node: solarpanelplasma_broken
      - !type:DoActsBehavior
        acts: ["Breakage"]
  - type: Construction
    graph: SolarPanel
    node: solarpanelplasma

- type: entity
  id: SolarPanelUranium
  parent: SolarPanelBasePhysSprite
  name: solar panel uranium
  description: A few sheets of uranium glass that generate electricity when hit by photons.
  components:
  - type: PowerSupplier
    supplyRampTolerance: 500
    supplyRampRate: 500
  - type: SolarPanel
    maxSupply: 1500
  - type: Sprite
    sprite: Structures/Power/Generation/solar_panel.rsi
    state: solar_panel_uranium
  - type: Damageable
    damageContainer: Inorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger: # Excess damage, don't spawn entities
        !type:DamageTrigger
        damage: 400
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:DoActsBehavior
        acts: ["Destruction"]
    - trigger:
        !type:DamageTrigger
        damage: 200
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:ChangeConstructionNodeBehavior
        node: solarpaneluranium_broken
      - !type:DoActsBehavior
        acts: ["Breakage"]
  - type: Construction
    graph: SolarPanel
    node: solarpaneluranium

- type: entity
  id: SolarPanel
  parent: SolarPanelBasePhysSprite
  name: solar panel
  description: A few sheets of glass that generate electricity when hit by photons.
  components:
  - type: PowerSupplier
    supplyRampTolerance: 500
    supplyRampRate: 500
  - type: SolarPanel
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger: # Excess damage, don't spawn entities
        !type:DamageTrigger
        damage: 200
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:DoActsBehavior
        acts: ["Destruction"]
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:ChangeConstructionNodeBehavior
        node: solarpanel_broken
      - !type:DoActsBehavior
        acts: ["Breakage"]
  - type: Construction
    graph: SolarPanel
    node: solarpanel
  - type: Tag
    tags:
    - DroneUsable # Goobstation
  - type: SolarPanelReplacementMarker

- type: entity
  id: SolarPanelBroken
  parent: SolarPanelBasePhysSprite
  name: solar panel
  description: A broken solar panel.
  suffix: Broken
  components:
  - type: Sprite
    state: solar_panel_glass_broken
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger: # Excess damage, don't spawn entities
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:DoActsBehavior
        acts: ["Destruction"]
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlass:
            min: 1
            max: 2
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: Construction
    graph: SolarPanel
    node: solarpanel_broken

- type: entity
  id: SolarPanelPlasmaBroken
  parent: SolarPanelBasePhysSprite
  name: plasma solar panel
  description: A broken plasma solar panel.
  suffix: Broken
  components:
  - type: Sprite
    state: solar_panel_plasma_broken
  - type: Damageable
    damageContainer: Inorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger: # Excess damage, don't spawn entities
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:DoActsBehavior
        acts: ["Destruction"]
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlassPlasma:
            min: 1
            max: 2
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: Construction
    graph: SolarPanel
    node: solarpanelplasma_broken

- type: entity
  id: SolarPanelUraniumBroken
  parent: SolarPanelBasePhysSprite
  name: uranium solar panel
  description: A broken uranium solar panel.
  suffix: Broken
  components:
  - type: Sprite
    state: solar_panel_uranium_broken
  - type: Damageable
    damageContainer: Inorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger: # Excess damage, don't spawn entities
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:DoActsBehavior
        acts: ["Destruction"]
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlassUranium:
            min: 1
            max: 2
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: Construction
    graph: SolarPanel
    node: solarpaneluranium_broken

- type: entity
  id: SolarAssembly
  name: solar assembly
  description: A solar assembly. Insert glass to build a solar panel. # Goobstation
  placement:
    mode: SnapgridCenter
  components:
  - type: Clickable
  - type: InteractionOutline
  - type: Physics
    bodyType: Static
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeCircle
          radius: 0.25
        density: 375
        mask:
        - MachineMask
        layer:
        - MachineLayer
  - type: Sprite
    sprite: Structures/Power/Generation/solar_panel.rsi
    state: solar_assembly
  - type: Transform
    anchored: true
    noRot: true
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger: # Excess damage, don't spawn entities
        !type:DamageTrigger
        damage: 200
      behaviors:
      - !type:DoActsBehavior
        acts: ["Destruction"]
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:DoActsBehavior
        acts: ["Breakage"]
  - type: Anchorable
  - type: Pullable
  - type: Construction
    graph: SolarPanel
    node: solarassembly
    defaultTarget: solarpanel
  - type: RequireProjectileTarget
  - type: GuideHelp
    guides:
    - SolarPanels

- type: entity
  id: SolarTracker
  name: solar tracker
  description: A solar tracker. Tracks the nearest star.
  placement:
    mode: SnapgridCenter
  components:
  - type: Clickable
  - type: InteractionOutline
  - type: Physics
    bodyType: Static
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb {}
        density: 100
        mask:
        - MachineMask
        layer:
        - MachineLayer
  - type: Sprite
    sprite: Structures/Power/Generation/solar_panel.rsi
    state: solar_tracker
  - type: Transform
    anchored: true
    noRot: true
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: StructuralMetallic
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:DoActsBehavior
        acts: ["Breakage"]
  - type: Anchorable
  - type: Pullable
  - type: Construction
    graph: SolarPanel
    node: solartracker
  - type: RequireProjectileTarget
  - type: GuideHelp
    guides:
    - SolarPanels
