Skip to content

Commit

Permalink
Include container ents in examine (#32267)
Browse files Browse the repository at this point in the history
Mainly for closets but if it's like a mouse in a bag they can see what's in the bag type deal.
  • Loading branch information
metalgearsloth authored Sep 23, 2024
1 parent dd7884e commit b2cb813
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Content.Client/Verbs/VerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.State;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Utility;

Expand All @@ -28,6 +29,7 @@ public sealed class VerbSystem : SharedVerbSystem
[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?
Expand Down Expand Up @@ -81,12 +83,11 @@ public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true
// 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)
Expand All @@ -103,6 +104,21 @@ public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true
}
}

// 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;

Expand Down

0 comments on commit b2cb813

Please sign in to comment.