diff --git a/Content.Client/Examine/ExamineSystem.cs b/Content.Client/Examine/ExamineSystem.cs index 564a901769..a85ea488ba 100644 --- a/Content.Client/Examine/ExamineSystem.cs +++ b/Content.Client/Examine/ExamineSystem.cs @@ -39,8 +39,6 @@ namespace Content.Client.Examine public override void Initialize() { - IoCManager.InjectDependencies(this); - UpdatesOutsidePrediction = true; SubscribeLocalEvent(AddExamineVerb); diff --git a/Content.Client/Verbs/VerbSystem.cs b/Content.Client/Verbs/VerbSystem.cs index 7dfe818fcd..a9c9586e43 100644 --- a/Content.Client/Verbs/VerbSystem.cs +++ b/Content.Client/Verbs/VerbSystem.cs @@ -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); } } diff --git a/Content.Server/Examine/ExamineSystem.cs b/Content.Server/Examine/ExamineSystem.cs index eb91139539..5bf6e4a6bd 100644 --- a/Content.Server/Examine/ExamineSystem.cs +++ b/Content.Server/Examine/ExamineSystem.cs @@ -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(ExamineInfoRequest); - - IoCManager.InjectDependencies(this); } private void ExamineInfoRequest(ExamineSystemMessages.RequestExamineInfoMessage request, EntitySessionEventArgs eventArgs) diff --git a/Content.Server/Interaction/InteractionSystem.cs b/Content.Server/Interaction/InteractionSystem.cs index 823b369b54..3292a21440 100644 --- a/Content.Server/Interaction/InteractionSystem.cs +++ b/Content.Server/Interaction/InteractionSystem.cs @@ -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"); diff --git a/Content.Shared/Examine/ExamineSystemShared.cs b/Content.Shared/Examine/ExamineSystemShared.cs index 3940e6369e..1172875d23 100644 --- a/Content.Shared/Examine/ExamineSystemShared.cs +++ b/Content.Shared/Examine/ExamineSystemShared.cs @@ -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!; + /// /// Examine range to use when the examiner is in critical condition. /// @@ -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] diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index fd85fe034b..7f5269b739 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -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); diff --git a/Content.Shared/Inventory/InventorySystem.Equip.cs b/Content.Shared/Inventory/InventorySystem.Equip.cs index 0c13929529..2b25abda1e 100644 --- a/Content.Shared/Inventory/InventorySystem.Equip.cs +++ b/Content.Shared/Inventory/InventorySystem.Equip.cs @@ -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? diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs index a5cb4d11b9..5e34801595 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs @@ -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; } diff --git a/Content.Shared/Verbs/SharedVerbSystem.cs b/Content.Shared/Verbs/SharedVerbSystem.cs index b8c172433a..0a69457515 100644 --- a/Content.Shared/Verbs/SharedVerbSystem.cs +++ b/Content.Shared/Verbs/SharedVerbSystem.cs @@ -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