lockkey system tweak (#601)

* lockkey system tweak

* Update SharedCP14LockKeySystem.cs

---------

Co-authored-by: Ed <edwardxperia2000@gmail.com>
This commit is contained in:
A.Ne.
2024-11-21 00:16:00 +04:00
committed by GitHub
parent e79b046c4a
commit 4abd793ef9

View File

@@ -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<LockComponent> _lockQuery;
private EntityQuery<CP14LockComponent> _cp14LockQuery;
private EntityQuery<CP14KeyComponent> _keyQuery;
private EntityQuery<DoorComponent> _doorQuery;
public const int DepthComplexity = 2;
@@ -32,6 +34,7 @@ public sealed class SharedCP14LockKeySystem : EntitySystem
_lockQuery = GetEntityQuery<LockComponent>();
_cp14LockQuery = GetEntityQuery<CP14LockComponent>();
_keyQuery = GetEntityQuery<CP14KeyComponent>();
_doorQuery = GetEntityQuery<DoorComponent>();
SubscribeLocalEvent<CP14KeyComponent, AfterInteractEvent>(OnKeyInteract);
SubscribeLocalEvent<CP14KeyRingComponent, AfterInteractEvent>(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;