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;
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;
[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!;
{
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<InventoryComponent>();
+ 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);