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()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
IoCManager.InjectDependencies(this);
|
|
||||||
|
|
||||||
UpdatesOutsidePrediction = true;
|
UpdatesOutsidePrediction = true;
|
||||||
|
|
||||||
SubscribeLocalEvent<GetOtherVerbsEvent>(AddExamineVerb);
|
SubscribeLocalEvent<GetOtherVerbsEvent>(AddExamineVerb);
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace Content.Client.Verbs
|
|||||||
{
|
{
|
||||||
foreach (var entity in entities.ToList())
|
foreach (var entity in entities.ToList())
|
||||||
{
|
{
|
||||||
if (!player.Value.IsInSameOrTransparentContainer(entity))
|
if (!ContainerSystem.IsInSameOrTransparentContainer(player.Value, entity))
|
||||||
entities.Remove(entity);
|
entities.Remove(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using Content.Shared.Examine;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
@@ -24,8 +23,6 @@ namespace Content.Server.Examine
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeNetworkEvent<ExamineSystemMessages.RequestExamineInfoMessage>(ExamineInfoRequest);
|
SubscribeNetworkEvent<ExamineSystemMessages.RequestExamineInfoMessage>(ExamineInfoRequest);
|
||||||
|
|
||||||
IoCManager.InjectDependencies(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExamineInfoRequest(ExamineSystemMessages.RequestExamineInfoMessage request, EntitySessionEventArgs eventArgs)
|
private void ExamineInfoRequest(ExamineSystemMessages.RequestExamineInfoMessage request, EntitySessionEventArgs eventArgs)
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ namespace Content.Server.Interaction
|
|||||||
if (!wideAttack)
|
if (!wideAttack)
|
||||||
{
|
{
|
||||||
// Check if interacted entity is in the same container, the direct child, or direct parent of the user.
|
// 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",
|
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");
|
$"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
|
public abstract class ExamineSystemShared : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||||
|
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Examine range to use when the examiner is in critical condition.
|
/// Examine range to use when the examiner is in critical condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -54,11 +57,17 @@ namespace Content.Shared.Examine
|
|||||||
if (EntityManager.TryGetComponent(examiner, out MobStateComponent mobState) && mobState.IsIncapacitated())
|
if (EntityManager.TryGetComponent(examiner, out MobStateComponent mobState) && mobState.IsIncapacitated())
|
||||||
return false;
|
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 true;
|
||||||
|
|
||||||
return examiner.InRangeUnobstructed(entity, ExamineDetailsRange, ignoreInsideBlocker: true) &&
|
// is it inside of an open storage (e.g., an open backpack)?
|
||||||
examiner.IsInSameOrNoContainer(entity);
|
return _interactionSystem.CanAccessViaStorage(examiner, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ namespace Content.Shared.Interaction
|
|||||||
[Dependency] private readonly SharedVerbSystem _verbSystem = default!;
|
[Dependency] private readonly SharedVerbSystem _verbSystem = default!;
|
||||||
[Dependency] private readonly SharedAdminLogSystem _adminLogSystem = default!;
|
[Dependency] private readonly SharedAdminLogSystem _adminLogSystem = default!;
|
||||||
[Dependency] private readonly RotateToFaceSystem _rotateToFaceSystem = default!;
|
[Dependency] private readonly RotateToFaceSystem _rotateToFaceSystem = default!;
|
||||||
|
[Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
|
||||||
|
|
||||||
public const float InteractionRange = 2;
|
public const float InteractionRange = 2;
|
||||||
public const float InteractionRangeSquared = InteractionRange * InteractionRange;
|
public const float InteractionRangeSquared = InteractionRange * InteractionRange;
|
||||||
@@ -76,7 +77,7 @@ namespace Content.Shared.Interaction
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user.IsInSameOrParentContainer(ev.Target) && !CanAccessViaStorage(user, ev.Target))
|
if (!ContainerSystem.IsInSameOrParentContainer(user, ev.Target) && !CanAccessViaStorage(user, ev.Target))
|
||||||
{
|
{
|
||||||
ev.Cancel();
|
ev.Cancel();
|
||||||
return;
|
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.
|
// 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)
|
// 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;
|
return;
|
||||||
|
|
||||||
// Verify user has a hand, and find what object they are currently holding in their active hand
|
// 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.
|
// 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)
|
// 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;
|
return;
|
||||||
|
|
||||||
var activateMsg = new ActivateInWorldEvent(user, used);
|
var activateMsg = new ActivateInWorldEvent(user, used);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public abstract partial class InventorySystem
|
|||||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||||
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!;
|
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!;
|
||||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||||
|
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
|
|
||||||
private void InitializeEquip()
|
private void InitializeEquip()
|
||||||
@@ -162,11 +163,11 @@ public abstract partial class InventorySystem
|
|||||||
public bool CanAccess(EntityUid actor, EntityUid target, EntityUid itemUid)
|
public bool CanAccess(EntityUid actor, EntityUid target, EntityUid itemUid)
|
||||||
{
|
{
|
||||||
// Can the actor reach the target?
|
// 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;
|
return false;
|
||||||
|
|
||||||
// Can the actor reach the item?
|
// Can the actor reach the item?
|
||||||
if (actor.InRangeUnobstructed(itemUid) && actor.IsInSameOrParentContainer(itemUid))
|
if (_interactionSystem.InRangeUnobstructed(actor, itemUid) && _containerSystem.IsInSameOrParentContainer(actor, itemUid))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Is the item in an open storage UI, i.e., is the user quick-equipping from an open backpack?
|
// 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.ActionBlocker;
|
||||||
using Content.Shared.Alert;
|
|
||||||
using Content.Shared.Buckle.Components;
|
using Content.Shared.Buckle.Components;
|
||||||
using Content.Shared.GameTicking;
|
|
||||||
using Content.Shared.Input;
|
|
||||||
using Content.Shared.Physics.Pull;
|
using Content.Shared.Physics.Pull;
|
||||||
using Content.Shared.Pulling.Components;
|
using Content.Shared.Pulling.Components;
|
||||||
using Content.Shared.Pulling.Events;
|
using Content.Shared.Pulling.Events;
|
||||||
using Content.Shared.Rotatable;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Input.Binding;
|
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Players;
|
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
|
|
||||||
namespace Content.Shared.Pulling
|
namespace Content.Shared.Pulling
|
||||||
@@ -26,6 +15,7 @@ namespace Content.Shared.Pulling
|
|||||||
public abstract partial class SharedPullingSystem : EntitySystem
|
public abstract partial class SharedPullingSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||||
|
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||||
|
|
||||||
public bool CanPull(EntityUid puller, EntityUid pulled)
|
public bool CanPull(EntityUid puller, EntityUid pulled)
|
||||||
{
|
{
|
||||||
@@ -54,7 +44,7 @@ namespace Content.Shared.Pulling
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!puller.IsInSameOrNoContainer(pulled))
|
if (!_containerSystem.IsInSameOrNoContainer(puller, pulled))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace Content.Shared.Verbs
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||||
|
[Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -53,7 +54,7 @@ namespace Content.Shared.Verbs
|
|||||||
canAccess = true;
|
canAccess = true;
|
||||||
else if (EntityManager.EntityExists(target) && _interactionSystem.InRangeUnobstructed(user, target, ignoreInsideBlocker: true))
|
else if (EntityManager.EntityExists(target) && _interactionSystem.InRangeUnobstructed(user, target, ignoreInsideBlocker: true))
|
||||||
{
|
{
|
||||||
if (user.IsInSameOrParentContainer(target))
|
if (ContainerSystem.IsInSameOrParentContainer(user, target))
|
||||||
canAccess = true;
|
canAccess = true;
|
||||||
else
|
else
|
||||||
// the item might be in a backpack that the user has open
|
// the item might be in a backpack that the user has open
|
||||||
|
|||||||
Reference in New Issue
Block a user