- type: entity
  id: TableFrame
  # BaseStructure and not BaseTable, since these shouldn't be climbable/placeable.
  parent: BaseStructure
  name: table frame
  description: Pieces of metal that make the frame of a table.
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/frame.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/frame.rsi
    state: full
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.40,-0.30,0.40,0.45"
        density: 80
        mask:
        - TableMask
        layer:
        - TableLayer
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Metallic
  - type: IconSmooth
    key: state
    base: state_
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 25
      behaviors:
        - !type:DoActsBehavior
          acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 5
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
          params:
            volume: -6
      - !type:SpawnEntitiesBehavior
        spawn:
          PartRodMetal1:
            min: 1
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: Construction
    graph: Table
    node: TableFrame

- type: entity
  id: CounterWoodFrame
  parent: BaseStructure
  name: wooden counter frame
  description: Pieces of wood that make the frame of a table.
  components:
  - type: SpriteFade
  - type: Sprite
    sprite: Structures/Furniture/Tables/frame.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/frame.rsi
    state: full
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.45,-0.45,0.45,0.45"
        density: 55
        mask:
        - TableMask
        layer:
        - TableLayer
        - BulletImpassable #Goobstation
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Wood
  - type: IconSmooth
    key: state
    base: state_
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 15
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: WoodDestroy
      - !type:SpawnEntitiesBehavior
        spawn:
          MaterialWoodPlank1:
            min: 0
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: Construction
    graph: Table
    node: CounterWoodFrame
  - type: RequireProjectileTarget # Goobstation - Crawling
    ignoreThrow: true

- type: entity
  id: CounterMetalFrame
  parent: CounterWoodFrame
  name: metal counter frame
  description: Pieces of metal that make the frame of a table.
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/frame.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/frame.rsi
    state: full
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Metallic
  - type: IconSmooth
    key: state
    base: state_
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 125
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 25
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
          params:
            volume: -6
      - !type:SpawnEntitiesBehavior
        spawn:
          SheetSteel1:
            min: 0
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: Construction
    graph: Table
    node: CounterMetalFrame

- type: entity
  id: Table
  parent: TableBase
  name: table
  description: A square piece of metal standing on four metal legs.
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/generic.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/generic.rsi
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 125
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 25
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
          params:
            volume: -6
      - !type:SpawnEntitiesBehavior
        spawn:
          SheetSteel1:
            min: 1
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: IconSmooth
    key: metaltable
    base: state_
  - type: Construction
    graph: Table
    node: Table

- type: entity
  id: TableReinforced
  parent: TableBase
  name: reinforced table
  description: A square piece of metal standing on four metal legs. Extra robust.
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/reinforced.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/reinforced.rsi
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 150
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 75
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
          params:
            volume: -6
      - !type:SpawnEntitiesBehavior
        spawn:
          SheetSteel1:
            min: 2
            max: 2
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: IconSmooth
    key: metalreinforcedtable
  - type: Construction
    graph: Table
    node: TableReinforced
  - type: Climbable
    # Reinforced tables are extra tough
  - type: Bonkable
    bonkDamage:
      types:
        Blunt: 8
    bonkTime: 3

- type: entity
  id: TableGlass
  parent: TableBase
  name: glass table
  description: A square piece of glass, standing on four metal legs.
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/glass.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/glass.rsi
  - type: GlassTable
    climberDamage:
      types:
        Slash: 15
    tableDamage:
      types:
        Blunt: 25
    tableMassLimit: 60
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 25
      behaviors:
        - !type:DoActsBehavior
          acts: [ "Destruction" ]
        - !type:PlaySoundBehavior
          sound:
            collection: GlassBreak
    - trigger:
        !type:DamageTrigger
        damage: 5
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlass:
            min: 1
            max: 1
      - !type:ChangeConstructionNodeBehavior
        node: TableFrame
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: IconSmooth
    key: glasstable
  - type: Construction
    graph: Table
    node: TableGlass
  - type: FootstepModifier
    footstepSoundCollection:
      collection: FootstepTile

- type: entity
  id: TableReinforcedGlass
  parent: TableBase
  name: reinforced glass table
  description: A square piece of glass, standing on four metal legs. Extra robust.
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/r_glass.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/r_glass.rsi
  - type: GlassTable
    climberDamage:
      types:
        Slash: 25
    tableDamage:
      types:
        Blunt: 40
    tableMassLimit: 120
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors: #excess damage (nuke?). avoid computational cost of spawning entities.
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
    - trigger:
        !type:DamageTrigger
        damage: 20
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:ChangeConstructionNodeBehavior
        node: TableFrame
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlass:
            min: 1
            max: 1
          PartRodMetal1:
            min: 1
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: IconSmooth
    key: reinforcedglasstable
  - type: Construction
    graph: Table
    node: TableReinforcedGlass
  - type: FootstepModifier
    footstepSoundCollection:
      collection: FootstepTile

