# SPDX-FileCopyrightText: 2021 Julian Giebel <j.giebel@netrocks.info>
# SPDX-FileCopyrightText: 2021 Kara D <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2021 Kara Dinyes <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2021 Vera Aguilera Puerto <gradientvera@outlook.com>
# SPDX-FileCopyrightText: 2021 mirrorcult <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2022 Alex Evgrashin <aevgrashin@yandex.ru>
# SPDX-FileCopyrightText: 2022 Andreas Kämper <andreas@kaemper.tech>
# SPDX-FileCopyrightText: 2022 Flipp Syder <76629141+vulppine@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Jacob Tong <10494922+ShadowCommander@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Justin Trotter <trotter.justin@gmail.com>
# SPDX-FileCopyrightText: 2022 Peptide90 <78795277+Peptide90@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 Rane <60792108+Elijahrane@users.noreply.github.com>
# SPDX-FileCopyrightText: 2022 WlarusFromDaSpace <44726328+WlarusFromDaSpace@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 AJCM-git <60196617+AJCM-git@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Arendian <137322659+Arendian@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 Blazeror <154933882+Blazeror@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 CommieFlowers <rasmus.cedergren@hotmail.com>
# SPDX-FileCopyrightText: 2023 DrSmugleaf <DrSmugleaf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 ElectroJr <leonsfriedrich@gmail.com>
# SPDX-FileCopyrightText: 2023 Julian Giebel <juliangiebel@live.de>
# SPDX-FileCopyrightText: 2023 Morb <14136326+Morb0@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 TemporalOroboros <TemporalOroboros@gmail.com>
# SPDX-FileCopyrightText: 2023 Tom Leys <tom@crump-leys.com>
# SPDX-FileCopyrightText: 2023 Visne <39844191+Visne@users.noreply.github.com>
# SPDX-FileCopyrightText: 2023 rolfero <45628623+rolfero@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Emisse <99158783+Emisse@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Errant <35878406+Errant-4@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Ilya246 <57039557+Ilya246@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 JustCone <141039037+JustCone14@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Kara <lunarautomaton6@gmail.com>
# SPDX-FileCopyrightText: 2024 Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Mervill <mervills.email@gmail.com>
# SPDX-FileCopyrightText: 2024 MilenVolf <63782763+MilenVolf@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 PJBot <pieterjan.briers+bot@gmail.com>
# SPDX-FileCopyrightText: 2024 Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
# SPDX-FileCopyrightText: 2024 Piras314 <p1r4s@proton.me>
# SPDX-FileCopyrightText: 2024 PopGamer46 <yt1popgamer@gmail.com>
# SPDX-FileCopyrightText: 2024 Spessmann <156740760+Spessmann@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Sphiral <145869023+SphiraI@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Velcroboy <107660393+IamVelcroboy@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 Velcroboy <velcroboy333@hotmail.com>
# SPDX-FileCopyrightText: 2024 Winkarst <74284083+Winkarst-cpu@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 chromiumboy <50505512+chromiumboy@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 coolboy911 <85909253+coolboy911@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 deltanedas <39013340+deltanedas@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 deltanedas <@deltanedas:kde.org>
# SPDX-FileCopyrightText: 2024 lunarcomets <140772713+lunarcomets@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 lzk <124214523+lzk228@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 metalgearsloth <comedian_vs_clown@hotmail.com>
# SPDX-FileCopyrightText: 2024 saintmuntzer <47153094+saintmuntzer@users.noreply.github.com>
# SPDX-FileCopyrightText: 2024 slarticodefast <161409025+slarticodefast@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 BombasterDS <deniskaporoshok@gmail.com>
# SPDX-FileCopyrightText: 2025 BombasterDS2 <shvalovdenis.workmail@gmail.com>
# SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
# SPDX-FileCopyrightText: 2025 K-Dynamic <20566341+K-Dynamic@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 yavuz <58685802+yahay505@users.noreply.github.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
#Normal windoors
- type: entity
  id: BaseWindoor
  parent: BaseStructure
  abstract: true
  placement:
    mode: SnapgridCenter
  components:
  - type: MeleeSound
    soundGroups:
      Brute:
        collection: GlassSmash
  - type: InteractionOutline
  - type: StationAiWhitelist
  - type: Physics
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeAabb
          bounds: "-0.49,-0.49,0.49,-0.36"
        density: 1500
        mask:
        - TabletopMachineMask
        layer:
        - GlassAirlockLayer
  - type: Sprite
    sprite: Structures/Doors/Windoors/windoor.rsi
    layers:
    - state: closed
      map: ["enum.DoorVisualLayers.Base"]
    - state: closed_unlit
      shader: unshaded
      map: ["enum.DoorVisualLayers.BaseUnlit"]
      visible: false
    - state: welded
      map: ["enum.WeldableLayers.BaseWelded"]
    - state: bolted_unlit
      shader: unshaded
      map: ["enum.DoorVisualLayers.BaseBolted"]
    - state: emergency_unlit
      shader: unshaded
      map: ["enum.DoorVisualLayers.BaseEmergencyAccess"]
    - state: panel_open
      map: ["enum.WiresVisualLayers.MaintenancePanel"]
    - state: electrified_ai
      sprite: Interface/Misc/ai_hud.rsi
      shader: unshaded
      visible: false
      map: ["enum.ElectrifiedLayers.HUD"]
    - state: electrified
      sprite: Effects/electricity.rsi
      shader: unshaded
      visible: false
      map: ["enum.ElectrifiedLayers.Sparks"]
  - type: AnimationPlayer
  - type: ApcPowerReceiver
  - type: ExtensionCableReceiver
  - type: DoorSignalControl
  - type: DeviceNetwork
    deviceNetId: Wireless
    receiveFrequencyId: BasicDevice
  - type: WirelessNetworkConnection
    range: 200
  - type: DeviceLinkSink
    ports:
      - Open
      - Close
      - Toggle
      - AutoClose
      - DoorBolt
  - type: DeviceLinkSource
    ports:
    - DoorStatus
    lastSignals:
      DoorStatus: false
  - type: Damageable
    damageContainer: StructuralInorganic
    damageModifierSet: Glass
  - type: ExaminableDamage
    messages: WindowMessages
  - type: RCDDeconstructable
    cost: 8
    delay: 8
    fx: EffectRCDDeconstruct8
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 400
      behaviors: #excess damage (nuke?). avoid computational cost of spawning entities.
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 200
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlass:
            min: 1
            max: 2
          SheetSteel1:
            min: 2
            max: 4
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: ContainerFill
    containers:
      board: [ DoorElectronics ]
  - type: AccessReader
    containerAccessProvider: board
  - type: ContainerContainer
    containers:
      board: !type:Container
  - type: Door
    canCrush: false
    openingAnimationTime: 0.9
    closingAnimationTime: 0.9
    openSound:
      path: /Audio/Machines/windoor_open.ogg
    closeSound:
      path: /Audio/Machines/windoor_open.ogg
    denySound:
      path: /Audio/Machines/airlock_deny.ogg
  - type: Airlock
    keepOpenIfClicked: true
    openPanelVisible: true
    denyAnimationTime: 0.4
    animatePanel: false
    openUnlitVisible: true
    # needed so that windoors will close regardless of whether there are people in it; it doesn't crush after all
    safety: false
  - type: NavMapDoor
  - type: DoorBolt
  - type: Electrified
    enabled: false
    usesApcPower: true
  - type: WiresPanel
  - type: Wires
    boardName: wires-board-name-windoor
    layoutId: Airlock
  - type: UserInterface
    interfaces:
      enum.AiUi.Key:
        type: StationAiBoundUserInterface
      enum.WiresUiKey.Key:
        type: WiresBoundUserInterface
  - type: Appearance
  - type: GenericVisualizer
    visuals:
      enum.ElectrifiedVisuals.ShowSparks:
        enum.ElectrifiedLayers.Sparks:
          True: { visible: True }
          False: { visible: False }
  - type: WiresVisuals
  - type: ElectrocutionHUDVisuals
  - type: Airtight
    noAirWhenFullyAirBlocked: false
    airBlockedDirection:
      - South
  - type: Construction
    graph: Windoor
    node: windoor
    containers:
    - board
  - type: StaticPrice
    price: 150
  - type: PryUnpowered
  - type: Penetratable # Goobstation - Better snipers
    penetrateDamage: 25
    damagePenalty: 0.1
  - type: InteractionVerbs # EE: Interaction Verbs
    allowedVerbs:
    - KnockOn

