# SPDX-FileCopyrightText: 2020 Paul Ritter <ritter.paul1@googlemail.com>
# SPDX-FileCopyrightText: 2020 Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
# SPDX-FileCopyrightText: 2020 nuke <47336974+nuke-makes-games@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Galactic Chimp <GalacticChimpanzee@gmail.com>
# SPDX-FileCopyrightText: 2021 Swept <sweptwastaken@protonmail.com>
# SPDX-FileCopyrightText: 2021 Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Morber <14136326+Morb0@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Peptide90 <78795277+Peptide90@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Doru991 <75124791+Doru991@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Ed <96445749+TheShuEd@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 ElectroJr <leonsfriedrich@gmail.com>
# SPDX-FileCopyrightText: 2023 Jezithyr <6192499+Jezithyr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2023 Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 T-Stalker <43253663+DogZeroX@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 TemporalOroboros <TemporalOroboros@gmail.com>
# SPDX-FileCopyrightText: 2023 faint <46868845+ficcialfaint@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 gus <august.eymann@gmail.com>
# SPDX-FileCopyrightText: 2023 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 qwerltaz <69696513+qwerltaz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 beck-thompson <107373427+beck-thompson@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  name: torch
  parent: BaseItem
  id: Torch
  description: A torch fashioned from some wood.
  components:
    - type: ExpendableLight
      refuelMaterialID: WoodPlank
      glowDuration: 100
      refuelMaximumDuration: 205
      fadeOutDuration: 4
      iconStateSpent: torch_spent
      turnOnBehaviourID: turn_on
      fadeOutBehaviourID: fade_out
      # Sounds legit nuff
      litSound:
        path: /Audio/Items/Flare/flare_on.ogg
    - type: Sprite
      sprite: Objects/Misc/torch.rsi
      layers:
        - map: [ enum.ExpendableLightVisualLayers.Base ]
          state: torch_unlit
        - map: [ enum.ExpendableLightVisualLayers.Glow ]
          state: lit_overlay
          color: "#FFFFFF"
          visible: false
          shader: unshaded
        - map: [ enum.ExpendableLightVisualLayers.Overlay ]
          state: torch_nocloth
    - type: Icon
      sprite: Objects/Misc/torch.rsi
      state: icon
    - type: Item
      sprite: Objects/Misc/torch.rsi
      heldPrefix: unlit
    - type: Construction
      graph: LightTorch
      node: torch
    - type: Appearance
    - type: PointLight
      enabled: false
      color: "#E25822"
      radius: 1.0
      energy: 5.0
      netsync: false
    - type: IgnitionSource
      temperature: 400
      ignited: false
    - type: LightBehaviour
      behaviours:
        - !type:RandomizeBehaviour # immediately make it bright and flickery
          id: turn_on
          interpolate: Nearest
          minDuration: 0.02
          maxDuration: 0.06
          startValue: 6.0
          endValue: 9.0
          property: Energy
          isLooped: true
        - !type:FadeBehaviour # have the radius start small and get larger as it starts to burn
          id: turn_on
          maxDuration: 8.0
          startValue: 1.0
          endValue: 6.0
        - !type:RandomizeBehaviour # weaker flicker as it fades out
          id: fade_out
          interpolate: Nearest
          minDuration: 0.02
          maxDuration: 0.06
          startValue: 4.0
          endValue: 8.0
          property: Energy
          isLooped: true
        - !type:FadeBehaviour # fade out radius as it burns out
          id: fade_out
          maxDuration: 4.0
          startValue: 6.0
          endValue: 1.0
    - type: Tag
      tags:
      - Torch