# SPDX-FileCopyrightText: 2023 metalgearsloth <comedian_vs_clown@hotmail.com>
# SPDX-FileCopyrightText: 2024 Ed <96445749+TheShuEd@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 J. Brown <DrMelon@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2024 Piras314 <p1r4s@proton.me>
# SPDX-FileCopyrightText: 2024 Tayrtahn <tayrtahn@gmail.com>
# SPDX-FileCopyrightText: 2024 qwerltaz <69696513+qwerltaz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 yglop <95057024+yglop@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Armok <155400926+ARMOKS@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 BombasterDS <deniskaporoshok@gmail.com>
# SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
# SPDX-FileCopyrightText: 2025 Ilya246 <57039557+Ilya246@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Ilya246 <ilyukarno@gmail.com>
# SPDX-FileCopyrightText: 2025 ImWeax <59857479+ImWeax@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 SX-7 <sn1.test.preria.2002@gmail.com>
# SPDX-FileCopyrightText: 2025 Weax <59857479+ImWeax@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 keronshb <54602815+keronshb@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  id: BaseEnergyBall
  abstract: true
  components:
  - type: Clickable
  - type: Physics
    bodyType: KinematicController
    bodyStatus: InAir
    sleepingAllowed: false
  - type: CanMoveInAir
  - type: ChasingWalk
    minSpeed: 1
    maxSpeed: 3
    chasingComponent:
    - type: LightningTarget
  - type: AmbientSound
    volume: 3
    range: 15
    sound:
      path: /Audio/Effects/tesla.ogg
  - type: PointLight
    enabled: true
    radius: 8
    energy: 2
    color: "#4080FF"
  - type: Appearance
  - type: LightningArcShooter
    arcDepth: 2
    maxLightningArc: 1
    shootMinInterval: 4
    shootMaxInterval: 10
    shootRange: 3
    lightningPrototype: Lightning
  # Goobstation
  - type: ContainmentFieldIgnore # to replace the cursed mass threshold system

- type: entity
  id: TeslaEnergyBall
  parent: BaseEnergyBall
  name: tesla orb
  description: A giant ball of pure energy. The space around it is humming and melting.
  components:
  - type: Fixtures
    fixtures:
      EventHorizonCollider:
        shape:
          !type:PhysShapeCircle
            radius: 0.55
        hard: true
        restitution: 0.8
        density: 99999
        mask:
        - Opaque
        layer:
        - GlassLayer
      EventHorizonConsumer:
        shape:
          !type:PhysShapeCircle
            radius: 0.65
        hard: false
        mask:
        - Opaque
        layer:
        - GlassLayer
  - type: PointLight
    radius: 10
    energy: 16
  - type: EventHorizon
    radius: 0.5
    canBreachContainment: false
    colliderFixtureId: EventHorizonCollider
    consumerFixtureId: EventHorizonConsumer
    consumeTiles: false
    consumeEntities: false
  # <Goobstation>
  - type: Tag
    tags:
    - Tesla
  # </Goobstation>
  - type: TeslaEnergyBall
    spawnProto: TeslaMiniEnergyBall
    soundCollapse:
      path: /Audio/Effects/tesla_collapse.ogg
      params:
        variation: 0.3
  - type: LightningArcShooter
    arcDepth: 3
    maxLightningArc: 4
    shootMinInterval: 3
    shootMaxInterval: 5
    shootRange: 7
    lightningPrototype: Lightning #To do: change to HyperchargedLightning, after fix beam system
  - type: ChasingWalk
    minSpeed: 1
    maxSpeed: 3
  - type: ChaoticJump
    jumpMinInterval: 8
    jumpMaxInterval: 15
  - type: WarpPoint
    follow: true
    location: tesla ball
  - type: Sprite
    drawdepth: Effects
    sprite: Structures/Power/Generation/Tesla/energy_ball.rsi
    layers:
    - state: energy_ball
      shader: unshaded
  - type: EmitSoundOnSpawn
    sound:
      path: /Audio/Effects/tesla_collapse.ogg
      params:
        variation: 0.3
  - type: InteractionPopup # for the brave
    successChance: 0.2
    interactSuccessString: petting-success-tesla
    interactFailureString: petting-failure-tesla
    interactSuccessSpawn: EffectHearts
  - type: SupermatterImmune # Goobstation
  - type: GuideHelp # For the curious among the brave.
    guides:
    - TeslaEngine
    - SingularityTeslaEngine
    - Power

- type: entity
  id: TeslaMiniEnergyBall
  parent: BaseEnergyBall
  name: mini tesla orb
  description: The cub of a destructive energy cage. Not as dangerous, but still not worth touching with bare hands.
  components:
  - type: ChasingWalk
    minSpeed: 2
    maxSpeed: 3
    chasingComponent:
    - type: TeslaEnergyBall
  - type: Fixtures
    fixtures:
      TeslaCollider:
        shape:
          !type:PhysShapeCircle
            radius: 0.35
        hard: true
        restitution: 0.8
        density: 10
        mask:
        - None
        layer:
        - None
  - type: TimedDespawn
    lifetime: 120
  - type: Sprite
    drawdepth: Effects
    sprite: Structures/Power/Generation/Tesla/energy_miniball.rsi
    layers:
    - state: tesla_projectile
      shader: unshaded
  - type: Electrified
    requirePower: false
