# SPDX-FileCopyrightText: 2019 L.E.D <10257081+unusualcrow@users.noreply.github.com>
# SPDX-FileCopyrightText: 2019 Remie Richards <remierichards@gmail.com>
# SPDX-FileCopyrightText: 2019 moneyl <8206401+Moneyl@users.noreply.github.com>
# SPDX-FileCopyrightText: 2020 AJCM-git <60196617+AJCM-git@users.noreply.github.com>
# SPDX-FileCopyrightText: 2020 Exp <theexp111@gmail.com>
# SPDX-FileCopyrightText: 2020 Hugo Laloge <hugo.laloge@gmail.com>
# SPDX-FileCopyrightText: 2020 Paul Ritter <ritter.paul1@googlemail.com>
# SPDX-FileCopyrightText: 2020 Peter Wedder <burneddi@gmail.com>
# SPDX-FileCopyrightText: 2020 Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
# SPDX-FileCopyrightText: 2020 ike709 <ike709@users.noreply.github.com>
# SPDX-FileCopyrightText: 2020 py01 <60152240+collinlunn@users.noreply.github.com>
# SPDX-FileCopyrightText: 2020 py01 <pyronetics01@gmail.com>
# SPDX-FileCopyrightText: 2020 windarkata <windarkata@gmail.com>
# SPDX-FileCopyrightText: 2021 20kdc <asdd2808@gmail.com>
# SPDX-FileCopyrightText: 2021 Julian Giebel <j.giebel@netrocks.info>
# SPDX-FileCopyrightText: 2021 Julian Giebel <juliangiebel@live.de>
# SPDX-FileCopyrightText: 2021 Metal Gear Sloth <metalgearsloth@gmail.com>
# SPDX-FileCopyrightText: 2021 Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
# SPDX-FileCopyrightText: 2021 ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Swept <sweptwastaken@protonmail.com>
# SPDX-FileCopyrightText: 2021 Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 Vera Aguilera Puerto <zddm@outlook.es>
# SPDX-FileCopyrightText: 2021 Visne <39844191+Visne@users.noreply.github.com>
# SPDX-FileCopyrightText: 2021 metalgearsloth <comedian_vs_clown@hotmail.com>
# SPDX-FileCopyrightText: 2021 mirrorcult <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2022 0x6273 <0x40@keemail.me>
# SPDX-FileCopyrightText: 2022 Flipp Syder <76629141+vulppine@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Illiux <newoutlook@gmail.com>
# SPDX-FileCopyrightText: 2022 Jacob Tong <10494922+ShadowCommander@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Peptide90 <78795277+Peptide90@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Rane <60792108+Elijahrane@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 corentt <36075110+corentt@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 DrSmugleaf <DrSmugleaf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Morb <14136326+Morb0@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Sir Winters <7543955+Owai-Seek@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 TNE <38938720+JustTNE@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 freeman2651 <104049107+freeman2651@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 lzk <124214523+lzk228@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2024 Tayrtahn <tayrtahn@gmail.com>
# SPDX-FileCopyrightText: 2024 Tunguso4ka <71643624+Tunguso4ka@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 yglop <95057024+yglop@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  id: ChemMaster
  parent: [ BaseMachinePowered, ConstructibleMachine ]
  name: ChemMaster 4000
  description: An industrial grade chemical manipulator with pill and bottle production included.
  placement:
    mode: SnapgridCenter
  components:
  - type: Sprite
    sprite: Structures/Machines/mixer.rsi
    snapCardinals: true
    layers:
    - state: mixer_empty
    - state: mixer_screens
      shader: unshaded
      map: ["enum.PowerDeviceVisualLayers.Powered"]
  - type: Icon
    sprite: Structures/Machines/mixer.rsi
    state: mixer_empty
  - type: ItemMapper
    containerWhitelist: [beakerSlot]
    mapLayers:
      mixer_loaded:
        whitelist:
          components:
          - FitsInDispenser
  - type: ChemMaster
    pillDosageLimit: 20
  - type: Physics
    bodyType: Static
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.25,-0.4,0.25,0.4"
        density: 190
        mask:
        - MachineMask
        layer:
        - MachineLayer
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: MetalGlassBreak
      - !type:ChangeConstructionNodeBehavior
        node: machineFrame
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: ActivatableUI
    key: enum.ChemMasterUiKey.Key
  - type: ActivatableUIRequiresPower
  - type: UserInterface
    interfaces:
      enum.ChemMasterUiKey.Key:
        type: ChemMasterBoundUserInterface
  - type: ApcPowerReceiver
    powerLoad: 250
  - type: Appearance
  - type: GenericVisualizer
    visuals:
      enum.PowerDeviceVisuals.Powered:
        enum.PowerDeviceVisualLayers.Powered:
          True: { visible: true }
          False: { visible: false }
  # Machine / Construction stuff
  - type: WiresPanel
  - type: Machine
    board: ChemMasterMachineCircuitboard
  - type: ContainerContainer
    containers:
      beakerSlot: !type:ContainerSlot
      outputSlot: !type:ContainerSlot
      machine_board: !type:Container
      machine_parts: !type:Container
  - type: ItemSlots
    slots:
      beakerSlot:
        whitelist:
          components:
          - FitsInDispenser
      outputSlot:
        whitelistFailPopup: chem-master-component-cannot-put-entity-message
        whitelist:
          tags:
          - Bottle
          - PillCanister
          - MedicalPatch # Goobstation
  - type: AutomationSlots # Goobstation
    slots:
    - !type:AutomatedSolution
      input: PlumbingInput
      output: PlumbingOutput
      solutionName: buffer
    - !type:AutomatedItemSlot
      input: AutomationSlotBeaker
      output: AutomationSlotBeaker
      slotId: beakerSlot
    - !type:AutomatedItemSlot # not very useful because you can't tell it to make pills
      input: AutomationSlotBottles
      output: AutomationSlotBottles
      slotId: outputSlot
    - !type:AutomatedBeakerSlot
      input: PlumbingDispenser
      output: PlumbingDispenser
  - type: SolutionContainerManager
    solutions:
      buffer: # Goobstation - solution shitcode doesnt like max volume 0 and i dont want to rewrite AddSolution
        maxVol: 1000000
  - type: DumpableSolution
    solution: buffer
    unlimited: true
  - type: GuideHelp
    guides:
    - Chemicals
    - Chemist
