# SPDX-FileCopyrightText: 2021 20kdc <asdd2808@gmail.com>
# SPDX-FileCopyrightText: 2021 DrSmugleaf <DrSmugleaf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Metal Gear Sloth <metalgearsloth@gmail.com>
# SPDX-FileCopyrightText: 2021 Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
# SPDX-FileCopyrightText: 2021 Swept <sweptwastaken@protonmail.com>
# SPDX-FileCopyrightText: 2021 Vera Aguilera Puerto <zddm@outlook.es>
# SPDX-FileCopyrightText: 2021 Visne <39844191+Visne@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 Peptide90 <78795277+Peptide90@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Profane McBane <profanedbane+github@gmail.com>
# SPDX-FileCopyrightText: 2022 keronshb <54602815+keronshb@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 metalgearsloth <comedian_vs_clown@hotmail.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 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Vera Aguilera Puerto <6766154+Zumorica@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 Ilya246 <57039557+Ilya246@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  id: UnfinishedMachineFrame
  name: machine frame
  description: A machine under construction. Needs more parts.
  suffix: Unfinished
  placement:
    mode: SnapgridCenter
  components:
    - type: Transform
      anchored: true
    - type: Physics
      bodyType: Static
    - type: Fixtures
      fixtures:
        fix1:
          shape:
            !type:PhysShapeAabb
            bounds: "-0.25,-0.5,0.25,0.5"
          density: 190
          mask:
          - MachineMask
          layer:
          - MachineLayer
    - type: Clickable
    - type: InteractionOutline
    - type: Anchorable
    - type: Rotatable
    - type: Pullable
    - type: Construction
      containers:
        - machine_board
        - machine_parts
      graph: Machine
      node: missingWires
    - type: ContainerContainer
      containers:
        machine_board: !type:Container
        machine_parts: !type:Container
    - type: Damageable
      damageContainer: StructuralInorganic
      damageModifierSet: Metallic
    - type: Destructible
      thresholds:
      - trigger: # Excess damage, don't spawn entities
          !type:DamageTrigger
          damage: 200
        behaviors:
        - !type:PlaySoundBehavior
          sound:
            collection: MetalBreak
        - !type:DoActsBehavior
          acts: ["Destruction"]
      - trigger:
          !type:DamageTrigger
          damage: 100
        behaviors:
        - !type:PlaySoundBehavior
          sound:
            collection: MetalBreak
        - !type:ChangeConstructionNodeBehavior
          node: start
        - !type:DoActsBehavior
          acts: ["Destruction"]
    - type: Sprite
      sprite: Structures/Machines/parts.rsi
      state: box_0
      snapCardinals: true

- type: entity
  id: MachineFrame
  name: machine frame
  suffix: Ready
  placement:
    mode: SnapgridCenter
  components:
    - type: Transform
      anchored: true
    - type: Physics
      bodyType: Static
    - type: Fixtures
      fixtures:
        fix1:
          shape:
            !type:PhysShapeAabb
            bounds: "-0.25,-0.5,0.25,0.5"
          density: 190
          mask:
          - MachineMask
          layer:
          - MachineLayer
    - type: Clickable
    - type: InteractionOutline
    - type: Anchorable
    - type: Rotatable
    - type: Pullable
    - type: Construction
      graph: Machine
      node: machineFrame
      defaultTarget: machine
      containers:
        - machine_board
        - machine_parts
    - type: Damageable
      damageContainer: StructuralInorganic
      damageModifierSet: Metallic
    - type: Destructible
      thresholds:
      - trigger: # Excess damage, don't spawn entities
          !type:DamageTrigger
          damage: 200
        behaviors:
        - !type:PlaySoundBehavior
          sound:
            collection: MetalBreak
        - !type:DoActsBehavior
          acts: ["Destruction"]
      - trigger:
          !type:DamageTrigger
          damage: 100
        behaviors:
        - !type:PlaySoundBehavior
          sound:
            collection: MetalBreak
        - !type:ChangeConstructionNodeBehavior
          node: missingWires
        - !type:DoActsBehavior
          acts: ["Destruction"]
    - type: MachineFrame
    - type: ContainerContainer
      containers:
        machine_board: !type:Container
        machine_parts: !type:Container
    - type: Sprite
      sprite: Structures/Machines/parts.rsi
      state: box_1
      snapCardinals: true
    - type: Appearance
    - type: ItemMapper
      mapLayers:
        box_2:
          minCount: 1
          whitelist:
            components:
            - MachineBoard

- type: entity
  id: MachineFrameDestroyed
  parent: BaseStructureDynamic
  name: destroyed machine frame
  placement:
    mode: SnapgridCenter
  components:
    - type: Transform
      anchored: true
      noRot: true
    - type: Physics
      bodyType: Static
    - type: Construction
      graph: Machine
      node: destroyedMachineFrame
    - type: Damageable
      damageContainer: StructuralInorganic
      damageModifierSet: Metallic
    - type: Destructible
      thresholds:
      - trigger: # Excess damage, don't spawn entities
          !type:DamageTrigger
          damage: 200
        behaviors:
        - !type:DoActsBehavior
          acts: ["Destruction"]
      - trigger:
          !type:DamageTrigger
          damage: 100
        behaviors:
        - !type:SpawnEntitiesBehavior
          spawn:
            SheetSteel1:
              min: 1
              max: 3
        - !type:DoActsBehavior
          acts: ["Destruction"]
    - type: Sprite
      sprite: Structures/Machines/parts.rsi
      state: destroyed