- type: entity
  abstract: true
  parent: BaseStructure
  id: BaseBed
  components:
  - type: HealOnBuckle
    damage:
      types:
        Poison: -0.1
        Blunt: -0.1
  - type: Physics
    bodyType: Static
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.45,-0.45,0.45,0.05"
        density: 190
        mask:
        - TableMask
  - type: Sprite
    sprite: Structures/Furniture/furniture.rsi
    state: bed
    noRot: true
  - type: Strap
    position: Down
    rotation: -90
  # Construction has to be before PlaceableSurface or you'll place things onto the entity instead of deconstructing it.
  - type: Construction
    graph: bed
    node: bed
  # So that you can put bedsheets on beds again. Would be cool to have a tag
  # for this so that only bedsheets can be placed.
  - type: PlaceableSurface
    placeCentered: true
  - type: Transform
    anchored: true
    noRot: true
  - type: Anchorable
  - type: Pullable

- type: entity
  parent: [ BaseBed, StructureHealthFurniture ]
  id: Bed
  name: bed
  description: This is used to lie in, sleep in or strap on. Resting here provides extremely slow healing.
  components:
  - type: Destructible
    thresholds:
    - trigger: &DamageFurnitureNormal
        !type:DamageTrigger
        damage: 40
      behaviors:
      - !type:PlaySoundBehavior
        sound:
          collection: MetalBreak
      - !type:SpawnEntitiesBehavior
        spawn:
          SheetSteel1:
            min: 1
            max: 2

- type: entity
  parent: Bed
  id: MedicalBed
  name: medical bed
  description: A hospital bed for patients to recover in. Resting here provides fairly slow healing.
  components:
  - type: Sprite
    state: bed-MED
  - type: HealOnBuckle
    damage:
      types:
        Poison: -0.2
        Cold: -0.4
        Blunt: -0.2
  - type: Construction
    graph: bed
    node: medicalbed
  - type: GuideHelp
    guides:
    - MedicalDoctor
  - type: AmbientMusicMarkerMedical

- type: entity
  parent: [ BaseBed, StructureHealthFurniture ]
  id: DogBed
  name: dog bed
  description: A comfy-looking dog bed. You can even strap your pet in, in case the gravity turns off.
  components:
  - type: Sprite
    state: dogbed
  - type: Strap
    position: Stand
    rotation: 0
  - type: Construction
    graph: bed
    node: dogbed
  - type: Damageable
    damageModifierSet: WoodMod
  - type: Destructible
    thresholds:
    - trigger: *DamageFurnitureNormal
      behaviors:
      - &SoundWoodDestroy !type:PlaySoundBehavior
        sound:
          collection: WoodDestroy
          params:
            volume: -3
      - !type:SpawnEntitiesBehavior
        spawn:
          MaterialWoodPlank:
            min: 1
            max: 5

- type: entity
  parent: Bed
  id: Mattress
  name: mattress
  description: Better sleep in that then on the floor i guess.
  components:
  - type: Sprite
    state: mattress
  - type: Damageable
    damageModifierSet: PlasticMod

- type: entity
  parent: [ BaseBed, StructureHealthFurniture ]
  id: WebBed
  name: web bed
  description: You got webbed.
  components:
  - type: Damageable
    damageModifierSet: ThreadMod
  - type: Sprite
    sprite: Structures/Web/bed.rsi
    state: icon
  - type: Destructible
    thresholds:
    - trigger: *DamageFurnitureNormal
      behaviors:
      - *SoundWoodDestroy
      - !type:SpawnEntitiesBehavior
        spawn:
          MaterialWebSilk:
            min: 1
            max: 1
  - type: Construction
    graph: WebStructures
    node: bed

- type: entity
  parent: [ BaseBed,StructureHealthFurnitureStrong ]
  id: PsychBed
  name: psychologist bed
  description: An upholstered bed for the psychological care of patients.
  components:
  - type: Sprite
    state: psychbed
  - type: HealOnBuckle
    damage:
      types:
        Cold: -0.5
  - type: Damageable
    damageModifierSet: WoodMod
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 80
      behaviors:
      - *SoundWoodDestroy
      - !type:SpawnEntitiesBehavior
        spawn:
          MaterialWoodPlank:
            min: 1
            max: 2
