- type: entity
  parent: [ BaseStructure, StructureHealthBarrier ]
  id: Grille
  name: grille
  description: A flimsy framework of iron rods.
  placement:
    mode: SnapgridCenter
    snap:
    - Wall
  components:
  - type: MeleeSound
    soundGroups:
      Brute:
        path:
          "/Audio/Weapons/grille_hit.ogg"
  - type: RCDDeconstructable
    cost: 6
    delay: 4
    fx: EffectRCDDeconstruct4
  - type: CanBuildWindowOnTop
  - type: Anchorable
    flags:
    - Anchorable
  - type: Rotatable
  - type: Sprite
    drawdepth: Walls
    sprite: Structures/Walls/grille-new.rsi
    layers:
    - state: full
    - state: electrified
      sprite: Effects/electricity.rsi
      map: ["enum.ElectrifiedLayers.Sparks"]
      shader: unshaded
      visible: false
  - type: Icon
    sprite: Structures/Walls/grille-new.rsi
    state: full
  - type: PlacementReplacement
    key: grilles
  - type: IconSmooth
    index: 0
    key: walls
    base: grille
  - type: Electrified
    requirePower: true
    noWindowInTile: true
    highVoltageNode: high
    mediumVoltageNode: medium
    lowVoltageNode: low
  - type: NodeContainer
    nodes:
      high:
        !type:CableDeviceNode
        nodeGroupID: HVPower
      medium:
        !type:CableDeviceNode
        nodeGroupID: MVPower
      low:
        !type:CableDeviceNode
        nodeGroupID: Apc
  - type: Physics
    bodyType: Static
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.5,-0.5,0.5,0.5"
        mask:
        - FullTileMask
        layer:
        - GlassLayer
  - type: Appearance
  - type: GenericVisualizer
    visuals:
      enum.ElectrifiedVisuals.ShowSparks:
        enum.ElectrifiedLayers.Sparks:
          True: { visible: True }
          False: { visible: False }
  - type: AnimationPlayer
  - type: Damageable
    damageModifierSet: SteelMod
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 80
      behaviors:
      - &SpawnRod !type:SpawnEntitiesBehavior
        spawn:
          PartRodMetal1:
            min: 0
            max: 1
      - !type:ChangeConstructionNodeBehavior
        node: grilleBroken
      - !type:PlaySoundBehavior
        sound:
          path: "/Audio/Weapons/grille_hit.ogg"
  - type: Construction
    graph: Grille
    node: grille

### DIAGONAL
- type: entity
  parent: Grille
  id: GrilleDiagonal
  name: diagonal grille
  components:
  - type: Sprite
    sprite: Structures/Walls/grille-diagonal.rsi
    layers:
    - state: state0
    - state: electrified_diagonal
      sprite: Effects/electricity.rsi
      map: ["enum.ElectrifiedLayers.Sparks"]
      shader: unshaded
      visible: false
  - type: Icon
    sprite: Structures/Walls/grille-diagonal.rsi
    state: state0
  - type: IconSmooth
    index: 0
    mode: Diagonal
    key: grilles
    base: state
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PolygonShape
          vertices:
          - "-0.5,-0.5"
          - "0.5,0.5"
          - "0.5,-0.5"
        mask:
        - FullTileMask
        layer:
        - GlassLayer
  - type: Construction
    graph: GrilleDiagonal
    node: grilleDiagonal

### BROKEN
- type: entity
  parent: [ BaseStructure, StructureHealthFurnitureWeak ]
  id: GrilleBroken
  name: grille
  description: A flimsy framework of iron rods. It has seen better days.
  components:
  - type: Sprite
    drawdepth: Walls
    sprite: Structures/Walls/grille-new.rsi
    state: broken
  - type: Icon
    sprite: Structures/Walls/grille-new.rsi
    state: broken
  - type: RCDDeconstructable
    cost: 6
    delay: 4
    fx: EffectRCDDeconstruct4
  - type: Construction
    graph: Grille
    node: grilleBroken
    deconstructionTarget: start
  - type: Fixtures # overwrite BaseStructure parent.
  - type: Physics
    bodyType: Static
    canCollide: false
  - type: Tag
    tags:
    - ForceNoFixRotations
  - type: Damageable
    damageModifierSet: SteelMod
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 5
      behaviors:
      - *SpawnRod
      - !type:PlaySoundBehavior
        sound:
          path: "/Audio/Weapons/grille_hit.ogg"
