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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user