- type: entity
  id: BaseSecureWindoor
  parent: BaseWindoor
  abstract: true
  components:
  - type: Sprite
    sprite: Structures/Doors/Windoors/windoor.rsi
    layers:
    - state: secure_underlay
    - state: closed
      map: [ "enum.DoorVisualLayers.Base" ]
    - state: closed_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseUnlit" ]
      visible: false
    - state: welded
      map: [ "enum.WeldableLayers.BaseWelded" ]
    - state: bolted_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseBolted" ]
    - state: emergency_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseEmergencyAccess" ]
    - state: panel_open
      map: [ "enum.WiresVisualLayers.MaintenancePanel" ]
      visible: false
    - state: electrified_ai
      sprite: Interface/Misc/ai_hud.rsi
      shader: unshaded
      visible: false
      map: [ "enum.ElectrifiedLayers.HUD" ]
    - state: electrified
      sprite: Effects/electricity.rsi
      shader: unshaded
      visible: false
      map: [ "enum.ElectrifiedLayers.Sparks" ]
  - type: Damageable
    damageModifierSet: RGlass
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 600
      behaviors: #excess damage (nuke?). avoid computational cost of spawning entities.
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 400
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlass:
            min: 1
            max: 2
          SheetPlasteel1:
            min: 1
            max: 2
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: Construction
    graph: Windoor
    node: windoorSecure
  - type: StaticPrice
    price: 350
  - type: Tag
    tags:
      - SecureWindoor
      # This tag is used to nagivate the Airlock construction graph. It's needed because the construction graph is shared between Airlock, AirlockGlass, and HighSecDoor
  - type: Penetratable # Goobstation - Better snipers
    penetrateDamage: 50
    damagePenalty: 0.1

