SubscribeLocalEvent<StorageComponent, AfterInteractEvent>(AfterInteract);
SubscribeLocalEvent<StorageComponent, DestructionEventArgs>(OnDestroy);
SubscribeLocalEvent<StorageComponent, BoundUIOpenedEvent>(OnBoundUIOpen);
+ SubscribeLocalEvent<StorageComponent, LockToggledEvent>(OnLockToggled);
SubscribeLocalEvent<MetaDataComponent, StackCountChangedEvent>(OnStackCountChanged);
SubscribeLocalEvent<StorageComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
return _nextSmallest[item.Size];
}
+ /// <summary>
+ /// Checks if a storage's UI is open by anyone when locked, and closes it unless they're an admin.
+ /// </summary>
+ private void OnLockToggled(EntityUid uid, StorageComponent component, ref LockToggledEvent args)
+ {
+ if (!args.Locked)
+ return;
+
+ // Gets everyone looking at the UI
+ foreach (var actor in _ui.GetActors(uid, StorageComponent.StorageUiKey.Key))
+ {
+ if (_admin.HasAdminFlag(actor, AdminFlags.Admin))
+ continue;
+
+ // And closes it unless they're an admin
+ _ui.CloseUi(uid, StorageComponent.StorageUiKey.Key, actor);
+ }
+ }
+
private void OnStackCountChanged(EntityUid uid, MetaDataComponent component, StackCountChangedEvent args)
{
if (_containerSystem.TryGetContainingContainer(uid, out var container, component) &&