Verb tweaks (#31309)

* Verb tweaks

Remove the LOS check because this is already done above in CanExamine.

* Fix outlines

* import
This commit is contained in:
metalgearsloth
2024-08-25 22:05:39 +10:00
committed by GitHub
parent cc710fa46b
commit 7cb6b5e972
4 changed files with 49 additions and 40 deletions

View File

@@ -67,6 +67,14 @@ namespace Content.Client.Verbs
? Visibility
: Visibility | MenuVisibility.NoFov;
var ev = new MenuVisibilityEvent()
{
TargetPos = targetPos,
Visibility = visibility,
};
RaiseLocalEvent(player.Value, ref ev);
visibility = ev.Visibility;
// Get entities
List<EntityUid> entities;
@@ -77,13 +85,8 @@ namespace Content.Client.Verbs
var entitiesUnderMouse = gameScreenBase.GetClickableEntities(targetPos).ToHashSet();
bool Predicate(EntityUid e) => e == player || entitiesUnderMouse.Contains(e);
// first check the general location.
if (!_examine.CanExamine(player.Value, targetPos, Predicate))
return false;
TryComp(player.Value, out ExaminerComponent? examiner);
// Then check every entity
entities = new();
foreach (var ent in _entityLookup.GetEntitiesInRange(targetPos, EntityMenuLookupSize))
{
@@ -137,27 +140,6 @@ namespace Content.Client.Verbs
}
}
// Remove any entities that do not have LOS
if ((visibility & MenuVisibility.NoFov) == 0)
{
var xformQuery = GetEntityQuery<TransformComponent>();
var playerPos = _transform.GetMapCoordinates(player.Value, xform: xformQuery.GetComponent(player.Value));
for (var i = entities.Count - 1; i >= 0; i--)
{
var entity = entities[i];
if (!_examine.InRangeUnOccluded(
playerPos,
_transform.GetMapCoordinates(entity, xform: xformQuery.GetComponent(entity)),
ExamineSystemShared.ExamineRange,
null))
{
entities.RemoveSwap(i);
}
}
}
if (entities.Count == 0)
return false;
@@ -229,15 +211,4 @@ namespace Content.Client.Verbs
OnVerbsResponse?.Invoke(msg);
}
}
[Flags]
public enum MenuVisibility
{
// What entities can a user see on the entity menu?
Default = 0, // They can only see entities in FoV.
NoFov = 1 << 0, // They ignore FoV restrictions
InContainer = 1 << 1, // They can see through containers.
Invisible = 1 << 2, // They can see entities without sprites and the "HideContextMenu" tag is ignored.
All = NoFov | InContainer | Invisible
}
}