# SPDX-FileCopyrightText: 2022 EmoGarbage404 <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Fishfish458 <47410468+Fishfish458@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 fishfish458 <fishfish458>
# SPDX-FileCopyrightText: 2022 rolfero <45628623+rolfero@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 TemporalOroboros <TemporalOroboros@gmail.com>
# SPDX-FileCopyrightText: 2023 lapatison <100279397+lapatison@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Cojoke <83733158+Cojoke-dot@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Ilya246 <57039557+Ilya246@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2024 Nairod <110078045+Nairodian@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Piras314 <p1r4s@proton.me>
# SPDX-FileCopyrightText: 2024 lzk <124214523+lzk228@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 slarticodefast <161409025+slarticodefast@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entityTable
  id: FilingCabinetFillTable
  table: !type:AllSelector
    children:
    - !type:GroupSelector
      rolls: !type:RangeNumberSelector
        range: 2, 4
      children:
      - id: BoxFolderBlue
      - id: BoxFolderRed
      - id: BoxFolderYellow
      - id: BoxFolderWhite
      - id: BoxFolderGrey
      - id: BoxFolderBlack
    - !type:GroupSelector
      rolls: !type:RangeNumberSelector
        range: 0, 3
      children:
      - id: Paper
      - id: PaperOffice
    - !type:GroupSelector
      prob: .3
      rolls: !type:ConstantNumberSelector
        value: 2
      children:
      - id: Pen
    - !type:GroupSelector
      prob: 0.15
      children:
      - !type:AllSelector
        weight: 0.2
        children:
        - id: RubberStampApproved
        - id: RubberStampDenied
      - id: RubberStampGreytide
        weight: 0.1
      - id: LuxuryPen
      - id: NanoTaskCartridge

- type: entity
  parent: [ BaseStructureDynamic, BaseBagOpenClose ]
  id: BaseFilingCabinet
  description: A cabinet for all your filing needs.
  suffix: Empty
  abstract: true
  components:
  - type: Storage
    grid:
    - 0,0,9,3
    maxItemSize: Normal
  - type: Sprite
    sprite: Structures/Storage/cabinets.rsi
    noRot: true
  - type: Appearance
  - type: UserInterface
    interfaces:
      enum.StorageUiKey.Key:
        type: StorageBoundUserInterface
  - type: Transform
    noRot: true
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.18,-0.48,0.18,0.48"
        density: 200
        mask:
        - MachineMask
        layer:
        - MachineLayer
  - type: InteractionOutline
  - type: ContainerContainer
    containers:
      storagebase: !type:Container
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Metallic
  - type: Destructible
    thresholds:
    - trigger: # Excess damage, don't spawn entities
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
      - !type:DoActsBehavior
        acts: ["Destruction"]
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:DoActsBehavior
        acts: ["Destruction"]
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
      - !type:SpawnEntitiesBehavior
        spawn:
          SheetSteel1:
            min: 1
            max: 2
  - type: StaticPrice
    price: 80
  - type: Construction
    graph: FilingCabinet

- type: entity
  name: filing cabinet
  parent: BaseFilingCabinet
  id: filingCabinet
  components:
  - type: Sprite
    state: filingcabinet
    layers:
    - state: filingcabinet
    - state: filingcabinet-open
      map: ["openLayer"]
  - type: Construction
    node: filingCabinet

- type: entity
  name: tall cabinet
  parent: BaseFilingCabinet
  id: filingCabinetTall
  components:
  - type: Sprite
    state: tallcabinet
    layers:
    - state: tallcabinet
    - state: tallcabinet-open
      map: ["openLayer"]
  - type: Construction
    node: tallCabinet

- type: entity
  name: chest drawer
  parent: BaseFilingCabinet
  id: filingCabinetDrawer
  description: A small drawer for all your filing needs, Now with wheels!
  components:
  - type: Sprite
    state: chestdrawer
    layers:
    - state: chestdrawer
    - state: chestdrawer-open
      map: ["openLayer"]
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.22,-0.42,0.22,0.34"
        density: 210
        mask:
        - MachineMask
        layer:
        - MachineLayer
  - type: Construction
    node: chestDrawer
  - type: RequireProjectileTarget

- type: entity
  abstract: true
  id: BaseBureaucraticStorageFill
  suffix: Filled
  components:
  - type: EntityTableContainerFill
    containers:
      storagebase: !type:NestedSelector
        tableId: FilingCabinetFillTable

- type: entity
  parent: [BaseBureaucraticStorageFill, filingCabinet]
  id: filingCabinetRandom

- type: entity
  parent: [BaseBureaucraticStorageFill, filingCabinetTall]
  id: filingCabinetTallRandom

- type: entity
  parent: [BaseBureaucraticStorageFill, filingCabinetDrawer]
  id: filingCabinetDrawerRandom