Merge remote-tracking branch 'refs/remotes/upstream/master' into ed-13-05-2024-upstream
# Conflicts: # Content.Shared/Lock/LockSystem.cs # Resources/Prototypes/Maps/oasis.yml
This commit is contained in:
@@ -111,6 +111,7 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
SubscribeLocalEvent<StorageComponent, AfterInteractEvent>(AfterInteract);
|
||||
SubscribeLocalEvent<StorageComponent, DestructionEventArgs>(OnDestroy);
|
||||
SubscribeLocalEvent<StorageComponent, BoundUIOpenedEvent>(OnBoundUIOpen);
|
||||
SubscribeLocalEvent<StorageComponent, LockToggledEvent>(OnLockToggled);
|
||||
SubscribeLocalEvent<MetaDataComponent, StackCountChangedEvent>(OnStackCountChanged);
|
||||
|
||||
SubscribeLocalEvent<StorageComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
|
||||
@@ -1406,6 +1407,25 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
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).ToList())
|
||||
{
|
||||
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) &&
|
||||
@@ -1418,15 +1438,15 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
|
||||
private void HandleOpenBackpack(ICommonSession? session)
|
||||
{
|
||||
HandleOpenSlotUI(session, "back");
|
||||
HandleToggleSlotUI(session, "back");
|
||||
}
|
||||
|
||||
private void HandleOpenBelt(ICommonSession? session)
|
||||
{
|
||||
HandleOpenSlotUI(session, "belt");
|
||||
HandleToggleSlotUI(session, "belt");
|
||||
}
|
||||
|
||||
private void HandleOpenSlotUI(ICommonSession? session, string slot)
|
||||
private void HandleToggleSlotUI(ICommonSession? session, string slot)
|
||||
{
|
||||
if (session is not { } playerSession)
|
||||
return;
|
||||
@@ -1440,7 +1460,14 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
if (!ActionBlocker.CanInteract(playerEnt, storageEnt))
|
||||
return;
|
||||
|
||||
OpenStorageUI(storageEnt.Value, playerEnt);
|
||||
if (!_ui.IsUiOpen(storageEnt.Value, StorageComponent.StorageUiKey.Key, playerEnt))
|
||||
{
|
||||
OpenStorageUI(storageEnt.Value, playerEnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ui.CloseUi(storageEnt.Value, StorageComponent.StorageUiKey.Key, playerEnt);
|
||||
}
|
||||
}
|
||||
|
||||
protected void ClearCantFillReasons()
|
||||
|
||||
Reference in New Issue
Block a user