diff --git a/Content.Server/GameObjects/Components/Doors/AirlockComponent.cs b/Content.Server/GameObjects/Components/Doors/AirlockComponent.cs index 653aa71a7f..6542f44207 100644 --- a/Content.Server/GameObjects/Components/Doors/AirlockComponent.cs +++ b/Content.Server/GameObjects/Components/Doors/AirlockComponent.cs @@ -170,6 +170,11 @@ namespace Content.Server.GameObjects.Components.Doors return IsPowered(); } + public override bool CanClose() + { + return IsPowered(); + } + public override void Deny() { if (!IsPowered()) diff --git a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs index 31d5db8e96..928301e0e8 100644 --- a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs +++ b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs @@ -55,7 +55,7 @@ namespace Content.Server.GameObjects { if (State == DoorState.Open) { - Close(); + TryClose(eventArgs.User); } else if (State == DoorState.Closed) { @@ -137,6 +137,31 @@ namespace Content.Server.GameObjects }); } + public virtual bool CanClose() + { + return true; + } + + public bool CanClose(IEntity user) + { + if (!CanClose()) return false; + if (!Owner.TryGetComponent(out AccessReader accessReader)) + { + return true; + } + return accessReader.IsAllowed(user); + } + + public void TryClose(IEntity user) + { + if (!CanClose(user)) + { + Deny(); + return; + } + Close(); + } + public bool Close() { if (collidableComponent.TryCollision(Vector2.Zero)) @@ -178,7 +203,7 @@ namespace Content.Server.GameObjects OpenTimeCounter += frameTime; if (OpenTimeCounter > AUTO_CLOSE_DELAY) { - if (!Close()) + if (!CanClose() || !Close()) { // Try again in 2 seconds if it's jammed or something. OpenTimeCounter -= 2;