]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Include container ents in examine (#32267)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Mon, 23 Sep 2024 04:55:30 +0000 (14:55 +1000)
committerGitHub <noreply@github.com>
Mon, 23 Sep 2024 04:55:30 +0000 (14:55 +1000)
Mainly for closets but if it's like a mouse in a bag they can see what's in the bag type deal.

Content.Client/Verbs/VerbSystem.cs

index f990c83d7c2a9f5752ddbe2b3c84e740a56aaa2e..f84389195f8c744531629e060c95c80c932a3225 100644 (file)
@@ -13,6 +13,7 @@ using Robust.Client.GameObjects;
 using Robust.Client.Graphics;
 using Robust.Client.Player;
 using Robust.Client.State;
+using Robust.Shared.Containers;
 using Robust.Shared.Map;
 using Robust.Shared.Utility;
 
@@ -28,6 +29,7 @@ namespace Content.Client.Verbs
         [Dependency] private readonly IStateManager _stateManager = default!;
         [Dependency] private readonly IEyeManager _eyeManager = default!;
         [Dependency] private readonly IPlayerManager _playerManager = default!;
+        [Dependency] private readonly SharedContainerSystem _containers = default!;
 
         /// <summary>
         ///     When a user right clicks somewhere, how large is the box we use to get entities for the context menu?
@@ -81,12 +83,11 @@ namespace Content.Client.Verbs
             // Get entities
             _entities.Clear();
             var entitiesUnderMouse = _tree.QueryAabb(targetPos.MapId, Box2.CenteredAround(targetPos.Position, new Vector2(EntityMenuLookupSize, EntityMenuLookupSize)));
+            bool Predicate(EntityUid e) => e == player;
 
             // Do we have to do FoV checks?
             if ((visibility & MenuVisibility.NoFov) == 0)
             {
-                bool Predicate(EntityUid e) => e == player;
-
                 TryComp(player.Value, out ExaminerComponent? examiner);
 
                 foreach (var ent in entitiesUnderMouse)
@@ -103,6 +104,21 @@ namespace Content.Client.Verbs
                 }
             }
 
+            // If we're in a container list all other entities in it.
+            if (_containers.TryGetContainingContainer(player.Value, out var container))
+            {
+                foreach (var ent in container.ContainedEntities)
+                {
+                    if (ent == player.Value || _entities.Contains(ent))
+                        continue;
+
+                    if ((visibility & MenuVisibility.NoFov) == 0x0 || _examine.CanExamine(player.Value, targetPos, examined: ent))
+                    {
+                        _entities.Add(ent);
+                    }
+                }
+            }
+
             if (_entities.Count == 0)
                 return false;