]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Improve messages for pointing at items in inventories (#36252)
authorTayrtahn <tayrtahn@gmail.com>
Fri, 18 Apr 2025 12:09:49 +0000 (08:09 -0400)
committerGitHub <noreply@github.com>
Fri, 18 Apr 2025 12:09:49 +0000 (08:09 -0400)
* Show different messages for pointing at items in someone's inventory

* Improve search for inventory (requires engine PR)

* Add comments explaining each GetString

* Better loc ids

* Add comment about using innermost inventory

* Swap conditions for named variables

* Remove POSS-NOUN uses

* Add missing THE

Content.Server/Pointing/EntitySystems/PointingSystem.cs
Resources/Locale/en-US/entity-systems/pointing/pointing-system.ftl

index 23c70d78f48a4716511719768ddb801ed0b3225e..e12cb24ca740e5b9bfa2cde6a329694a1358cf20 100644 (file)
@@ -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<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);
index be7b6196b247e5b8c24cd6e6cbfc8ac4639d82e9..edd8440db67af4b8c7eb7148cc559ace75a94fa5 100644 (file)
@@ -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}.