# SPDX-FileCopyrightText: 2021 Acruid <shatter66@gmail.com>
# SPDX-FileCopyrightText: 2021 Alex Evgrashin <aevgrashin@yandex.ru>
# SPDX-FileCopyrightText: 2021 DrSmugleaf <DrSmugleaf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Kara D <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2021 Metal Gear Sloth <metalgearsloth@gmail.com>
# SPDX-FileCopyrightText: 2021 Paul <ritter.paul1+git@googlemail.com>
# SPDX-FileCopyrightText: 2021 Peptide90 <78795277+Peptide90@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Radrark <76271993+Radrark@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Vera Aguilera Puerto <zddm@outlook.es>
# SPDX-FileCopyrightText: 2021 Visne <39844191+Visne@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Ygg01 <y.laughing.man.y@gmail.com>
# SPDX-FileCopyrightText: 2021 drongood12 <73915636+drongood12@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 mirrorcult <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2022 Jacob Tong <10494922+ShadowCommander@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Paul Ritter <ritter.paul1@googlemail.com>
# SPDX-FileCopyrightText: 2022 Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
# SPDX-FileCopyrightText: 2023 Cody ~ Aexxie <125095677+Aexxie@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 brainfood1183 <113240905+brainfood1183@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 lzk <124214523+lzk228@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 3nderall <101940324+3nderall@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 3nderall <3nderall@gmail.com>
# SPDX-FileCopyrightText: 2024 Adeinitas <147965189+adeinitas@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Ilya246 <57039557+Ilya246@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Plykiya <58439124+Plykiya@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Timemaster99 <57200767+Timemaster99@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 VMSolidus <evilexecutive@gmail.com>
# SPDX-FileCopyrightText: 2024 chromiumboy <50505512+chromiumboy@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 deltanedas <39013340+deltanedas@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 deltanedas <@deltanedas:kde.org>
# SPDX-FileCopyrightText: 2024 gluesniffler <159397573+gluesniffler@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 metalgearsloth <comedian_vs_clown@hotmail.com>
# SPDX-FileCopyrightText: 2024 plykiya <plykiya@protonmail.com>
# SPDX-FileCopyrightText: 2024 slarticodefast <161409025+slarticodefast@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
# SPDX-FileCopyrightText: 2025 Steve <marlumpy@gmail.com>
# SPDX-FileCopyrightText: 2025 marc-pelletier <113944176+marc-pelletier@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  id: BaseFoam
  abstract: true
  components:
  - type: Sprite
    drawdepth: Effects
  - type: Appearance
  - type: AnimationPlayer
  - type: SmokeVisuals
  - type: Transform
    anchored: true
  - type: Physics
  - type: Fixtures
    fixtures:
      fix1:
        hard: false
        shape:
          !type:PhysShapeAabb
          bounds: "-0.4,-0.4,0.4,0.4"
        mask:
        - ItemMask
        layer:
        - SlipLayer
  - type: Smoke
  - type: ActiveEdgeSpreader
  - type: EdgeSpreader
    id: Smoke
  - type: SolutionContainerManager
    solutions:
      solutionArea:
        maxVol: 600
        canReact: false

- type: entity
  parent: BaseFoam
  id: Smoke
  name: smoke
  categories: [ HideSpawnMenu ]
  components:
  - type: Occluder
  - type: Sprite
    sprite: Effects/chemsmoke.rsi
    state: chemsmoke
  - type: TimedDespawn
    lifetime: 5 # goob edit - faster foam
  - type: Tag
    tags:
    - HideContextMenu

- type: entity
  parent: BaseFoam
  id: TearGasSmoke
  name: tear gas
  categories: [ HideSpawnMenu ]
  components:
  - type: Sprite
    sprite: Effects/chemsmoke.rsi
    state: chemsmoke
  - type: TimedDespawn
    lifetime: 5 # goob edit - faster foam
  - type: Tag
    tags:
    - HideContextMenu

- type: entity
  parent: TearGasSmoke
  id: TearGasSmokeWhite
  categories: [ HideSpawnMenu ]
  components:
  - type: Sprite
    state: chemsmoke_white

- type: entity
  parent: Smoke
  id: WizardSmoke
  name: smoke
  categories: [ HideSpawnMenu ]
  components:
  - type: Smoke
    spreadAmount: 5

- type: entity
  parent: BaseFoam
  id: Foam
  name: foam
  categories: [ HideSpawnMenu ]
  components:
  - type: Sprite
    color: "#ffffffcc"
    sprite: Effects/foam.rsi
    layers:
    - state: foam
      map: ["enum.FoamVisualLayers.Base"]
    - map: [ "enum.EdgeLayer.South" ]
      state: foam-south
    - map: [ "enum.EdgeLayer.East" ]
      state: foam-east
    - map: [ "enum.EdgeLayer.North" ]
      state: foam-north
    - map: [ "enum.EdgeLayer.West" ]
      state: foam-west
  - type: SmoothEdge
  - type: IconSmooth
    mode: NoSprite
  - type: FoamVisuals
    animationTime: 0.6
    animationState: foam-dissolve
  - type: Slippery
  - type: StepTrigger
    triggerGroups:
      types:
      - SlipTile
  # disabled until foam reagent duplication is fixed
  #- type: ScoopableSolution
  #  solution: solutionArea

