Restrict examine/context-menu usage when incapacitated. (#5416)

* wip

* update in-view checks

* cleanup
This commit is contained in:
Leon Friedrich
2021-11-22 09:40:09 +13:00
committed by GitHub
parent fda85b4b6b
commit bec1f99f1f
4 changed files with 85 additions and 41 deletions

View File

@@ -46,6 +46,7 @@ namespace Content.Client.ContextMenu.UI
[Dependency] private readonly IEyeManager _eyeManager = default!;
private readonly VerbSystem _verbSystem;
private readonly ExamineSystem _examineSystem;
/// <summary>
/// This maps the currently displayed entities to the actual GUI elements.
@@ -60,6 +61,7 @@ namespace Content.Client.ContextMenu.UI
IoCManager.InjectDependencies(this);
_verbSystem = verbSystem;
_examineSystem = EntitySystem.Get<ExamineSystem>();
_cfg.OnValueChanged(CCVars.EntityMenuGroupingType, OnGroupingChanged, true);
@@ -157,10 +159,9 @@ namespace Content.Client.ContextMenu.UI
var coords = args.Coordinates.ToMap(_entityManager);
if (!_verbSystem.TryGetEntityMenuEntities(coords, out var entities))
return false;
if (_verbSystem.TryGetEntityMenuEntities(coords, out var entities))
OpenRootMenu(entities);
OpenRootMenu(entities);
return true;
}
@@ -183,7 +184,7 @@ namespace Content.Client.ContextMenu.UI
foreach (var entity in Elements.Keys.ToList())
{
if (entity.Deleted || !ignoreFov && !player.InRangeUnOccluded(entity))
if (entity.Deleted || !ignoreFov && !_examineSystem.CanExamine(player, entity))
RemoveEntity(entity);
}
}