- type: entity
  parent: BaseStructureDynamic
  id: BaseGlassBox
  abstract: true
  components:
  - type: Sprite
    noRot: true
    sprite: Structures/Storage/glassbox.rsi
  - type: Transform
    anchored: true
  - type: Physics
    bodyType: Static
  - type: InteractionOutline
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.45,-0.45,0.45,0.45"
        density: 1000
        mask:
        - MachineMask
        layer:
        - MidImpassable
        - LowImpassable
  - type: Anchorable
    delay: 4

- type: entity
  parent: [BaseGlassBox, BaseItemCabinetGlass]
  id: GlassBox
  name: glass box
  description: A sturdy showcase for an expensive exhibit.
  abstract: true # TODO: Temporarily abstract. Remove it after item scaling in cabinets is implemented.
  components:
  - type: Sprite
    layers:
    - state: base
    - state: caplaser # TODO: Remove it after item scaling in cabinets is implemented.
      map: ["enum.ItemCabinetVisuals.Layer"]
      visible: false
    - state: glass
      map: ["enum.OpenableVisuals.Layer"]
    - state: locked
      shader: unshaded
      map: ["enum.LockVisualLayers.Lock"]
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.45,-0.45,0.45,0.45"
        density: 1000
        mask:
        - MachineMask
        layer:
        - LowImpassable
        - MidImpassable
        - BulletImpassable
  - type: AccessReader
  - type: Repairable
    fuelCost: 15
    doAfterDelay: 5
  - type: Lock
  - type: LockVisuals
  - type: DamageVisuals
    thresholds: [4, 8, 12] # TODO: Fix damage visuals on open state.
    damageDivisor: 7.555
    trackAllDamage: true
    damageOverlay:
      sprite: Structures/Storage/glassbox.rsi
  - type: Damageable
    damageModifierSet: Glass
  - type: Injurable
    damageContainer: StructuralInorganic
  - type: MeleeSound
    soundGroups:
      Brute:
        collection: GlassSmash
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 150
      behaviors:
      - !type:EmptyAllContainersBehaviour
      - !type:PlaySoundBehavior
        sound:
          collection: WindowShatter
      - !type:PlaySoundBehavior
        sound:
          path: /Audio/Machines/warning_buzzer.ogg
          params:
            volume: 10
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlassReinforced:
            min: 1
            max: 2
      - !type:ChangeConstructionNodeBehavior
        node: brokenGlassBox
      - !type:DoActsBehavior
        acts: [ "Destruction" ]

- type: entity
  parent: GlassBox
  id: GlassBoxLaser
  suffix: AntiqueLaser
  components:
  - type: AccessReader
    access: [["Captain"]]
  - type: Construction
    graph: GlassBox
    node: glassBox
  - type: ItemSlots
    slots:
      ItemCabinet:
        ejectOnInteract: true
        whitelist:
          tags:
          - WeaponAntiqueLaser
        ejectSound: /Audio/Machines/machine_switch.ogg

- type: entity
  parent: GlassBoxLaser
  id: GlassBoxLaserOpen
  suffix: AntiqueLaser, Open
  components:
  - type: Openable
    opened: true
  - type: Lock
    locked: false

- type: entity
  parent: GlassBoxLaser
  id: GlassBoxLaserFilled
  suffix: AntiqueLaser, Filled
  components:
  - type: ContainerFill
    containers:
      ItemCabinet:
      - WeaponAntiqueLaser

- type: entity
  parent: [GlassBoxLaserFilled, GlassBoxLaserOpen]
  id: GlassBoxLaserFilledOpen
  suffix: AntiqueLaser, Filled, Open

- type: entity
  parent: BaseGlassBox
  id: GlassBoxFrame
  name: glass box frame
  description: A glassless sturdy showcase for an expensive exhibit.
  suffix: Frame
  components:
  - type: Sprite
    layers:
    - state: base
  - type: Construction
    graph: GlassBox
    node: boxMissingWires
  - type: Climbable
  - type: Damageable
    damageModifierSet: Wood
  - type: Injurable
    damageContainer: StructuralInorganic
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: WoodDestroy
      - !type:SpawnEntitiesBehavior
        spawn:
          MaterialWoodPlank1:
            min: 2
            max: 5
      - !type:DoActsBehavior
        acts: ["Destruction"]

- type: entity
  parent: GlassBoxFrame
  id: GlassBoxBroken
  name: broken glass box
  description: A broken showcase for a stolen expensive exhibit.
  suffix: Broken
  components:
  - type: Sprite
    layers:
    - state: base
    - state: glass-broken
  - type: Construction
    graph: GlassBox
    node: brokenGlassBox
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: WoodDestroy
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlassReinforced:
            min: 1
            max: 1
          MaterialWoodPlank1:
            min: 2
            max: 5
      - !type:DoActsBehavior
        acts: ["Destruction"]
