From 855720c9dc48216e22ad0040ede9640136fa1eab Mon Sep 17 00:00:00 2001 From: vulppine Date: Tue, 30 Aug 2022 21:56:42 -0700 Subject: [PATCH] makes devicelist work if the map hasn't been initialized yet instead of storing the address, it instead stores the entityUID if in mapping mode --- .../Systems/NetworkConfiguratorSystem.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs index fc76b70f12..e1cd2e3429 100644 --- a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs @@ -30,6 +30,8 @@ public sealed class NetworkConfiguratorSystem : EntitySystem { base.Initialize(); + SubscribeLocalEvent(OnMapInit); + //Interaction SubscribeLocalEvent((uid, component, args) => OnUsed(uid, component, args.Target, args.User, args.CanReach)); //TODO: Replace with utility verb? @@ -63,6 +65,11 @@ public sealed class NetworkConfiguratorSystem : EntitySystem } } + private void OnMapInit(EntityUid uid, NetworkConfiguratorComponent component, MapInitEvent args) + { + component.Devices.Clear(); + } + private void TryAddNetworkDevice(EntityUid? targetUid, EntityUid configuratorUid, EntityUid userUid, NetworkConfiguratorComponent? configurator = null) { @@ -77,10 +84,17 @@ public sealed class NetworkConfiguratorSystem : EntitySystem if (!targetUid.HasValue || !Resolve(targetUid.Value, ref device, false)) return; - if (string.IsNullOrEmpty(device.Address)) + var address = device.Address; + if (string.IsNullOrEmpty(address)) { - _popupSystem.PopupCursor(Loc.GetString("network-configurator-device-failed", ("device", targetUid)), Filter.Entities(userUid)); - return; + if (MetaData(targetUid.Value).EntityLifeStage == EntityLifeStage.MapInitialized) + { + _popupSystem.PopupCursor(Loc.GetString("network-configurator-device-failed", ("device", targetUid)), + Filter.Entities(userUid)); + return; + } + + address = $"UID: {targetUid.Value.ToString()}"; } if (configurator.Devices.ContainsValue(targetUid.Value)) @@ -89,7 +103,7 @@ public sealed class NetworkConfiguratorSystem : EntitySystem return; } - configurator.Devices.Add(device.Address, targetUid.Value); + configurator.Devices.Add(address, targetUid.Value); _popupSystem.PopupCursor(Loc.GetString("network-configurator-device-saved", ("address", device.Address), ("device", targetUid)), Filter.Entities(userUid), PopupType.Medium);