#Plasma Windoors
- type: entity
  id: BasePlasmaWindoor
  parent: BaseWindoor
  abstract: true
  components:
  - type: Sprite
    sprite: Structures/Doors/Windoors/plasma.rsi
    layers:
    - state: closed
      map: [ "enum.DoorVisualLayers.Base" ]
    - state: closed_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseUnlit" ]
      visible: false
    - state: welded
      map: [ "enum.WeldableLayers.BaseWelded" ]
    - state: bolted_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseBolted" ]
    - state: emergency_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseEmergencyAccess" ]
    - state: panel_open
      map: [ "enum.WiresVisualLayers.MaintenancePanel" ]
      visible: false
    - state: electrified_ai
      sprite: Interface/Misc/ai_hud.rsi
      shader: unshaded
      visible: false
      map: [ "enum.ElectrifiedLayers.HUD" ]
    - state: electrified
      sprite: Effects/electricity.rsi
      shader: unshaded
      visible: false
      map: [ "enum.ElectrifiedLayers.Sparks" ]
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 480
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 240
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlassPlasma:
            min: 1
            max: 2
          SheetSteel1:
            min: 1
            max: 2
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: Construction
    graph: Windoor
    node: pwindoor
  - type: StaticPrice
    price: 500
  - type: Penetratable # Goobstation - Better snipers
    penetrateDamage: 40
    damagePenalty: 0.1

- type: entity
  id: BaseSecurePlasmaWindoor
  parent: BaseSecureWindoor
  abstract: true
  components:
  - type: Sprite
    sprite: Structures/Doors/Windoors/plasma.rsi
    layers:
    - state: secure_underlay
    - state: closed
      map: [ "enum.DoorVisualLayers.Base" ]
    - state: closed_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseUnlit" ]
      visible: false
    - state: welded
      map: [ "enum.WeldableLayers.BaseWelded" ]
    - state: bolted_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseBolted" ]
    - state: emergency_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseEmergencyAccess" ]
    - state: panel_open
      map: [ "enum.WiresVisualLayers.MaintenancePanel" ]
      visible: false
    - state: electrified_ai
      sprite: Interface/Misc/ai_hud.rsi
      shader: unshaded
      visible: false
      map: [ "enum.ElectrifiedLayers.HUD" ]
    - state: electrified
      sprite: Effects/electricity.rsi
      shader: unshaded
      visible: false
      map: [ "enum.ElectrifiedLayers.Sparks" ]
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 800
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 530
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlassPlasma:
            min: 1
            max: 2
          SheetPlasteel1:
            min: 1
            max: 2
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: Construction
    graph: Windoor
    node: pwindoorSecure
  - type: StaticPrice
    price: 500
  - type: RadiationBlocker
    resistance: 4
  - type: Tag
    tags:
      - SecurePlasmaWindoor
      # This tag is used to nagivate the Airlock construction graph. It's needed because the construction graph is shared between Airlock, AirlockGlass, and HighSecDoor
  - type: Penetratable # Goobstation - Better snipers
    penetrateDamage: 50
    damagePenalty: 0.1

