# SPDX-FileCopyrightText: 2021 Galactic Chimp <GalacticChimpanzee@gmail.com>
# SPDX-FileCopyrightText: 2021 Julian Giebel <j.giebel@netrocks.info>
# SPDX-FileCopyrightText: 2021 Swept <sweptwastaken@protonmail.com>
# SPDX-FileCopyrightText: 2021 metalgearsloth <comedian_vs_clown@hotmail.com>
# SPDX-FileCopyrightText: 2022 DrSmugleaf <DrSmugleaf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Jacob Tong <10494922+ShadowCommander@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Paul Ritter <ritter.paul1@googlemail.com>
# SPDX-FileCopyrightText: 2022 Peptide90 <78795277+Peptide90@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Visne <39844191+Visne@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Julian Giebel <juliangiebel@live.de>
# SPDX-FileCopyrightText: 2023 Nairod <110078045+Nairodian@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Rane <60792108+Elijahrane@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 eoineoineoin <github@eoinrul.es>
# SPDX-FileCopyrightText: 2023 lzk <124214523+lzk228@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Cojoke <83733158+Cojoke-dot@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Ed <96445749+TheShuEd@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2024 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 brainfood1183 <113240905+brainfood1183@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 nikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 slarticodefast <161409025+slarticodefast@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  abstract: true
  id: DisposalUnitBase
  parent: [ BaseMachinePowered, BaseAutomatedMachine ] # Goob: Automation
  description: A pneumatic waste disposal unit.
  placement:
    mode: SnapgridCenter
    snap:
    - Disposal
  components:
  - type: Climbable
    vaultable: false
  - type: Sprite
    sprite: Structures/Piping/disposal.rsi
    layers:
    - state: condisposal
      map: [ "enum.DisposalUnitVisualLayers.Unanchored" ]
    - state: disposal
      map: [ "enum.DisposalUnitVisualLayers.Base" ]
    - state: disposal-charging
      map: [ "enum.DisposalUnitVisualLayers.BaseCharging" ]
    - state: disposal-flush
      map: [ "enum.DisposalUnitVisualLayers.OverlayFlush" ]
    - state: dispover-charge
      map: [ "enum.DisposalUnitVisualLayers.OverlayCharging" ]
    - state: dispover-ready
      map: [ "enum.DisposalUnitVisualLayers.OverlayReady" ]
    - state: dispover-full
      map: [ "enum.DisposalUnitVisualLayers.OverlayFull" ]
    - state: dispover-handle
      map: [ "enum.DisposalUnitVisualLayers.OverlayEngaged" ]
  - type: Physics
    bodyType: Static
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.45,-0.45,0.45,0.45"
        density: 55
        mask:
        - MachineMask
        layer:
        - MachineLayer
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 200
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 100
      behaviors:
      - !type:DoActsBehavior
        acts: ["Destruction"]
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
          params:
            volume: -6
      - !type:SpawnEntitiesBehavior
        spawn:
          SheetSteel1:
            min: 1
            max: 1
  - type: Appearance
  - type: UserInterface
    interfaces:
      enum.DisposalUnitUiKey.Key:
        type: DisposalUnitBoundUserInterface
  - type: AutomationSlots # Goobstation
    slots:
    - !type:AutomatedContainer
      input: AutomationSlotInput
      output: AutomationSlotInput
      containerId: disposals
      maxItems: 30 # disposals doesn't have a limit this is just so you can't use it as an ME system
    - !type:AutomatedPorts
      sinks:
      - Toggle
      - DisposalFlush
      - DisposalEject
      sources:
      - DisposalReady
  - type: ContainerContainer
    containers:
      disposals: !type:Container
  - type: StaticPrice
    price: 70
  - type: PowerSwitch

- type: entity
  id: DisposalUnit
  parent: DisposalUnitBase
  name: disposal unit
  components:
  - type: Sprite
    sprite: Structures/Piping/disposal.rsi
    snapCardinals: true
  - type: Construction
    graph: DisposalMachine
    node: disposal_unit
  - type: DisposalUnit
  - type: ThrowInsertContainer
    containerId: disposals
    probability: 0.67
  - type: UserInterface
    interfaces:
      enum.DisposalUnitUiKey.Key:
        type: DisposalUnitBoundUserInterface
  - type: Rummageable
    table: !type:NestedSelector
      tableId: RatKingLoot
  - type: RequireProjectileTarget
  # Einstein Engines start
  - type: DeviceLinkSink
    ports:
      - FillbotAnyItem
  # Einstein Engines end

- type: entity
  id: MailingUnit
  parent: DisposalUnitBase
  name: mailing unit
  description: A pneumatic mail delivery unit.
  components:
  - type: Sprite
    sprite: Structures/Piping/disposal.rsi
    snapCardinals: true
    layers:
      - state: conmailing
        map: [ "enum.DisposalUnitVisualLayers.Unanchored" ]
      - state: mailing
        map: [ "enum.DisposalUnitVisualLayers.Base" ]
      - state: mailing-charging
        map: [ "enum.DisposalUnitVisualLayers.BaseCharging" ]
      - state: mailing-flush
        map: [ "enum.DisposalUnitVisualLayers.OverlayFlush" ]
      - state: dispover-charge
        map: [ "enum.DisposalUnitVisualLayers.OverlayCharging" ]
      - state: dispover-ready
        map: [ "enum.DisposalUnitVisualLayers.OverlayReady" ]
      - state: dispover-full
        map: [ "enum.DisposalUnitVisualLayers.OverlayFull" ]
      - state: mailover-handle
        map: [ "enum.DisposalUnitVisualLayers.OverlayEngaged" ]
  - type: Construction
    graph: DisposalMachine
    node: mailing_unit
  - type: DisposalUnit
    whitelist:
      components:
      - Item
    blacklist:
      components:
      - EntityStorage
  - type: MailingUnit
  - type: DeviceNetwork
    deviceNetId: Wired
    receiveFrequencyId: MailingUnit
    transmitFrequencyId: MailingUnit
  - type: WiredNetworkConnection
  - type: Configuration
    config:
      tag:
  - type: Appearance
  - type: UserInterface
    interfaces:
      enum.MailingUnitUiKey.Key:
        type: MailingUnitBoundUserInterface
      enum.ConfigurationUiKey.Key:
        type: ConfigurationBoundUserInterface
  # Einstein Engines start
  - type: DeviceLinkSink
    ports:
      - FillbotAnyItem
  # Einstein Engines end
