Fix user interface interaction validation (#36480)
This commit is contained in:
@@ -106,7 +106,9 @@ namespace Content.Shared.Interaction
|
||||
_uiQuery = GetEntityQuery<ActivatableUIComponent>();
|
||||
|
||||
SubscribeLocalEvent<BoundUserInterfaceCheckRangeEvent>(HandleUserInterfaceRangeCheck);
|
||||
SubscribeLocalEvent<ActivatableUIComponent, BoundUserInterfaceMessageAttempt>(OnBoundInterfaceInteractAttempt);
|
||||
|
||||
// TODO make this a broadcast event subscription again when engine has updated.
|
||||
SubscribeLocalEvent<UserInterfaceComponent, BoundUserInterfaceMessageAttempt>(OnBoundInterfaceInteractAttempt);
|
||||
|
||||
SubscribeAllEvent<InteractInventorySlotEvent>(HandleInteractInventorySlotEvent);
|
||||
|
||||
@@ -151,12 +153,15 @@ namespace Content.Shared.Interaction
|
||||
/// <summary>
|
||||
/// Check that the user that is interacting with the BUI is capable of interacting and can access the entity.
|
||||
/// </summary>
|
||||
private void OnBoundInterfaceInteractAttempt(Entity<ActivatableUIComponent> ent, ref BoundUserInterfaceMessageAttempt ev)
|
||||
private void OnBoundInterfaceInteractAttempt(Entity<UserInterfaceComponent> ent, ref BoundUserInterfaceMessageAttempt ev)
|
||||
{
|
||||
_uiQuery.TryComp(ev.Target, out var aUiComp);
|
||||
if (!_actionBlockerSystem.CanInteract(ev.Actor, ev.Target))
|
||||
{
|
||||
// We permit ghosts to open uis unless explicitly blocked
|
||||
if (ev.Message is not OpenBoundInterfaceMessage || !HasComp<GhostComponent>(ev.Actor) || ent.Comp.BlockSpectators)
|
||||
if (ev.Message is not OpenBoundInterfaceMessage
|
||||
|| !HasComp<GhostComponent>(ev.Actor)
|
||||
|| aUiComp?.BlockSpectators == true)
|
||||
{
|
||||
ev.Cancel();
|
||||
return;
|
||||
@@ -174,14 +179,16 @@ namespace Content.Shared.Interaction
|
||||
return;
|
||||
}
|
||||
|
||||
if (aUiComp == null)
|
||||
return;
|
||||
|
||||
if (ent.Comp.SingleUser && ent.Comp.CurrentSingleUser != null && ent.Comp.CurrentSingleUser != ev.Actor)
|
||||
if (aUiComp.SingleUser && aUiComp.CurrentSingleUser != null && aUiComp.CurrentSingleUser != ev.Actor)
|
||||
{
|
||||
ev.Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ent.Comp.RequiresComplex && !_actionBlockerSystem.CanComplexInteract(ev.Actor))
|
||||
if (aUiComp.RequiresComplex && !_actionBlockerSystem.CanComplexInteract(ev.Actor))
|
||||
ev.Cancel();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user