- type: entity
  id: TablePlasmaGlass
  parent: TableBase
  name: plasma glass table
  description: A square piece of plasma glass, standing on four metal legs. Pretty!
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/plasma.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/plasma.rsi
  - type: GlassTable
    climberDamage:
      types:
        Slash: 30
    tableDamage:
      types:
        Blunt: 100
    tableMassLimit: 240
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 250
      behaviors: #excess damage (nuke?). avoid computational cost of spawning entities.
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
      - !type:ChangeConstructionNodeBehavior
        node: TableFrame
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlassPlasma:
            min: 1
            max: 1
          PartRodMetal1:
            min: 1
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: IconSmooth
    key: plasmaglasstable
  - type: Construction
    graph: Table
    node: TablePlasmaGlass
  - type: FootstepModifier
    footstepSoundCollection:
      collection: FootstepTile

- type: entity
  id: TableBrass
  parent: TableBase
  name: brass table
  description: A shiny, corrosion resistant brass table. Steampunk!
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/brass.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/brass.rsi
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 125
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 25
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
          params:
            volume: -6
      - !type:SpawnEntitiesBehavior
        spawn:
          SheetBrass1:
            min: 1
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: IconSmooth
    key: brasstable
  - type: Construction
    graph: Table
    node: TableBrass

- type: entity
  id: TableWood
  parent: TableBase
  name: wood table
  description: Do not apply fire to this. Rumour says it burns easily.
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/wood.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/wood.rsi
  - type: Damageable
    damageModifierSet: Wood
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors: #excess damage (nuke?). avoid computational cost of spawning entities.
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
      - !type:PlaySoundBehavior
        sound:
          collection: GlassBreak
    - trigger:
        !type:DamageTrigger
        damage: 15
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: WoodDestroy
      - !type:SpawnEntitiesBehavior
        spawn:
          MaterialWoodPlank:
            min: 1
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: IconSmooth
    key: woodtable
  - type: Construction
    graph: Table
    node: TableWood
  - type: Tag
    tags:
    - Wooden
  - type: FootstepModifier
    footstepSoundCollection:
      collection: FootstepWood

- type: entity
  id: TableCarpet
  parent: TableBase
  name: gambling table
  description: Play em' cowboy.
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/carpet.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/carpet.rsi
  - type: Damageable
    damageModifierSet: Wood
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 15
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: WoodDestroy
      - !type:SpawnEntitiesBehavior
        spawn:
          MaterialWoodPlank:
            min: 1
            max: 1
          MaterialCloth1:
            min: 1
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: IconSmooth
    key: woodgambletable
  - type: Construction
    graph: Table
    node: TableCarpet
  - type: Tag
    tags:
    - Wooden
  - type: FootstepModifier
    footstepSoundCollection:
      collection: FootstepCarpet

- type: entity
  id: TableStone
  parent: TableBase
  name: stone table
  description: Literally the sturdiest thing you have ever seen.
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/stone.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/stone.rsi
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          path: /Audio/Effects/picaxe2.ogg
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: IconSmooth
    key: stonetable
  - type: FootstepModifier
    footstepSoundCollection:
      collection: FootstepFloor

- type: entity
  id: TableWeb
  parent: TableBase
  name: web table
  description: Really smooth and surprisingly durable.
  components:
  - type: Damageable
    damageModifierSet: Web
  - type: Sprite
    sprite: Structures/Furniture/Tables/web.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/web.rsi
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: MeleeSound
    soundGroups:
      Brute:
        path:
          "/Audio/Weapons/slash.ogg"
  - type: IconSmooth
    key: webtable
  - type: Construction
    graph: WebStructures
    node: table
  - type: FootstepModifier
    footstepSoundCollection:
      collection: FootstepCarpet

- type: entity
  parent: TableBase
  id: TableXeno
  name: xeno table
  description: I wouldn't put the silverware on it.
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/xeno.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/xeno.rsi
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: gib
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: FootstepModifier
    footstepSoundCollection:
      collection: FootstepFloor

# Fancy tables