- type: entity
  id: MetalFoam
  name: metal foam
  categories: [ HideSpawnMenu ]
  parent: Foam
  components:
  - type: Sprite
    color: "#ffffffcc"
    sprite: Effects/foam.rsi
    layers:
    - state: m_foam
      map: ["enum.FoamVisualLayers.Base"]
    - map: [ "enum.EdgeLayer.South" ]
      state: m_foam-south
    - map: [ "enum.EdgeLayer.East" ]
      state: m_foam-east
    - map: [ "enum.EdgeLayer.North" ]
      state: m_foam-north
    - map: [ "enum.EdgeLayer.West" ]
      state: m_foam-west
  - type: EdgeSpreader
    id: MetalFoam
  - type: FoamVisuals
    animationTime: 0.6
    animationState: m_foam-dissolve

- type: entity
  id: IronMetalFoam
  name: iron metal foam
  categories: [ HideSpawnMenu ]
  parent: MetalFoam
  components:
  - type: SpawnOnDespawn
    prototype: FoamedIronMetal

- type: entity
  id: AluminiumMetalFoam
  name: aluminium metal foam
  categories: [ HideSpawnMenu ]
  parent: MetalFoam
  components:
  - type: SpawnOnDespawn
    prototype: FoamedAluminiumMetal

- type: entity
  id: BaseFoamedMetal
  name: base foamed metal
  abstract: true
  placement:
    mode: SnapgridCenter
    snap:
    - Wall
  components:
  - type: RCDDeconstructable
    cost: 2
    delay: 2
    fx: EffectRCDDeconstruct2
  - type: Clickable
  - type: InteractionOutline
  - type: Sprite
    drawdepth: Walls
  - type: Physics
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb {}
        layer:
        - WallLayer
        mask:
        - WallLayer
  - type: Occluder
  - type: Appearance
  - type: SmoothEdge
  - type: IconSmooth
    key: walls
    mode: NoSprite
  - type: Transform
    anchored: true
  - type: Airtight
  - type: ReplaceFloorOnSpawn
    replaceableTiles:
    - Plating
    - Lattice
    - TrainLattice
    replacementTiles:
    - FloorMetalFoam
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 12
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]

- type: entity
  id: FoamedIronMetal
  name: foamed iron metal
  description: "For sealing hull breaches."
  parent: BaseFoamedMetal
  components:
  - type: Sprite
    drawdepth: Effects
    color: "#ffffffcc"
    sprite: Effects/foam.rsi
    layers:
    - state: iron_foam
      map: ["enum.FoamVisualLayers.Base"]
    - map: [ "enum.EdgeLayer.South" ]
      state: iron_foam-south
    - map: [ "enum.EdgeLayer.East" ]
      state: iron_foam-east
    - map: [ "enum.EdgeLayer.North" ]
      state: iron_foam-north
    - map: [ "enum.EdgeLayer.West" ]
      state: iron_foam-west

- type: entity
  id: FoamedAluminiumMetal
  name: foamed aluminium metal
  description: "Leftover sparse foam from an aluminum foam grenade. Easily destroyed."
  parent: BaseFoamedMetal
  components:
  - type: Sprite
    drawdepth: Effects
    color: "#ffffffcc"
    sprite: Effects/foam.rsi
    layers:
    - state: metal_foam
      map: ["enum.FoamVisualLayers.Base"]
    - map: [ "enum.EdgeLayer.South" ]
      state: metal_foam-south
    - map: [ "enum.EdgeLayer.East" ]
      state: metal_foam-east
    - map: [ "enum.EdgeLayer.North" ]
      state: metal_foam-north
    - map: [ "enum.EdgeLayer.West" ]
      state: metal_foam-west
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: FlimsyMetallic
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 1 # Intentionally very weak to encourage speedy repair, think of it as thin webbing
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]

- type: entity
  id: ReactionFlash
  categories: [ HideSpawnMenu ]
  components:
  - type: PointLight
    enabled: true
    radius: 2
    energy: 8
  - type: LightFade
    duration: 0.5
  - type: TimedDespawn
    lifetime: 0.5


# Assmos - Extinguisher Nozzle
- type: entity
  parent: BaseFoam
  id: Resin
  name: resin
  categories: [ HideSpawnMenu ]
  components:
  - type: Sprite
    color: "#ffffffcc"
    sprite: Effects/foam.rsi
    layers:
    - state: resin
      map: ["enum.FoamVisualLayers.Base"]
    - map: [ "enum.EdgeLayer.South" ]
      state: resin-south
    - map: [ "enum.EdgeLayer.East" ]
      state: resin-east
    - map: [ "enum.EdgeLayer.North" ]
      state: resin-north
    - map: [ "enum.EdgeLayer.West" ]
      state: resin-west
  - type: SmoothEdge
  - type: IconSmooth
    mode: NoSprite
  - type: FoamVisuals
    animationTime: 0.6
    animationState: resin-dissolve
  - type: AtmosResinDespawn
