- type: entity
  abstract: true
  parent: [ SolutionTank, SolutionHuge, DisposalUnitBase, SeatBase, StructureHealthFurnitureStrong ]
  id: BaseToilet
  name: toilet
  description: The HT-451, a torque rotation-based, waste disposal unit for small matter. This one seems remarkably clean.
  components:
  - type: Sprite
    sprite: Structures/Furniture/toilet.rsi
    layers:
    - map: [ "enum.DisposalUnitVisualLayers.Base" ]
      state: disposal
    - map: [ "enum.DisposalUnitVisualLayers.OverlayCharging" ]
      state: dispover-ready
  - type: GenericVisualizer
    visuals:
      enum.DisposalUnitVisuals.IsReady:
        enum.DisposalUnitVisualLayers.Base:
          True: { state: disposal }
          False: { state: disposal-charging }
      enum.DisposalUnitVisuals.IsCharging:
        enum.DisposalUnitVisualLayers.OverlayCharging:
          True: { state: dispover-charge, visible: true }
          False: { state: dispover-ready, visible: true }
      enum.PowerDeviceVisuals.Powered:
        enum.DisposalUnitVisualLayers.OverlayCharging:
          False: { visible: false }
      enum.AnchorVisuals.Anchored:
        enum.DisposalUnitVisualLayers.Base:
          True: { state: disposal }
          False: { state: condisposal }
        enum.DisposalUnitVisualLayers.OverlayCharging:
          False: { visible: false }
      enum.ToiletVisuals.SeatVisualState:
        SeatVisualState.SeatUp:
          SeatUp: { state: disposal-up }
          SeatDown: { state: disposal-down }
      enum.ToolOpenableVisuals.ToolOpenableVisualState:
        ToolOpenableVisualState.StashOpen:
          Open: { state: disposal-open }
          Closed: { state: disposal-closed }
  - type: Rotatable
  - type: Transform
    noRot: false
  - type: Strap
    whitelist:
      components:
      - HumanoidProfile
  - type: DisposalUnit
    container:
      occludes: true
      showEnts: false
      ents: []
    blacklist:
      components:
      - HumanoidProfile
      - Plunger
      - SolutionTransfer
      - EntityStorage
    whitelist:
      components:
      - Item
    soundFlush: /Audio/Effects/Fluids/flush.ogg
    soundInsert: /Audio/Effects/Fluids/splash.ogg
  - type: Toilet
  - type: ContainerContainer
    containers:
      stash: !type:ContainerSlot {}
      DisposalUnitComponent: !type:Container
      solutions: !type:Container
  - type: Physics
    bodyType: Static
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeCircle
          radius: 0.4
        density: 190
        mask:
        - MachineMask
        layer:
        - None
  - type: Appearance
  - type: SecretStash
    secretStashName: secret-stash-toilet
  - type: ToolOpenable
    openToolQualityNeeded: Prying
    closeToolQualityNeeded: Prying
    name: secret-stash-toilet
  - type: Drain
    autoDrain: false
  - type: StaticPrice
    price: 100
  - type: ActivatableUI
    key: enum.DisposalUnitUiKey.Key
    verbOnly: true # Not strictly needed, but we want E to toggle lid
  - type: UserInterface
    interfaces:
      enum.DisposalUnitUiKey.Key:
        type: DisposalUnitBoundUserInterface
  - type: SolutionManager
    solutions:
    - SolutionDrainNormal
  - type: DrainableSolution
    solution: tank
  - type: ReagentTank
  - type: DumpableSolution
    solution: drainBuffer
  - type: Edible
    edible: Drink
    solution: tank
    destroyOnEmpty: false
    utensil: Spoon
  - type: SolutionRegeneration
    generated:
      reagents:
      - ReagentId: Water
        Quantity: 1
  - type: Damageable
    damageModifierSet: SteelMod
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 80
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak

# constructed toilets don't come with Rummageable or plungeruse component to avoid infinite item spawning.
- type: entity
  parent: BaseToilet
  id: ConstructedToilet
  name: toilet
  description: The HT-451, a torque rotation-based, waste disposal unit for small matter. This one seems remarkably clean.
  suffix: Constructed, Unplungable
  components:
  - type: Construction
    graph: Toilet
    node: toilet

- type: entity
  parent: BaseToilet
  id: ToiletEmpty
  name: toilet
  description: The HT-451, a torque rotation-based, waste disposal unit for small matter. This one seems remarkably clean.
  suffix: Empty
  components:
  - type: PlungerUse
  - type: Rummageable
    table: !type:NestedSelector
      tableId: RatKingLoot

# so theres not actually any way to replenish the gastrotoxin / gold in these.
# I wouldn't add it to the solutionregeneration comp because that doesn't make a lot of sense imo.
- type: entity
  parent: ToiletEmpty
  id: ToiletDirtyWater
  suffix: Dirty Water
  components:
  - type: Solution
    solution:
        reagents:
        - ReagentId: Water
          Quantity: 180
        - ReagentId: GastroToxin
          Quantity: 20

- type: entity
  parent: ToiletEmpty
  id: ToiletFilled
  suffix: Empty, Random Cistern Loot
  components:
  - type: EntityTableContainerFill
    containers:
      stash: !type:NestedSelector
        tableId: ToiletCisternLoot
        rolls: !type:RangeNumberSelector
          range: 0, 1

- type: entity
  parent: ToiletDirtyWater
  id: ToiletDirtyWaterFilled
  suffix: Dirty Water, Random Cistern Loot
  components:
  - type: EntityTableContainerFill
    containers:
      stash: !type:NestedSelector
        tableId: ToiletCisternLoot
        rolls: !type:RangeNumberSelector
          range: 0, 1

- type: entity
  parent: BaseToilet
  id: ToiletGoldenEmpty
  name: golden toilet
  description: The HT-451G is the gold version of the device. It says on the side that it is made of the purest Mercurian gold and a real leather seat.
  suffix: Empty
  components:
  - type: Sprite
    sprite: Structures/Furniture/golden_toilet.rsi
  - type: StaticPrice
    price: 1500
  - type: Damageable
    damageModifierSet: PreciousMetalMod
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 80
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          IngotGold1:
            min: 5
            max: 5
  - type: PlungerUse
  - type: Rummageable
    table: !type:NestedSelector
      tableId: RatKingLoot

- type: entity
  parent: ToiletGoldenEmpty
  id: ToiletGoldenDirtyWater
  suffix: Dirty Water, StealTarget
  components:
  - type: StealTarget
    stealGroup: ToiletGoldenDirtyWater
  - type: Solution
    solution:
        reagents:
        - ReagentId: Water
          Quantity: 160
        - ReagentId: Gold
          Quantity: 20
        - ReagentId: GastroToxin
          Quantity: 20