- type: entity
  id: TableFancyBase
  abstract: true
  parent: TableBase
  name: fancy table
  description: Expensive and rich.
  components:
  - type: Damageable
    damageModifierSet: Wood
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 25
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: WoodDestroy
      - !type:SpawnEntitiesBehavior
        spawn:
          MaterialWoodPlank:
            min: 1
            max: 1
          MaterialCloth1:
            min: 1
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: IconSmooth
    key: fancytable
  - type: Tag
    tags:
    - Wooden
  - type: FootstepModifier
    footstepSoundCollection:
      collection: FootstepCarpet

- type: entity
  id: TableFancyBlue
  parent: TableFancyBase
  suffix: Blue
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/Fancy/blue.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/Fancy/blue.rsi
  - type: Construction
    graph: Table
    node: TableFancyBlue
  - type: IconSmooth
    key: fancytableblue

- type: entity
  id: TableFancyCyan
  parent: TableFancyBase
  suffix: Cyan
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/Fancy/cyan.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/Fancy/cyan.rsi
  - type: Construction
    graph: Table
    node: TableFancyCyan
  - type: IconSmooth
    key: fancytablecyan

- type: entity
  id: TableFancyBlack
  parent: TableFancyBase
  suffix: Black
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/Fancy/black.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/Fancy/black.rsi
  - type: Construction
    graph: Table
    node: TableFancyBlack
  - type: IconSmooth
    key: fancytableblack

- type: entity
  id: TableFancyRed
  parent: TableFancyBase
  suffix: Red
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/Fancy/red.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/Fancy/red.rsi
  - type: Construction
    graph: Table
    node: TableFancyRed
  - type: IconSmooth
    key: fancytablered

- type: entity
  id: TableFancyPurple
  parent: TableFancyBase
  suffix: Purple
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/Fancy/purple.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/Fancy/purple.rsi
  - type: Construction
    graph: Table
    node: TableFancyPurple
  - type: IconSmooth
    key: fancytablepurple

- type: entity
  id: TableFancyPink
  parent: TableFancyBase
  suffix: Pink
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/Fancy/pink.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/Fancy/pink.rsi
  - type: Construction
    graph: Table
    node: TableFancyPink
  - type: IconSmooth
    key: fancytablepink

- type: entity
  id: TableFancyGreen
  parent: TableFancyBase
  suffix: Green
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/Fancy/green.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/Fancy/green.rsi
  - type: Construction
    graph: Table
    node: TableFancyGreen
  - type: IconSmooth
    key: fancytablegreen

- type: entity
  id: TableFancyOrange
  parent: TableFancyBase
  suffix: Orange
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/Fancy/orange.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/Fancy/orange.rsi
  - type: Construction
    graph: Table
    node: TableFancyOrange
  - type: IconSmooth
    key: fancytableorange

- type: entity
  id: TableFancyWhite
  parent: TableFancyBase
  suffix: White
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/Fancy/white.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/Fancy/white.rsi
  - type: Construction
    graph: Table
    node: TableFancyWhite
  - type: IconSmooth
    key: fancytablewhite

#Debug

- type: entity
  id: TableDebug
  parent: TableBase
  name: table
  description: PUT ON THEM CODERSOCKS!!
  suffix: DEBUG
  components:
  - type: Tag
    tags:
      - Debug
  - type: Sprite
    sprite: Structures/Furniture/Tables/debug.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/debug.rsi
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 1
      behaviors:
      - !type:DoActsBehavior
        acts: ["Destruction"]

# counters

- type: entity
  id: TableCounterWood
  parent: CounterBase
  name: wood counter
  description: Do not apply fire to this. Rumour says it burns easily.
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/counterwood.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/counterwood.rsi
    state: full
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Wood
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 15
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: WoodDestroy
      - !type:SpawnEntitiesBehavior
        spawn:
          MaterialWoodPlank1:
            min: 0
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: IconSmooth
    key: counterwood
    base: state_
  - type: Construction
    graph: Table
    node: CounterWood
  - type: FootstepModifier
    footstepSoundCollection:
      collection: FootstepWood

- type: entity
  id: TableCounterMetal
  parent: CounterBase
  name: metal counter
  description: Looks like a good place to put a drink down.
  components:
  - type: Sprite
    sprite: Structures/Furniture/Tables/countermetal.rsi
  - type: Icon
    sprite: Structures/Furniture/Tables/countermetal.rsi
    state: full
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 125
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 25
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
          params:
            volume: -6
      - !type:SpawnEntitiesBehavior
        spawn:
          SheetSteel1:
            min: 0
            max: 1
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: IconSmooth
    key: countermetal
    base: state_
  - type: Construction
    graph: Table
    node: CounterMetal
