Improve messages for pointing at items in inventories (#36252)
* 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
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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}.
|
||||
|
||||
Reference in New Issue
Block a user