diff --git a/Content.Shared/_CP14/LockKey/SharedCP14LockKeySystem.cs b/Content.Shared/_CP14/LockKey/SharedCP14LockKeySystem.cs index ec48c10a1a..46f042a24c 100644 --- a/Content.Shared/_CP14/LockKey/SharedCP14LockKeySystem.cs +++ b/Content.Shared/_CP14/LockKey/SharedCP14LockKeySystem.cs @@ -5,6 +5,7 @@ using Content.Shared.Lock; using Content.Shared.Popups; using Content.Shared.Storage; using Content.Shared.Verbs; +using Content.Shared.Doors.Components; using Robust.Shared.Audio.Systems; using Robust.Shared.Random; using Robust.Shared.Serialization; @@ -22,6 +23,7 @@ public sealed class SharedCP14LockKeySystem : EntitySystem private EntityQuery _lockQuery; private EntityQuery _cp14LockQuery; private EntityQuery _keyQuery; + private EntityQuery _doorQuery; public const int DepthComplexity = 2; @@ -32,6 +34,7 @@ public sealed class SharedCP14LockKeySystem : EntitySystem _lockQuery = GetEntityQuery(); _cp14LockQuery = GetEntityQuery(); _keyQuery = GetEntityQuery(); + _doorQuery = GetEntityQuery(); SubscribeLocalEvent(OnKeyInteract); SubscribeLocalEvent(OnKeyRingInteract); @@ -82,6 +85,9 @@ public sealed class SharedCP14LockKeySystem : EntitySystem if (!args.CanReach || args.Target is not { Valid: true }) return; + if (_doorQuery.TryComp(args.Target, out var doorComponent) && doorComponent.State == DoorState.Open) + return; + if (!_lockQuery.TryComp(args.Target, out _)) return;