# SPDX-FileCopyrightText: 2024 Aidenkrz <aiden@djkraz.com>
# SPDX-FileCopyrightText: 2024 Ed <96445749+TheShuEd@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Flareguy <78941145+Flareguy@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Ilya246 <57039557+Ilya246@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 GoobBot <uristmchands@proton.me>
# SPDX-FileCopyrightText: 2025 Killerqu00 <killerqueen1777@gmail.com>
# SPDX-FileCopyrightText: 2025 Ted Lukin <66275205+pheenty@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Winkarst <74284083+Winkarst-cpu@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 gluesniffler <159397573+gluesniffler@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 pheenty <fedorlukin2006@gmail.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# Most of these have DO NOT MAP, since stations are completely unequipped to deal with ship combat + these are basically placeholder.

- type: entity
  id: ShuttleGunBase
  parent: BaseStructure
  name: shittle gun
  abstract: true
  components:
  - type: Appearance
  - type: InteractionOutline
  - type: Anchorable
  - type: Rotatable
  - type: ContainerContainer
  - type: Gun
    selectedMode: SemiAuto
    availableModes:
      - SemiAuto
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Electronic
  - type: DeviceNetwork
    deviceNetId: Wireless
    receiveFrequencyId: BasicDevice
  - type: WirelessNetworkConnection
    range: 200
  - type: DeviceLinkSink
    ports:
    - Trigger
    - Toggle
    - On
    - Off
  - type: AutoShootGun
  - type: GunSignalControl
  - type: StaticPrice
    price: 1500

# ---- Laser weapon branch ----
# naming: LSE (Laser) + conventional power + suffix (c for PowerCage, e for wired energy) + Name
# example: LSE-100e "Clown destroyer" (powered by the wiring, very weak)

- type: entity
  id: ShuttleGunSvalinnMachineGun
  parent: [ ShuttleGunBase, ConstructibleMachine]
  name: LSE-400c "Svalinn machine gun"
  description: Basic stationary laser unit. Effective against live targets and electronics. Uses regular power cells to fire, and has an extremely high rate of fire.
  categories: [ DoNotMap ]
  components:
  - type: Sprite
    sprite: Objects/Weapons/Guns/Shuttles/laser.rsi
    layers:
    - state: lse-400c
    - state: mag-unshaded-9
      map: ["enum.GunVisualLayers.MagUnshaded"]
      shader: unshaded
  - type: ContainerContainer
    containers:
      machine_board: !type:Container
      machine_parts: !type:Container
      gun_magazine: !type:ContainerSlot # goob edit - svalinn buff fix
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 150
      behaviors:
        - !type:ChangeConstructionNodeBehavior
          node: machineFrame
        - !type:DoActsBehavior
          acts: ["Destruction"]
  - type: Gun
    fireRate: 5
    useKey: false
    soundGunshot:
      path: /Audio/Weapons/Guns/Gunshots/ship_svalinn.ogg
      params:
        variation: 0.05
  - type: MagazineVisuals
    magState: mag
    steps: 10
    zeroVisible: true
  - type: Machine
    board: ShuttleGunSvalinnMachineGunCircuitboard
  # - type: PowerCellSlot # goob edit - svalinn buff fix
  #   cellSlotId: cell_slot
  - type: ItemSlots
    slots:
      gun_magazine: # goob edit - svalinn buff fix
        name: Magazine
        insertSound: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg
        ejectSound: /Audio/Weapons/Guns/MagOut/batrifle_magout.ogg
        whitelist:
          tags:
            - PowerCell
            - PowerCellSmall
            - PotatoBattery # goob edits start
  # - type: HitscanBatteryAmmoProvider
  #   proto: RedLightLaser
  #   fireCost: 50
  - type: MagazineAmmoProvider # goob edits end

- type: entity
  id: ShuttleGunPerforator
  parent: [ ShuttleGunBase, ConstructibleMachine]
  name: LSE-1200c "Perforator"
  description: Advanced stationary laser unit. Annihilates electronics and is extremely dangerous to health! Uses the power cage to fire.
  categories: [ DoNotMap ]
  components:
  - type: Sprite
    sprite: Objects/Weapons/Guns/Shuttles/laser.rsi
    layers:
    - state: lse-1200c
    - state: mag-unshaded-9
      map: ["enum.GunVisualLayers.MagUnshaded"]
      shader: unshaded
  - type: ContainerContainer
    containers:
      machine_board: !type:Container
      machine_parts: !type:Container
      cell_slot: !type:ContainerSlot
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 300
      behaviors:
        - !type:ChangeConstructionNodeBehavior
          node: machineFrame
        - !type:DoActsBehavior
          acts: ["Destruction"]
  - type: Gun
    fireRate: 1
    soundGunshot:
      path: /Audio/Weapons/Guns/Gunshots/ship_perforator.ogg
      params:
        variation: 0.05
  - type: MagazineVisuals
    magState: mag
    steps: 10
    zeroVisible: true
  - type: Machine
    board: ShuttleGunPerforatorCircuitboard
  - type: PowerCellSlot
    cellSlotId: cell_slot
  - type: ItemSlots
    slots:
      cell_slot:
        name: Magazine
        insertSound: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg
        ejectSound: /Audio/Weapons/Guns/MagOut/batrifle_magout.ogg
        whitelist:
          tags:
            - PowerCage
  - type: HitscanBatteryAmmoProvider
    proto: RedShuttleLaser
    fireCost: 150

# ---- Launchers ----
# naming: EXP (Explosion) + conventional power + suffix (g for Grenade, c for RPG Cartridge) + Name
# example: EXP-100c "Poppy"

