Merge remote-tracking branch 'space-station-14/master' into ed-25-05-2024-upstream

# Conflicts:
#	Content.Server/Atmos/Components/FlammableComponent.cs
#	Content.Shared/Lock/LockSystem.cs
#	Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs
This commit is contained in:
Ed
2024-05-25 18:49:49 +03:00
123 changed files with 1291 additions and 1076 deletions

View File

@@ -9,12 +9,12 @@ using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Destructible;
using Content.Shared.DoAfter;
using Content.Shared.Ghost;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Implants.Components;
using Content.Shared.Input;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Components;
using Content.Shared.Inventory;
using Content.Shared.Item;
using Content.Shared.Lock;
@@ -42,7 +42,6 @@ public abstract class SharedStorageSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] protected readonly IRobustRandom Random = default!;
[Dependency] private readonly ISharedAdminManager _admin = default!;
[Dependency] protected readonly ActionBlockerSystem ActionBlocker = default!;
[Dependency] private readonly EntityLookupSystem _entityLookupSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
@@ -251,17 +250,8 @@ public abstract class SharedStorageSystem : EntitySystem
private void AddUiVerb(EntityUid uid, StorageComponent component, GetVerbsEvent<ActivationVerb> args)
{
var silent = false;
if (!args.CanAccess || !args.CanInteract || TryComp<LockComponent>(uid, out var lockComponent) && lockComponent.Locked)
{
// we allow admins to open the storage anyways
if (!_admin.HasAdminFlag(args.User, AdminFlags.Admin))
return;
silent = true;
}
silent |= HasComp<GhostComponent>(args.User);
if (!CanInteract(args.User, (uid, component), args.CanAccess && args.CanInteract))
return;
// Does this player currently have the storage UI open?
var uiOpen = _ui.IsUiOpen(uid, StorageComponent.StorageUiKey.Key, args.User);
@@ -276,7 +266,7 @@ public abstract class SharedStorageSystem : EntitySystem
}
else
{
OpenStorageUI(uid, args.User, component, silent);
OpenStorageUI(uid, args.User, component);
}
}
};
@@ -300,13 +290,16 @@ public abstract class SharedStorageSystem : EntitySystem
/// Opens the storage UI for an entity
/// </summary>
/// <param name="entity">The entity to open the UI for</param>
public void OpenStorageUI(EntityUid uid, EntityUid entity, StorageComponent? storageComp = null, bool silent = false)
public void OpenStorageUI(EntityUid uid, EntityUid entity, StorageComponent? storageComp = null, bool silent = true)
{
if (!Resolve(uid, ref storageComp, false))
return;
// prevent spamming bag open / honkerton honk sound
silent |= TryComp<UseDelayComponent>(uid, out var useDelay) && UseDelay.IsDelayed((uid, useDelay));
if (!CanInteract(entity, (uid, storageComp), silent: silent))
return;
if (!silent)
{
if (!_ui.IsUiOpen(uid, StorageComponent.StorageUiKey.Key))
@@ -328,7 +321,7 @@ public abstract class SharedStorageSystem : EntitySystem
var entities = component.Container.ContainedEntities;
if (entities.Count == 0 || TryComp(uid, out LockComponent? lockComponent) && lockComponent.Locked)
if (entities.Count == 0 || !CanInteract(args.User, (uid, component)))
return;
// if the target is storage, add a verb to transfer storage.
@@ -339,7 +332,7 @@ public abstract class SharedStorageSystem : EntitySystem
{
Text = Loc.GetString("storage-component-transfer-verb"),
IconEntity = GetNetEntity(args.Using),
Act = () => TransferEntities(uid, args.Target, args.User, component, lockComponent, targetStorage, targetLock)
Act = () => TransferEntities(uid, args.Target, args.User, component, null, targetStorage, targetLock)
};
args.Verbs.Add(verb);
@@ -352,7 +345,7 @@ public abstract class SharedStorageSystem : EntitySystem
/// <returns>true if inserted, false otherwise</returns>
private void OnInteractUsing(EntityUid uid, StorageComponent storageComp, InteractUsingEvent args)
{
if (args.Handled || !storageComp.ClickInsert || TryComp(uid, out LockComponent? lockComponent) && lockComponent.Locked)
if (args.Handled || !CanInteract(args.User, (uid, storageComp), storageComp.ClickInsert, false))
return;
if (HasComp<PlaceableSurfaceComponent>(uid))
@@ -373,7 +366,7 @@ public abstract class SharedStorageSystem : EntitySystem
/// </summary>
private void OnActivate(EntityUid uid, StorageComponent storageComp, ActivateInWorldEvent args)
{
if (args.Handled || TryComp<LockComponent>(uid, out var lockComponent) && lockComponent.Locked)
if (args.Handled || !CanInteract(args.User, (uid, storageComp), storageComp.ClickInsert))
return;
// Toggle
@@ -383,7 +376,7 @@ public abstract class SharedStorageSystem : EntitySystem
}
else
{
OpenStorageUI(uid, args.User, storageComp);
OpenStorageUI(uid, args.User, storageComp, false);
}
args.Handled = true;
@@ -397,7 +390,7 @@ public abstract class SharedStorageSystem : EntitySystem
if (args.Handled)
return;
OpenStorageUI(uid, args.Performer, storageComp);
OpenStorageUI(uid, args.Performer, storageComp, false);
args.Handled = true;
}
@@ -1092,7 +1085,7 @@ public abstract class SharedStorageSystem : EntitySystem
/// <returns>true if inserted, false otherwise</returns>
public bool PlayerInsertEntityInWorld(Entity<StorageComponent?> uid, EntityUid player, EntityUid toInsert)
{
if (!Resolve(uid, ref uid.Comp) || !_interactionSystem.InRangeUnobstructed(player, uid))
if (!Resolve(uid, ref uid.Comp) || !_interactionSystem.InRangeUnobstructed(player, uid.Owner))
return false;
if (!Insert(uid, toInsert, out _, user: player, uid.Comp))
@@ -1408,7 +1401,7 @@ public abstract class SharedStorageSystem : EntitySystem
}
/// <summary>
/// Checks if a storage's UI is open by anyone when locked, and closes it unless they're an admin.
/// Checks if a storage's UI is open by anyone when locked, and closes it.
/// </summary>
private void OnLockToggled(EntityUid uid, StorageComponent component, ref LockToggledEvent args)
{
@@ -1418,11 +1411,8 @@ public abstract class SharedStorageSystem : EntitySystem
// 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);
if (!CanInteract(actor, (uid, component)))
_ui.CloseUi(uid, StorageComponent.StorageUiKey.Key, actor);
}
}
@@ -1462,7 +1452,7 @@ public abstract class SharedStorageSystem : EntitySystem
if (!_ui.IsUiOpen(storageEnt.Value, StorageComponent.StorageUiKey.Key, playerEnt))
{
OpenStorageUI(storageEnt.Value, playerEnt);
OpenStorageUI(storageEnt.Value, playerEnt, silent: false);
}
else
{
@@ -1477,6 +1467,20 @@ public abstract class SharedStorageSystem : EntitySystem
#endif
}
private bool CanInteract(EntityUid user, Entity<StorageComponent> storage, bool canInteract = true, bool silent = true)
{
if (HasComp<BypassInteractionChecksComponent>(user))
return true;
if (!canInteract)
return false;
var ev = new StorageInteractAttemptEvent(silent);
RaiseLocalEvent(storage, ref ev);
return !ev.Cancelled;
}
/// <summary>
/// Plays a clientside pickup animation for the specified uid.
/// </summary>