2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Interaction;
|
2022-09-29 15:51:59 +10:00
|
|
|
using Content.Shared.Storage;
|
2019-05-16 15:51:26 +02:00
|
|
|
using JetBrains.Annotations;
|
2020-06-18 22:52:44 +10:00
|
|
|
using Robust.Server.GameObjects;
|
2020-07-07 01:00:29 +02:00
|
|
|
using Robust.Shared.Containers;
|
2023-10-29 04:21:02 +11:00
|
|
|
using Robust.Shared.Player;
|
2018-02-05 13:57:26 -06:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Interaction
|
2018-02-05 13:57:26 -06:00
|
|
|
{
|
2024-10-22 22:47:57 +03:00
|
|
|
/// <summary>
|
|
|
|
|
/// Governs interactions during clicking on entities
|
|
|
|
|
/// </summary>
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
public sealed partial class InteractionSystem : SharedInteractionSystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
|
|
|
|
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
|
|
|
|
|
|
|
|
|
public override bool CanAccessViaStorage(EntityUid user, EntityUid target)
|
|
|
|
|
{
|
|
|
|
|
if (Deleted(target))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!_container.TryGetContainingContainer(target, out var container))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!TryComp(container.Owner, out StorageComponent? storage))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (storage.Container?.ID != container.ID)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// we don't check if the user can access the storage entity itself. This should be handed by the UI system.
|
|
|
|
|
return _uiSystem.IsUiOpen(container.Owner, StorageComponent.StorageUiKey.Key, user);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-02-05 13:57:26 -06:00
|
|
|
}
|