From b177fb8179eaf7a3b1c9fc9dabe36835e582cd06 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sun, 26 May 2024 15:20:29 +1200 Subject: [PATCH] Make NetworkConfigurator use BoundUserInterfaceCheckRangeEvent (#28293) --- .../Systems/NetworkConfiguratorSystem.cs | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs index 3460124158..402d005dd4 100644 --- a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs @@ -63,9 +63,21 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem SubscribeLocalEvent(OnToggleLinks); SubscribeLocalEvent(OnConfigButtonPressed); + SubscribeLocalEvent(OnUiRangeCheck); + SubscribeLocalEvent(OnComponentRemoved); } + private void OnUiRangeCheck(Entity ent, ref BoundUserInterfaceCheckRangeEvent args) + { + if (ent.Comp.ActiveDeviceList == null || args.Result == BoundUserInterfaceRangeResult.Fail) + return; + + DebugTools.Assert(Exists(ent.Comp.ActiveDeviceList)); + if (!_interactionSystem.InRangeUnobstructed(args.Actor!, ent.Comp.ActiveDeviceList.Value)) + args.Result = BoundUserInterfaceRangeResult.Fail; + } + private void OnShutdown(EntityUid uid, NetworkConfiguratorComponent component, ComponentShutdown args) { ClearDevices(uid, component); @@ -75,23 +87,6 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem component.ActiveDeviceList = null; } - public override void Update(float frameTime) - { - base.Update(frameTime); - - var query = EntityQueryEnumerator(); - while (query.MoveNext(out var uid, out var component)) - { - if (component.ActiveDeviceList != null - && EntityManager.EntityExists(component.ActiveDeviceList.Value) - && _interactionSystem.InRangeUnobstructed(uid, component.ActiveDeviceList.Value)) - continue; - - //The network configurator is a handheld device. There can only ever be an ui session open for the player holding the device. - _uiSystem.CloseUi(uid, NetworkConfiguratorUiKey.Configure); - } - } - private void OnMapInit(EntityUid uid, NetworkConfiguratorComponent component, MapInitEvent args) { UpdateListUiState(uid, component);