From 94178804dfa8e6f8e63d1e9bad4c08f1c32b807b Mon Sep 17 00:00:00 2001
From: Visne <39844191+Visne@users.noreply.github.com>
Date: Sat, 10 Sep 2022 23:48:03 +0200
Subject: [PATCH] Keep windoors open if they are clicked (#11180)
---
.../Doors/Components/AirlockComponent.cs | 13 +++++++++++++
Content.Server/Doors/Systems/AirlockSystem.cs | 14 ++++++++++++++
.../Doors/Windoors/base_structurewindoors.yml | 1 +
3 files changed, 28 insertions(+)
diff --git a/Content.Server/Doors/Components/AirlockComponent.cs b/Content.Server/Doors/Components/AirlockComponent.cs
index db82273a27..0a21d3cf44 100644
--- a/Content.Server/Doors/Components/AirlockComponent.cs
+++ b/Content.Server/Doors/Components/AirlockComponent.cs
@@ -50,6 +50,13 @@ namespace Content.Server.Doors.Components
[DataField("openPanelVisible")]
public bool OpenPanelVisible = false;
+ ///
+ /// Whether the airlock should stay open if the airlock was clicked.
+ /// If the airlock was bumped into it will still auto close.
+ ///
+ [DataField("keepOpenIfClicked")]
+ public bool KeepOpenIfClicked = false;
+
private CancellationTokenSource _powerWiresPulsedTimerCancel = new();
private bool _powerWiresPulsed;
@@ -105,6 +112,12 @@ namespace Content.Server.Doors.Components
}
}
+ ///
+ /// Whether the airlock should auto close. This value is reset every time the airlock closes.
+ ///
+ [ViewVariables(VVAccess.ReadWrite)]
+ public bool AutoClose = true;
+
///
/// Delay until an open door automatically closes.
///
diff --git a/Content.Server/Doors/Systems/AirlockSystem.cs b/Content.Server/Doors/Systems/AirlockSystem.cs
index 38ab19f25c..b807ebf40d 100644
--- a/Content.Server/Doors/Systems/AirlockSystem.cs
+++ b/Content.Server/Doors/Systems/AirlockSystem.cs
@@ -71,6 +71,10 @@ namespace Content.Server.Doors.Systems
component.UpdateBoltLightStatus();
UpdateAutoClose(uid, component);
+
+ // Make sure the airlock auto closes again next time it is opened
+ if (args.State == DoorState.Closed)
+ component.AutoClose = true;
}
///
@@ -84,6 +88,9 @@ namespace Content.Server.Doors.Systems
if (door.State != DoorState.Open)
return;
+ if (!airlock.AutoClose)
+ return;
+
if (!airlock.CanChangeState())
return;
@@ -133,6 +140,13 @@ namespace Content.Server.Doors.Systems
{
_wiresSystem.OpenUserInterface(uid, actor.PlayerSession);
args.Handled = true;
+ return;
+ }
+
+ if (component.KeepOpenIfClicked)
+ {
+ // Disable auto close
+ component.AutoClose = false;
}
}
diff --git a/Resources/Prototypes/Entities/Structures/Doors/Windoors/base_structurewindoors.yml b/Resources/Prototypes/Entities/Structures/Doors/Windoors/base_structurewindoors.yml
index eec19ea444..308cbcb8ad 100644
--- a/Resources/Prototypes/Entities/Structures/Doors/Windoors/base_structurewindoors.yml
+++ b/Resources/Prototypes/Entities/Structures/Doors/Windoors/base_structurewindoors.yml
@@ -72,6 +72,7 @@
acts: [ "Destruction" ]
- type: AccessReader
- type: Airlock
+ keepOpenIfClicked: true
openPanelVisible: true
# needed so that windoors will close regardless of whether there are people in it; it doesn't crush after all
safety: false