diff --git a/Content.Server/Pointing/EntitySystems/PointingSystem.cs b/Content.Server/Pointing/EntitySystems/PointingSystem.cs index 23c70d78f4..e12cb24ca7 100644 --- a/Content.Server/Pointing/EntitySystems/PointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/PointingSystem.cs @@ -9,6 +9,7 @@ using Content.Shared.Ghost; using Content.Shared.IdentityManagement; using Content.Shared.Input; using Content.Shared.Interaction; +using Content.Shared.Inventory; using Content.Shared.Mind; using Content.Shared.Pointing; using Content.Shared.Popups; @@ -16,6 +17,7 @@ using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Configuration; +using Robust.Shared.Containers; using Robust.Shared.Enums; using Robust.Shared.GameStates; using Robust.Shared.Input.Binding; @@ -36,6 +38,7 @@ namespace Content.Server.Pointing.EntitySystems [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly RotateToFaceSystem _rotateToFaceSystem = default!; + [Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly VisibilitySystem _visibilitySystem = default!; [Dependency] private readonly SharedMindSystem _minds = default!; @@ -208,15 +211,66 @@ namespace Content.Server.Pointing.EntitySystems { var pointedName = Identity.Entity(pointed, EntityManager); - selfMessage = player == pointed - ? Loc.GetString("pointing-system-point-at-self") - : Loc.GetString("pointing-system-point-at-other", ("other", pointedName)); + EntityUid? containingInventory = null; + // Search up through the target's containing containers until we find an inventory + var inventoryQuery = GetEntityQuery(); + foreach (var container in _container.GetContainingContainers(pointed)) + { + if (inventoryQuery.HasComp(container.Owner)) + { + // We want the innermost inventory, since that's the "owner" of the item + containingInventory = container.Owner; + break; + } + } - viewerMessage = player == pointed - ? Loc.GetString("pointing-system-point-at-self-others", ("otherName", playerName), ("other", playerName)) - : Loc.GetString("pointing-system-point-at-other-others", ("otherName", playerName), ("other", pointedName)); + var pointingAtSelf = player == pointed; - viewerPointedAtMessage = Loc.GetString("pointing-system-point-at-you-other", ("otherName", playerName)); + // Are we in a mob's inventory? + if (containingInventory != null) + { + var item = pointed; + var itemName = Identity.Entity(item, EntityManager); + + // Target the pointing at the item's holder + pointed = containingInventory.Value; + pointedName = Identity.Entity(pointed, EntityManager); + var pointingAtOwnItem = player == pointed; + + if (pointingAtOwnItem) + { + // You point at your item + selfMessage = Loc.GetString("pointing-system-point-in-own-inventory-self", ("item", itemName)); + // Urist McPointer points at his item + viewerMessage = Loc.GetString("pointing-system-point-in-own-inventory-others", ("item", itemName), ("pointer", playerName)); + } + else + { + // You point at Urist McHands' item + selfMessage = Loc.GetString("pointing-system-point-in-other-inventory-self", ("item", itemName), ("wearer", pointedName)); + // Urist McPointer points at Urist McWearer's item + viewerMessage = Loc.GetString("pointing-system-point-in-other-inventory-others", ("item", itemName), ("pointer", playerName), ("wearer", pointedName)); + // Urist McPointer points at your item + viewerPointedAtMessage = Loc.GetString("pointing-system-point-in-other-inventory-target", ("item", itemName), ("pointer", playerName)); + } + } + else + { + selfMessage = pointingAtSelf + // You point at yourself + ? Loc.GetString("pointing-system-point-at-self") + // You point at Urist McTarget + : Loc.GetString("pointing-system-point-at-other", ("other", pointedName)); + + viewerMessage = pointingAtSelf + // Urist McPointer points at himself + ? Loc.GetString("pointing-system-point-at-self-others", ("otherName", playerName), ("other", playerName)) + // Urist McPointer points at Urist McTarget + : Loc.GetString("pointing-system-point-at-other-others", ("otherName", playerName), ("other", pointedName)); + + // Urist McPointer points at you + viewerPointedAtMessage = Loc.GetString("pointing-system-point-at-you-other", ("otherName", playerName)); + } var ev = new AfterPointedAtEvent(pointed); RaiseLocalEvent(player, ref ev); diff --git a/Resources/Locale/en-US/entity-systems/pointing/pointing-system.ftl b/Resources/Locale/en-US/entity-systems/pointing/pointing-system.ftl index be7b6196b2..edd8440db6 100644 --- a/Resources/Locale/en-US/entity-systems/pointing/pointing-system.ftl +++ b/Resources/Locale/en-US/entity-systems/pointing/pointing-system.ftl @@ -7,4 +7,9 @@ pointing-system-point-at-self-others = {CAPITALIZE(THE($otherName))} points at { pointing-system-point-at-other-others = {CAPITALIZE(THE($otherName))} points at {THE($other)}. pointing-system-point-at-you-other = {CAPITALIZE(THE($otherName))} points at you. pointing-system-point-at-tile = You point at the {$tileName}. +pointing-system-point-in-own-inventory-self = You point at your {$item}. +pointing-system-point-in-own-inventory-others = {CAPITALIZE(THE($pointer))} points at {THE($pointer)}'s {$item}. +pointing-system-point-in-other-inventory-self = You point at {THE($wearer)}'s {$item}. +pointing-system-point-in-other-inventory-target = {CAPITALIZE(THE($pointer))} points at your {$item}. +pointing-system-point-in-other-inventory-others = {CAPITALIZE(THE($pointer))} points at {THE($wearer)}'s {$item}. pointing-system-other-point-at-tile = {CAPITALIZE(THE($otherName))} points at the {$tileName}.