# SPDX-FileCopyrightText: 2021 metalgearsloth <metalgearsloth@gmail.com>
# SPDX-FileCopyrightText: 2021 shaeone <60476183+shaeone@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Moony <moonheart08@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Myctai <108953437+Myctai@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Radrark <76271993+Radrark@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Rinkashikachi <15rinkashikachi15@gmail.com>
# SPDX-FileCopyrightText: 2023 AJCM-git <60196617+AJCM-git@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 TemporalOroboros <TemporalOroboros@gmail.com>
# SPDX-FileCopyrightText: 2023 Whisper <121047731+QuietlyWhisper@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Aviu00 <93730715+Aviu00@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Ed <96445749+TheShuEd@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 lzk <124214523+lzk228@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 metalgearsloth <comedian_vs_clown@hotmail.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  id: BaseThruster
  parent: BaseStructureDynamic
  name: thruster
  description: A thruster that allows a shuttle to move.
  abstract: true
  components:
    - type: Fixtures
      fixtures:
        fix1:
          shape:
            !type:PhysShapeAabb
            bounds: "-0.45,-0.45,0.45,0.45"
          density: 60
          mask:
          - MachineMask
          layer:
          - MachineLayer
    - type: AmbientSound
      enabled: false
      range: 4
      volume: -4
      sound:
        path: /Audio/Effects/shuttle_thruster.ogg
    - type: Transform
      anchored: true
    - type: Physics
      bodyType: Static
    - type: Rotatable
      rotateWhileAnchored: true
    - type: Thruster
      damage:
        types:
          Heat: 40
    - type: InteractionOutline
    - type: Sprite
    - type: Appearance
    - type: ThrusterVisuals
    - type: ApcPowerReceiver
      powerLoad: 1500
    - type: ExtensionCableReceiver
    - type: Damageable
      damageContainer: StructuralInorganic
      damageModifierSet: Electronic
    - type: Destructible
      thresholds:
      - trigger:
          !type:DamageTrigger
          damage: 300  # Changed 100->300 because impact damage is real
        behaviors:
          - !type:DoActsBehavior
            acts: ["Destruction"]
          - !type:PlaySoundBehavior
            sound:
              collection: MetalBreak
    - type: StaticPrice
      price: 300
    - type: GuideHelp
      guides:
      - ShuttleCraft
  placement:
    mode: SnapgridCenter

- type: entity
  id: Thruster
  name: thruster
  parent: [ BaseThruster, ConstructibleMachine ]
  components:
  - type: Machine
    board: ThrusterMachineCircuitboard
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 600
      behaviors:
        - !type:DoActsBehavior
          acts: ["Destruction"]
    - trigger:
        !type:DamageTrigger
        damage: 300
      behaviors:
        - !type:DoActsBehavior
          acts: ["Destruction"]
        - !type:PlaySoundBehavior
          sound:
            collection: MetalBreak
        - !type:ChangeConstructionNodeBehavior
          node: machineFrame
  - type: Sprite
    sprite: Structures/Shuttles/thruster.rsi
    layers:
    - state: base
      map: ["enum.ThrusterVisualLayers.Base"]
    - state: thrust
      map: ["enum.ThrusterVisualLayers.ThrustOn"]
      shader: unshaded
      visible: false
    - state: thrust_burn_unshaded
      map: ["enum.ThrusterVisualLayers.ThrustingUnshaded"]
      shader: unshaded
      visible: false
      offset: 0, 1

- type: entity
  id: ThrusterUnanchored
  parent: Thruster
  suffix: Unanchored
  components:
    - type: Transform
      anchored: false
    - type: Physics
      bodyType: Dynamic

- type: entity
  id: DebugThruster
  parent: BaseThruster
  suffix: DEBUG
  components:
  - type: Thruster
    requireSpace: false
  - type: ApcPowerReceiver
    needsPower: false
    powerLoad: 0
  - type: Sprite
    sprite: Structures/Shuttles/thruster.rsi
    layers:
    - state: base
      map: ["enum.ThrusterVisualLayers.Base"]
    - state: thrust
      map: ["enum.ThrusterVisualLayers.ThrustOn"]
      shader: unshaded
      visible: false
    - state: thrust_burn_unshaded
      map: ["enum.ThrusterVisualLayers.ThrustingUnshaded"]
      shader: unshaded
      visible: false
      offset: 0, 1