#Uranium Windoors
- type: entity
  id: BaseUraniumWindoor
  parent: BaseWindoor
  abstract: true
  components:
  - type: Sprite
    sprite: Structures/Doors/Windoors/uranium.rsi
    layers:
    - state: closed
      map: [ "enum.DoorVisualLayers.Base" ]
    - state: closed_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseUnlit" ]
      visible: false
    - state: welded
      map: [ "enum.WeldableLayers.BaseWelded" ]
    - state: bolted_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseBolted" ]
    - state: emergency_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseEmergencyAccess" ]
    - state: panel_open
      map: [ "enum.WiresVisualLayers.MaintenancePanel" ]
      visible: false
    - state: electrified_ai
      sprite: Interface/Misc/ai_hud.rsi
      shader: unshaded
      visible: false
      map: [ "enum.ElectrifiedLayers.HUD" ]
    - state: electrified
      sprite: Effects/electricity.rsi
      shader: unshaded
      visible: false
      map: [ "enum.ElectrifiedLayers.Sparks" ]
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 400
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 240
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlassUranium:
            min: 1
            max: 2
          SheetSteel1:
            min: 1
            max: 2
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: Construction
    graph: Windoor
    node: uwindoor
  - type: StaticPrice
    price: 560
  - type: RadiationBlocker
    resistance: 3
  - type: Penetratable # Goobstation - Better snipers
    penetrateDamage: 40
    damagePenalty: 0.1

- type: entity
  id: BaseSecureUraniumWindoor
  parent: BaseSecureWindoor
  abstract: true
  components:
  - type: Sprite
    sprite: Structures/Doors/Windoors/uranium.rsi
    layers:
    - state: secure_underlay
    - state: closed
      map: [ "enum.DoorVisualLayers.Base" ]
    - state: closed_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseUnlit" ]
      visible: false
    - state: welded
      map: [ "enum.WeldableLayers.BaseWelded" ]
    - state: bolted_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseBolted" ]
    - state: emergency_unlit
      shader: unshaded
      map: [ "enum.DoorVisualLayers.BaseEmergencyAccess" ]
    - state: panel_open
      map: [ "enum.WiresVisualLayers.MaintenancePanel" ]
      visible: false
    - state: electrified_ai
      sprite: Interface/Misc/ai_hud.rsi
      shader: unshaded
      visible: false
      map: [ "enum.ElectrifiedLayers.HUD" ]
    - state: electrified
      sprite: Effects/electricity.rsi
      shader: unshaded
      visible: false
      map: [ "enum.ElectrifiedLayers.Sparks" ]
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 1200
      behaviors:
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
    - trigger:
        !type:DamageTrigger
        damage: 400
      behaviors:
      - !type:SpawnEntitiesBehavior
        spawn:
          ShardGlassUranium:
            min: 1
            max: 2
          SheetPlasteel1:
            min: 1
            max: 2
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: Construction
    graph: Windoor
    node: uwindoorSecure
  - type: StaticPrice
    price: 750
  - type: RadiationBlocker
    resistance: 5
  - type: Tag
    tags:
      - SecureUraniumWindoor
      # This tag is used to nagivate the Airlock construction graph. It's needed because the construction graph is shared between Airlock, AirlockGlass, and HighSecDoor
  - type: Penetratable # Goobstation - Better snipers
    penetrateDamage: 50
    damagePenalty: 0.1
