Move static container helper functions to container system (#6382)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -39,8 +39,6 @@ namespace Content.Client.Examine
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
UpdatesOutsidePrediction = true;
|
||||
|
||||
SubscribeLocalEvent<GetOtherVerbsEvent>(AddExamineVerb);
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Content.Client.Verbs
|
||||
{
|
||||
foreach (var entity in entities.ToList())
|
||||
{
|
||||
if (!player.Value.IsInSameOrTransparentContainer(entity))
|
||||
if (!ContainerSystem.IsInSameOrTransparentContainer(player.Value, entity))
|
||||
entities.Remove(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using Content.Shared.Examine;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -24,8 +23,6 @@ namespace Content.Server.Examine
|
||||
base.Initialize();
|
||||
|
||||
SubscribeNetworkEvent<ExamineSystemMessages.RequestExamineInfoMessage>(ExamineInfoRequest);
|
||||
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
private void ExamineInfoRequest(ExamineSystemMessages.RequestExamineInfoMessage request, EntitySessionEventArgs eventArgs)
|
||||
|
||||
@@ -297,7 +297,7 @@ namespace Content.Server.Interaction
|
||||
if (!wideAttack)
|
||||
{
|
||||
// Check if interacted entity is in the same container, the direct child, or direct parent of the user.
|
||||
if (target != null && !Deleted(target.Value) && !user.IsInSameOrParentContainer(target.Value) && !CanAccessViaStorage(user, target.Value))
|
||||
if (target != null && !Deleted(target.Value) && !ContainerSystem.IsInSameOrParentContainer(user, target.Value) && !CanAccessViaStorage(user, target.Value))
|
||||
{
|
||||
Logger.WarningS("system.interaction",
|
||||
$"User entity {ToPrettyString(user):user} clicked on object {ToPrettyString(target.Value):target} that isn't the parent, child, or in the same container");
|
||||
|
||||
@@ -30,6 +30,9 @@ namespace Content.Shared.Examine
|
||||
|
||||
public abstract class ExamineSystemShared : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Examine range to use when the examiner is in critical condition.
|
||||
/// </summary>
|
||||
@@ -54,11 +57,17 @@ namespace Content.Shared.Examine
|
||||
if (EntityManager.TryGetComponent(examiner, out MobStateComponent mobState) && mobState.IsIncapacitated())
|
||||
return false;
|
||||
|
||||
if (entity.TryGetContainerMan(out var man) && man.Owner == examiner)
|
||||
if (!_interactionSystem.InRangeUnobstructed(examiner, entity, ExamineDetailsRange, ignoreInsideBlocker: true))
|
||||
return false;
|
||||
|
||||
// Is the target hidden in a opaque locker or something? Currently this check allows players to examine
|
||||
// their organs, if they can somehow target them. Really this should be with userSeeInsideSelf: false, and a
|
||||
// separate check for if the item is in their inventory or hands.
|
||||
if (_containerSystem.IsInSameOrTransparentContainer(examiner, entity, userSeeInsideSelf: true))
|
||||
return true;
|
||||
|
||||
return examiner.InRangeUnobstructed(entity, ExamineDetailsRange, ignoreInsideBlocker: true) &&
|
||||
examiner.IsInSameOrNoContainer(entity);
|
||||
// is it inside of an open storage (e.g., an open backpack)?
|
||||
return _interactionSystem.CanAccessViaStorage(examiner, entity);
|
||||
}
|
||||
|
||||
[Pure]
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace Content.Shared.Interaction
|
||||
[Dependency] private readonly SharedVerbSystem _verbSystem = default!;
|
||||
[Dependency] private readonly SharedAdminLogSystem _adminLogSystem = default!;
|
||||
[Dependency] private readonly RotateToFaceSystem _rotateToFaceSystem = default!;
|
||||
[Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
|
||||
|
||||
public const float InteractionRange = 2;
|
||||
public const float InteractionRangeSquared = InteractionRange * InteractionRange;
|
||||
@@ -76,7 +77,7 @@ namespace Content.Shared.Interaction
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.IsInSameOrParentContainer(ev.Target) && !CanAccessViaStorage(user, ev.Target))
|
||||
if (!ContainerSystem.IsInSameOrParentContainer(user, ev.Target) && !CanAccessViaStorage(user, ev.Target))
|
||||
{
|
||||
ev.Cancel();
|
||||
return;
|
||||
@@ -154,7 +155,7 @@ namespace Content.Shared.Interaction
|
||||
|
||||
// Check if interacted entity is in the same container, the direct child, or direct parent of the user.
|
||||
// This is bypassed IF the interaction happened through an item slot (e.g., backpack UI)
|
||||
if (target != null && !user.IsInSameOrParentContainer(target.Value) && !CanAccessViaStorage(user, target.Value))
|
||||
if (target != null && !ContainerSystem.IsInSameOrParentContainer(user, target.Value) && !CanAccessViaStorage(user, target.Value))
|
||||
return;
|
||||
|
||||
// Verify user has a hand, and find what object they are currently holding in their active hand
|
||||
@@ -640,7 +641,7 @@ namespace Content.Shared.Interaction
|
||||
|
||||
// Check if interacted entity is in the same container, the direct child, or direct parent of the user.
|
||||
// This is bypassed IF the interaction happened through an item slot (e.g., backpack UI)
|
||||
if (!user.IsInSameOrParentContainer(used) && !CanAccessViaStorage(user, used))
|
||||
if (!ContainerSystem.IsInSameOrParentContainer(user, used) && !CanAccessViaStorage(user, used))
|
||||
return;
|
||||
|
||||
var activateMsg = new ActivateInWorldEvent(user, used);
|
||||
|
||||
@@ -24,6 +24,7 @@ public abstract partial class InventorySystem
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!;
|
||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
private void InitializeEquip()
|
||||
@@ -162,11 +163,11 @@ public abstract partial class InventorySystem
|
||||
public bool CanAccess(EntityUid actor, EntityUid target, EntityUid itemUid)
|
||||
{
|
||||
// Can the actor reach the target?
|
||||
if (actor != target && !( actor.InRangeUnobstructed(target) && actor.IsInSameOrParentContainer(target)))
|
||||
if (actor != target && !( actor.InRangeUnobstructed(target) && _containerSystem.IsInSameOrParentContainer(actor, target)))
|
||||
return false;
|
||||
|
||||
// Can the actor reach the item?
|
||||
if (actor.InRangeUnobstructed(itemUid) && actor.IsInSameOrParentContainer(itemUid))
|
||||
if (_interactionSystem.InRangeUnobstructed(actor, itemUid) && _containerSystem.IsInSameOrParentContainer(actor, itemUid))
|
||||
return true;
|
||||
|
||||
// Is the item in an open storage UI, i.e., is the user quick-equipping from an open backpack?
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Physics.Pull;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Shared.Pulling.Events;
|
||||
using Content.Shared.Rotatable;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Log;
|
||||
|
||||
namespace Content.Shared.Pulling
|
||||
@@ -26,6 +15,7 @@ namespace Content.Shared.Pulling
|
||||
public abstract partial class SharedPullingSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
|
||||
public bool CanPull(EntityUid puller, EntityUid pulled)
|
||||
{
|
||||
@@ -54,7 +44,7 @@ namespace Content.Shared.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!puller.IsInSameOrNoContainer(pulled))
|
||||
if (!_containerSystem.IsInSameOrNoContainer(puller, pulled))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Content.Shared.Verbs
|
||||
{
|
||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||
[Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -53,7 +54,7 @@ namespace Content.Shared.Verbs
|
||||
canAccess = true;
|
||||
else if (EntityManager.EntityExists(target) && _interactionSystem.InRangeUnobstructed(user, target, ignoreInsideBlocker: true))
|
||||
{
|
||||
if (user.IsInSameOrParentContainer(target))
|
||||
if (ContainerSystem.IsInSameOrParentContainer(user, target))
|
||||
canAccess = true;
|
||||
else
|
||||
// the item might be in a backpack that the user has open
|
||||
|
||||
Reference in New Issue
Block a user