- type: entity
  id: Gyroscope
  parent: [ BaseThruster, ConstructibleMachine ]
  name: gyroscope
  description: Increases the shuttle's potential angular rotation.
  components:
  - type: Thruster
    thrusterType: Angular
    requireSpace: false
    thrust: 2000
    machinePartThrust: Manipulator
  - type: Sprite
    # Listen I'm not the biggest fan of the sprite but it was the most appropriate thing I could find.
    sprite: Structures/Shuttles/gyroscope.rsi
    snapCardinals: true
    layers:
    - state: base
      map: ["enum.ThrusterVisualLayers.Base"]
    - state: thrust
      map: ["enum.ThrusterVisualLayers.ThrustOn"]
      shader: unshaded
      visible: false
    - state: thrust_burn
      map: [ "enum.ThrusterVisualLayers.Thrusting" ]
      visible: false
    - state: thrust_burn_unshaded
      map: ["enum.ThrusterVisualLayers.ThrustingUnshaded"]
      shader: unshaded
      visible: false
  - type: PointLight
    radius: 1.3
    energy: 0.8
    enabled: false
    mask: /Textures/Effects/LightMasks/cone.png
    autoRot: true
    offset: "0, 0.1" # shine from the top, not bottom of the computer
    color: "#4246b3"
  - type: Machine
    board: GyroscopeMachineCircuitboard
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 300
      behaviors:
        - !type:DoActsBehavior
          acts: ["Destruction"]
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors:
        - !type:DoActsBehavior
          acts: ["Destruction"]
        - !type:PlaySoundBehavior
          sound:
            collection: MetalBreak
        - !type:ChangeConstructionNodeBehavior
          node: machineFrame
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Electronic
  - type: StaticPrice
    price: 2000

- type: entity
  id: GyroscopeUnanchored
  parent: Gyroscope
  suffix: Unanchored
  components:
    - type: Transform
      anchored: false
    - type: Physics
      bodyType: Dynamic

- type: entity
  id: DebugGyroscope
  parent: BaseThruster
  suffix: DEBUG
  components:
  - type: Thruster
    thrusterType: Angular
    requireSpace: false
    thrust: 100
  - type: ApcPowerReceiver
    needsPower: false
    powerLoad: 0
  - type: Sprite
    sprite: Structures/Shuttles/gyroscope.rsi
    snapCardinals: true
    layers:
    - state: base
      map: ["enum.ThrusterVisualLayers.Base"]
    - state: thrust
      map: ["enum.ThrusterVisualLayers.ThrustOn"]
      shader: unshaded
      visible: false
    - state: thrust_burn_unshaded
      map: ["enum.ThrusterVisualLayers.ThrustingUnshaded"]
      shader: unshaded
      visible: false

# Goobstation
- type: entity
  id: ThrusterShuttleEvac # Can't be unanchored and hard to destroy
  parent: BaseStructure
  name: thruster
  description: A thruster that allows a shuttle to move.
  suffix: Evac shuttle, unanchorable
  components:
    - type: Fixtures
      fixtures:
        fix1:
          shape:
            !type:PhysShapeAabb
            bounds: "-0.45,-0.45,0.45,0.45"
          density: 60
          mask:
          - MachineMask
          layer:
          - MachineLayer
    - type: AmbientSound
      enabled: false
      range: 4
      volume: -4
      sound:
        path: /Audio/Effects/shuttle_thruster.ogg
    - type: Transform
      anchored: true
    - type: Physics
      bodyType: Static
    - type: Rotatable
    - type: Thruster
      damage:
        types:
          Heat: 40
    - type: InteractionOutline
    - type: Appearance
    - type: ThrusterVisuals
    - type: ApcPowerReceiver
      powerLoad: 1500
    - type: ExtensionCableReceiver
    - type: Damageable
      damageContainer: StructuralInorganic
      damageModifierSet: Electronic
    - type: Destructible
      thresholds:
      - trigger:
          !type:DamageTrigger
          damage: 5000
        behaviors:
          - !type:DoActsBehavior
            acts: ["Destruction"]
          - !type:PlaySoundBehavior
            sound:
              collection: MetalBreak
    - type: Clickable
    - type: StaticPrice
      price: 300
    - type: Sprite
      sprite: Structures/Shuttles/thruster.rsi
      layers:
      - state: base
        map: ["enum.ThrusterVisualLayers.Base"]
      - state: thrust
        map: ["enum.ThrusterVisualLayers.ThrustOn"]
        shader: unshaded
        visible: false
      - state: thrust_burn_unshaded
        map: ["enum.ThrusterVisualLayers.ThrustingUnshaded"]
        shader: unshaded
        visible: false
        offset: 0, 1
  placement:
    mode: SnapgridCenter