Fix chameleon backpacks not being able to be opened when locked (#39784)

* Fix chameleon backpacks not being able to be opened when locked

* rename

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
beck-thompson
2025-08-26 14:50:19 -07:00
committed by GitHub
parent 72738f7c87
commit 8e8b318862
4 changed files with 16 additions and 3 deletions

View File

@@ -48,11 +48,12 @@ public sealed class LockSystem : EntitySystem
SubscribeLocalEvent<LockComponent, GotEmaggedEvent>(OnEmagged);
SubscribeLocalEvent<LockComponent, LockDoAfter>(OnDoAfterLock);
SubscribeLocalEvent<LockComponent, UnlockDoAfter>(OnDoAfterUnlock);
SubscribeLocalEvent<LockComponent, StorageInteractAttemptEvent>(OnStorageInteractAttempt);
SubscribeLocalEvent<LockedWiresPanelComponent, LockToggleAttemptEvent>(OnLockToggleAttempt);
SubscribeLocalEvent<LockedWiresPanelComponent, AttemptChangePanelEvent>(OnAttemptChangePanel);
SubscribeLocalEvent<LockedAnchorableComponent, UnanchorAttemptEvent>(OnUnanchorAttempt);
SubscribeLocalEvent<LockedStorageComponent, StorageInteractAttemptEvent>(OnStorageInteractAttempt);
SubscribeLocalEvent<UIRequiresLockComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt);
SubscribeLocalEvent<UIRequiresLockComponent, LockToggledEvent>(LockToggled);
@@ -358,9 +359,9 @@ public sealed class LockSystem : EntitySystem
TryUnlock(uid, args.User, skipDoAfter: true);
}
private void OnStorageInteractAttempt(Entity<LockComponent> ent, ref StorageInteractAttemptEvent args)
private void OnStorageInteractAttempt(Entity<LockedStorageComponent> ent, ref StorageInteractAttemptEvent args)
{
if (ent.Comp.Locked)
if (IsLocked(ent.Owner))
args.Cancelled = true;
}

View File

@@ -0,0 +1,10 @@
using Content.Shared.Storage;
using Robust.Shared.GameStates;
namespace Content.Shared.Lock;
/// <summary>
/// Prevents using an entity's <see cref="StorageComponent"/> if its <see cref="LockComponent"/> is locked.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class LockedStorageComponent : Component;

View File

@@ -138,6 +138,7 @@
- type: AccessReader
access: [["Research"], ["Cargo"]]
- type: Lock
- type: LockedStorage
- type: SuppressArtifactContainer
- type: RadiationBlockingContainer
resistance: 5

View File

@@ -45,6 +45,7 @@
description: It looks as strong as reality itself.
components:
- type: Lock
- type: LockedStorage
- type: LockVisuals
- type: Sprite
sprite: Structures/Storage/Shelfs/wood.rsi