From 3a7274771ea3645621946dc9abbf17f2a2ecd44a Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Sun, 27 Aug 2023 10:27:43 +0200 Subject: [PATCH] Make bound-UI range checks consistent with interaction. (#19461) --- Content.Server/Interaction/InteractionSystem.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Content.Server/Interaction/InteractionSystem.cs b/Content.Server/Interaction/InteractionSystem.cs index ff49bc4bfe..3b03d56ee7 100644 --- a/Content.Server/Interaction/InteractionSystem.cs +++ b/Content.Server/Interaction/InteractionSystem.cs @@ -34,6 +34,8 @@ namespace Content.Server.Interaction base.Initialize(); SubscribeNetworkEvent(HandleDragDropRequestEvent); + + SubscribeLocalEvent(HandleUserInterfaceRangeCheck); } public override bool CanAccessViaStorage(EntityUid user, EntityUid target) @@ -91,5 +93,20 @@ namespace Content.Server.Interaction } #endregion + + private void HandleUserInterfaceRangeCheck(ref BoundUserInterfaceCheckRangeEvent ev) + { + if (ev.Player.AttachedEntity is not { } user) + return; + + if (InRangeUnobstructed(user, ev.Target, ev.UserInterface.InteractionRange)) + { + ev.Result = BoundUserInterfaceRangeResult.Pass; + } + else + { + ev.Result = BoundUserInterfaceRangeResult.Fail; + } + } } }