- type: entity
  id: ShuttleGunFriendship
  parent: [ShuttleGunBase, ConstructibleMachine]
  name: EXP-320g "Friendship"
  description: A small stationary grenade launcher that holds 2 grenades.
  categories: [ DoNotMap ]
  components:
  - type: Sprite
    sprite: Objects/Weapons/Guns/Shuttles/launcher.rsi
    layers:
    - state: exp-320g
    - state: mag-7
      map: ["enum.GunVisualLayers.Mag"]
  - type: ContainerContainer
    containers:
      machine_board: !type:Container
      machine_parts: !type:Container
      ballistic-ammo: !type:Container
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 200
      behaviors:
        - !type:ChangeConstructionNodeBehavior
          node: machineFrame
        - !type:DoActsBehavior
          acts: ["Destruction"]
  - type: Gun
    projectileSpeed: 80
    fireRate: 1
    angleDecay: 45
    minAngle: 0
    maxAngle: 15
    soundGunshot:
      path: /Audio/Weapons/Guns/Gunshots/ship_friendship.ogg
      params:
        pitch: 0.8
    soundEmpty:
      path: /Audio/Weapons/Guns/Empty/empty.ogg
  - type: BallisticAmmoProvider
    whitelist:
      tags:
        - Grenade
    capacity: 2
    soundInsert:
      path: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg
  - type: Machine
    board: ShuttleGunFriendshipCircuitboard
  - type: MagazineVisuals
    magState: mag
    steps: 8
    zeroVisible: false

- type: entity
  id: ShuttleGunDuster
  parent: [ShuttleGunBase, ConstructibleMachine]
  name: EXP-2100g "Duster"
  description: A powerful stationary grenade launcher. A cartridge is required for use.
  categories: [ DoNotMap ]
  components:
  - type: Sprite
    sprite: Objects/Weapons/Guns/Shuttles/launcher.rsi
    layers:
    - state: exp-2100g
    - state: mag-7
      map: ["enum.GunVisualLayers.Mag"]
  - type: ContainerContainer
    containers:
      machine_board: !type:Container
      machine_parts: !type:Container
      gun_magazine: !type:ContainerSlot
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 350
      behaviors:
        - !type:ChangeConstructionNodeBehavior
          node: machineFrame
        - !type:DoActsBehavior
          acts: ["Destruction"]
  - type: Gun
    projectileSpeed: 40
    fireRate: 0.3
    soundGunshot:
      path: /Audio/Weapons/Guns/Gunshots/ship_duster.ogg
      params:
        variation: 0.05
        pitch: 0.8
    soundEmpty:
      path: /Audio/Weapons/Guns/Empty/empty.ogg
  - type: Machine
    board: ShuttleGunDusterCircuitboard
  - type: MagazineAmmoProvider
  - type: MagazineVisuals
    magState: mag
    steps: 8
    zeroVisible: false
  - type: ItemSlots
    slots:
      gun_magazine:
        name: Magazine
        priority: 2
        whitelist:
          tags:
          - MagazineGrenade
        insertSound:
          path: /Audio/Weapons/Guns/MagIn/kinetic_reload.ogg
          params:
            pitch: 2
        ejectSound: /Audio/Weapons/Guns/MagOut/smg_magout.ogg

# ---- Other weapon ----

- type: entity
  id: ShuttleGunPirateCannon
  parent: ShuttleGunBase
  name: pirate ship cannon
  description: Kaboom!
  components:
  - type: ContainerContainer
    containers:
      ballistic-ammo: !type:Container
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 300
      behaviors:
        - !type:DoActsBehavior
          acts: ["Destruction"]
  - type: Sprite
    sprite: Objects/Weapons/Guns/Shuttles/pirate_cannon.rsi
    layers:
    - state: base
  - type: Gun
    fireRate: 1
    soundGunshot:
      path: /Audio/Weapons/Guns/Gunshots/mateba.ogg
  - type: BallisticAmmoProvider
    whitelist:
      tags:
        - CannonBall
    capacity: 1
    proto: CannonBall
    soundInsert:
      path: /Audio/Weapons/Guns/Gunshots/grenade_launcher.ogg

- type: entity
  id: ShuttleGunKinetic
  parent: [ ShuttleGunBase, ConstructibleMachine]
  name: PTK-800 "Matter Dematerializer"
  description: Salvage stationary mining turret. Gradually accumulates charges on its own, extremely effective for asteroid excavation.
  categories: [ DoNotMap ]
  components:
  - type: Sprite
    sprite: Objects/Weapons/Guns/Shuttles/kinetic.rsi
    layers:
    - state: ptk-800
    - state: mag-7
  - type: ContainerContainer
    containers:
      machine_board: !type:Container
      machine_parts: !type:Container
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors:
        - !type:ChangeConstructionNodeBehavior
          node: machineFrame
        - !type:DoActsBehavior
          acts: ["Destruction"]
  - type: Gun
    projectileSpeed: 25 # Goobstation edit
    fireRate: 1 # Goobstation edit
    selectedMode: SemiAuto
    angleDecay: 45
    minAngle: 5
    maxAngle: 15
    availableModes:
    - SemiAuto
    soundGunshot:
      path: /Audio/Weapons/Guns/Gunshots/kinetic_accel.ogg
      params:
        variation: 0.12
  - type: RechargeBasicEntityAmmo
    rechargeCooldown: 2
    rechargeSound:
      path: /Audio/Weapons/Guns/Bolt/lmg_bolt_closed.ogg
      params:
        pitch: 1.2
        variation: 0.08
  - type: BasicEntityAmmoProvider
    proto: BulletKineticShuttle
    capacity: 5
    count: 5
  - type: Machine
    board: ShuttleGunKineticCircuitboard
  - type: PressureDamageChange # Goobstation
  - type: UpgradeableGun # Goobstation
    maxUpgradeCapacity: 40
    whitelist:
      tags:
      - PKAUpgrade
