# SPDX-FileCopyrightText: 2023 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 metalgearsloth <comedian_vs_clown@hotmail.com>
# SPDX-FileCopyrightText: 2023 stopbreaking <126102320+stopbreaking@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Aviu00 <93730715+Aviu00@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 EmoGarbage404 <retron404@gmail.com>
# SPDX-FileCopyrightText: 2024 FungiFellow <151778459+FungiFellow@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2024 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 zzylex <146784470+zzylex@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <aiden@djkraz.com>
# SPDX-FileCopyrightText: 2025 Fishbait <Fishbait@git.ml>
# SPDX-FileCopyrightText: 2025 Tyzemol <85772526+Tyzemol@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 fishbait <gnesse@gmail.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  name: bow
  parent: [BaseItem, BaseMinorContraband]
  id: BaseBow
  description: The original rooty tooty point and shooty.
  abstract: true
  components:
  - type: Sprite
    sprite: Objects/Weapons/Guns/Bow/bow.rsi
  - type: Item
    size: Normal
  - type: Clothing
    quickEquip: false
    slots:
      - Back
      - suitStorage
  - type: Wieldable
    wieldSound:
      path: /Audio/Items/bow_pull.ogg
  - type: UseDelay
    delay: 1
  - type: GunRequiresWield
  - type: Gun
    minAngle: 0
    maxAngle: 5
    fireRate: 1
    selectedMode: SemiAuto
    availableModes:
    - SemiAuto
    soundGunshot:
      collection: BulletMiss
    soundEmpty: null
    clumsyProof: true # Goobstation
  - type: ItemSlots
    slots:
      projectiles:
        name: Projectiles
        startingItem: null
        insertSound: /Audio/Weapons/Guns/Misc/arrow_nock.ogg
        whitelist:
          tags:
          - Arrow
          - Plunger
  - type: ContainerContainer
    containers:
      projectiles: !type:ContainerSlot
  - type: ContainerAmmoProvider
    container: projectiles
  - type: UnwieldOnShoot # Goobstation
  - type: UseDelayBlockShoot # Goobstation
  - type: UndetectableContraband #Goobstation-Contraband detector

- type: entity
  id: BowImprovised
  parent: BaseBow
  components:
  - type: Sprite
    layers:
    - state: unwielded
      map: [ base ]
    - state: unwielded-arrow
      map: [ arrow ]
      visible: false
    - state: unwielded-plunger
      map: [ plunger ]
      visible: false
  # to elucidate whats intended here:
  # arrow is inserted -> ItemMapper sets layer with map `arrow` to visible
  # bow is wielded -> generic vis sets states of layers with map `arrow` and `base`
  # arrow is removed -> itemmapper sets layer with map `arrow` to invisible
  - type: Appearance
  - type: ItemMapper
    spriteLayers:
    - arrow
    - plunger
    mapLayers:
      arrow:
        whitelist:
          tags:
          - Arrow
      plunger:
        whitelist:
          tags:
          - Plunger
  - type: GenericVisualizer
    visuals:
      enum.WieldableVisuals.Wielded:
        arrow:
          True: { state: wielded-arrow }
          False: { state: unwielded-arrow }
        plunger:
          True: { state: wielded-plunger }
          False: { state: unwielded-plunger }
        base:
          True: { state: wielded }
          False: { state: unwielded }
  - type: Construction
    graph: ImprovisedBow
    node: ImprovisedBow