Make NetworkConfigurator use BoundUserInterfaceCheckRangeEvent (#28293)
This commit is contained in:
@@ -63,9 +63,21 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
|||||||
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorToggleLinkMessage>(OnToggleLinks);
|
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorToggleLinkMessage>(OnToggleLinks);
|
||||||
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorButtonPressedMessage>(OnConfigButtonPressed);
|
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorButtonPressedMessage>(OnConfigButtonPressed);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<NetworkConfiguratorComponent, BoundUserInterfaceCheckRangeEvent>(OnUiRangeCheck);
|
||||||
|
|
||||||
SubscribeLocalEvent<DeviceListComponent, ComponentRemove>(OnComponentRemoved);
|
SubscribeLocalEvent<DeviceListComponent, ComponentRemove>(OnComponentRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnUiRangeCheck(Entity<NetworkConfiguratorComponent> 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)
|
private void OnShutdown(EntityUid uid, NetworkConfiguratorComponent component, ComponentShutdown args)
|
||||||
{
|
{
|
||||||
ClearDevices(uid, component);
|
ClearDevices(uid, component);
|
||||||
@@ -75,23 +87,6 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
|||||||
component.ActiveDeviceList = null;
|
component.ActiveDeviceList = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
|
||||||
{
|
|
||||||
base.Update(frameTime);
|
|
||||||
|
|
||||||
var query = EntityQueryEnumerator<NetworkConfiguratorComponent>();
|
|
||||||
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)
|
private void OnMapInit(EntityUid uid, NetworkConfiguratorComponent component, MapInitEvent args)
|
||||||
{
|
{
|
||||||
UpdateListUiState(uid, component);
|
UpdateListUiState(uid, component);
|
||||||
|
|||||||
Reference in New Issue
Block a user