Fix item cabinet locking while open and locker favoritism (#12508)

Co-authored-by: Moony <moony@hellomouse.net>
Fixes https://github.com/space-wizards/space-station-14/issues/12426
This commit is contained in:
Bright0
2022-12-06 16:59:59 -06:00
committed by GitHub
parent 14599c0a90
commit f55d85a975
4 changed files with 40 additions and 13 deletions

View File

@@ -45,11 +45,13 @@ public sealed class EntityStorageSystem : EntitySystem
SubscribeLocalEvent<EntityStorageComponent, ActivateInWorldEvent>(OnInteract);
SubscribeLocalEvent<EntityStorageComponent, WeldableAttemptEvent>(OnWeldableAttempt);
SubscribeLocalEvent<EntityStorageComponent, WeldableChangedEvent>(OnWelded);
SubscribeLocalEvent<EntityStorageComponent, LockToggleAttemptEvent>(OnLockToggleAttempt);
SubscribeLocalEvent<EntityStorageComponent, DestructionEventArgs>(OnDestroy);
SubscribeLocalEvent<InsideEntityStorageComponent, InhaleLocationEvent>(OnInsideInhale);
SubscribeLocalEvent<InsideEntityStorageComponent, ExhaleLocationEvent>(OnInsideExhale);
SubscribeLocalEvent<InsideEntityStorageComponent, AtmosExposedGetAirEvent>(OnInsideExposed);
}
private void OnInit(EntityUid uid, EntityStorageComponent component, ComponentInit args)
@@ -102,6 +104,17 @@ public sealed class EntityStorageSystem : EntitySystem
component.IsWeldedShut = args.IsWelded;
}
private void OnLockToggleAttempt(EntityUid uid, EntityStorageComponent target, ref LockToggleAttemptEvent args)
{
// Cannot (un)lock open lockers.
if (target.Open)
args.Cancelled = true;
// Cannot (un)lock from the inside. Maybe a bad idea? Security jocks could trap nerds in lockers?
if (target.Contents.Contains(args.User))
args.Cancelled = true;
}
private void OnDestroy(EntityUid uid, EntityStorageComponent component, DestructionEventArgs args)
{
component.Open = true;