diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 9a2706d8a0..00246bafcd 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -106,7 +106,9 @@ namespace Content.Shared.Interaction _uiQuery = GetEntityQuery(); SubscribeLocalEvent(HandleUserInterfaceRangeCheck); - SubscribeLocalEvent(OnBoundInterfaceInteractAttempt); + + // TODO make this a broadcast event subscription again when engine has updated. + SubscribeLocalEvent(OnBoundInterfaceInteractAttempt); SubscribeAllEvent(HandleInteractInventorySlotEvent); @@ -151,12 +153,15 @@ namespace Content.Shared.Interaction /// /// Check that the user that is interacting with the BUI is capable of interacting and can access the entity. /// - private void OnBoundInterfaceInteractAttempt(Entity ent, ref BoundUserInterfaceMessageAttempt ev) + private void OnBoundInterfaceInteractAttempt(Entity 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(ev.Actor) || ent.Comp.BlockSpectators) + if (ev.Message is not OpenBoundInterfaceMessage + || !HasComp(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(); }