- 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
  parent: [ SolarPanelBasePhysSprite, StructureHealthMachine ]
  id: SolarPanelPlasma
  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
    damageModifierSet: GlassPlasmaMod
  - type: Destructible
    thresholds:
    - trigger: &DamageMachineNormal # Excess damage, don't spawn entities
        !type:DamageTrigger
        damage: 175
      behaviors:
      - &SoundGlassBreak !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
    - trigger:
        !type:DamageTrigger
        damage: 75
      behaviors:
      - *SoundGlassBreak
      - !type:ChangeConstructionNodeBehavior
        node: solarpanelplasma_broken
  - type: Construction
    graph: SolarPanel
    node: solarpanelplasma

- type: entity
  parent: [ SolarPanelBasePhysSprite, StructureHealthMachineStrong ]
  id: SolarPanelUranium
  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
    damageModifierSet: GlassMod
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 275
      behaviors:
      - *SoundGlassBreak
    - trigger:
        !type:DamageTrigger
        damage: 175
      behaviors:
      - *SoundGlassBreak
      - !type:ChangeConstructionNodeBehavior
        node: solarpaneluranium_broken
  - type: Construction
    graph: SolarPanel
    node: solarpaneluranium

- type: entity
  parent: [ SolarPanelBasePhysSprite, StructureHealthMachineWeak ]
  id: SolarPanel
  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
    damageModifierSet: GlassMod
  - type: Destructible
    thresholds:
    - trigger: # Excess damage, don't spawn entities
        !type:DamageTrigger
        damage: 100
      behaviors:
      - *SoundGlassBreak
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - *SoundGlassBreak
      - !type:ChangeConstructionNodeBehavior
        node: solarpanel_broken
  - type: Construction
    graph: SolarPanel
    node: solarpanel
  - type: SolarPanelReplacementMarker

- type: entity
  parent: [ SolarPanelBasePhysSprite, StructureHealthMachineFlimsy ]
  id: SolarPanelBroken
  name: solar panel
  description: A broken solar panel.
  suffix: Broken
  components:
  - type: Sprite
    state: solar_panel_glass_broken
  - type: Damageable
    damageModifierSet: SteelMod
  - type: Destructible
    thresholds:
    - trigger: &DamageMachineFlimsy
        !type:DamageTrigger
        damage: 50
      behaviors:
      - *SoundGlassBreak
      - &ChangeNodeAssembly !type:ChangeConstructionNodeBehavior
        node: solarassembly
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlass:
            min: 1
            max: 2
  - type: Construction
    graph: SolarPanel
    node: solarpanel_broken

- type: entity
  parent: [ SolarPanelBasePhysSprite, StructureHealthMachineFlimsy ]
  id: SolarPanelPlasmaBroken
  name: plasma solar panel
  description: A broken plasma solar panel.
  suffix: Broken
  components:
  - type: Sprite
    state: solar_panel_plasma_broken
  - type: Damageable
    damageModifierSet: SteelMod
  - type: Destructible
    thresholds:
    - trigger: *DamageMachineFlimsy
      behaviors:
      - *SoundGlassBreak
      - *ChangeNodeAssembly
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlassPlasma:
            min: 1
            max: 2
  - type: Construction
    graph: SolarPanel
    node: solarpanelplasma_broken

- type: entity
  parent: [ SolarPanelBasePhysSprite, StructureHealthMachineFlimsy ]
  id: SolarPanelUraniumBroken
  name: uranium solar panel
  description: A broken uranium solar panel.
  suffix: Broken
  components:
  - type: Sprite
    state: solar_panel_uranium_broken
  - type: Damageable
    damageModifierSet: SteelMod
  - type: Destructible
    thresholds:
    - trigger: *DamageMachineFlimsy
      behaviors:
      - *SoundGlassBreak
      - *ChangeNodeAssembly
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlassUranium:
            min: 1
            max: 2
  - type: Construction
    graph: SolarPanel
    node: solarpaneluranium_broken

- type: entity
  parent: StructureHealthMachineFlimsy
  id: SolarAssembly
  name: solar assembly
  description: A solar assembly. Anchor to a wire to start building a solar panel.
  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
    damageModifierSet: SteelMod
  - type: Destructible
    thresholds:
    - trigger: *DamageMachineFlimsy
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
  - type: Anchorable
  - type: Pullable
  - type: Construction
    graph: SolarPanel
    node: solarassembly
    defaultTarget: solarpanel
  - type: RequireProjectileTarget
  - type: GuideHelp
    guides:
    - SolarPanels

- type: entity
  parent: StructureHealthMachine
  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
    damageModifierSet: GlassMod
  - type: Destructible
    thresholds:
    - trigger: *DamageMachineNormal
      behaviors:
      - *SoundGlassBreak
      - *ChangeNodeAssembly
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlass:
            min: 0
            max: 2
          SolarTrackerElectronics:
            min: 0
            max: 1
  - type: Anchorable
  - type: Pullable
  - type: Construction
    graph: SolarPanel
    node: solartracker
  - type: RequireProjectileTarget
  - type: GuideHelp
    guides:
    - SolarPanels
