diff --git a/Content.Client/NetworkConfigurator/NetworkConfiguratorBoundUserInterface.cs b/Content.Client/NetworkConfigurator/NetworkConfiguratorBoundUserInterface.cs index 74b2732826..e69ea43aa6 100644 --- a/Content.Client/NetworkConfigurator/NetworkConfiguratorBoundUserInterface.cs +++ b/Content.Client/NetworkConfigurator/NetworkConfiguratorBoundUserInterface.cs @@ -55,20 +55,7 @@ public sealed class NetworkConfiguratorBoundUserInterface : BoundUserInterface private void OnShowPressed(BaseButton.ButtonEventArgs args) { - if (!args.Button.Pressed) - { - _netConfig.ToggleVisualization(Owner.Owner, false); - return; - } - - if (_entityManager.GetComponent(Owner.Owner).EntityLifeStage == EntityLifeStage.Initialized) - { - // We're in mapping mode. Do something hacky. - SendMessage(new ManualDeviceListSyncMessage(null, null)); - return; - } - - _netConfig.ToggleVisualization(Owner.Owner, true); + _netConfig.ToggleVisualization(Owner.Owner, args.Button.Pressed); } protected override void UpdateState(BoundUserInterfaceState state) @@ -86,25 +73,6 @@ public sealed class NetworkConfiguratorBoundUserInterface : BoundUserInterface } } - protected override void ReceiveMessage(BoundUserInterfaceMessage message) - { - base.ReceiveMessage(message); - - if (_configurationMenu == null - || _entityManager.GetComponent(Owner.Owner).EntityLifeStage > EntityLifeStage.Initialized - || message is not ManualDeviceListSyncMessage cast - || cast.Device == null - || cast.Devices == null) - { - return; - } - - _netConfig.SetActiveDeviceList(Owner.Owner, cast.Device.Value); - _deviceList.UpdateDeviceList(cast.Device.Value, cast.Devices); - _netConfig.ToggleVisualization(Owner.Owner, true); - _configurationMenu.Show.Pressed = true; - } - protected override void Dispose(bool disposing) { base.Dispose(disposing); diff --git a/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs b/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs index 8041a5a88f..18e9b7a46c 100644 --- a/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs @@ -12,10 +12,16 @@ public sealed class DeviceListSystem : SharedDeviceListSystem public override void Initialize() { base.Initialize(); + SubscribeLocalEvent(OnInit); SubscribeLocalEvent(OnBeforeBroadcast); SubscribeLocalEvent(OnBeforePacketSent); } + public void OnInit(EntityUid uid, DeviceListComponent component, ComponentInit args) + { + Dirty(component); + } + /// /// Gets the given device list as a dictionary /// diff --git a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs index 62306745e0..b52ab99668 100644 --- a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs @@ -46,7 +46,6 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem SubscribeLocalEvent(OnRemoveDevice); SubscribeLocalEvent(OnClearDevice); SubscribeLocalEvent(OnConfigButtonPressed); - SubscribeLocalEvent(ManualDeviceListSync); SubscribeLocalEvent(OnComponentRemoved); } @@ -330,20 +329,5 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem _deviceListSystem.GetDeviceList(component.ActiveDeviceList.Value) .Select(v => (v.Key, MetaData(v.Value).EntityName)).ToHashSet())); } - - // hacky solution related to mapping - private void ManualDeviceListSync(EntityUid uid, NetworkConfiguratorComponent comp, - ManualDeviceListSyncMessage args) - { - if (comp.ActiveDeviceList == null || args.Session is not IPlayerSession player) - { - return; - } - - var devices = _deviceListSystem.GetAllDevices(comp.ActiveDeviceList.Value).ToHashSet(); - - _uiSystem.TrySendUiMessage(uid, NetworkConfiguratorUiKey.Configure, new ManualDeviceListSyncMessage(comp.ActiveDeviceList.Value, devices), player); - } - #endregion } diff --git a/Content.Shared/DeviceNetwork/Systems/SharedDeviceListSystem.cs b/Content.Shared/DeviceNetwork/Systems/SharedDeviceListSystem.cs index 28771b43fa..66f5cbc25a 100644 --- a/Content.Shared/DeviceNetwork/Systems/SharedDeviceListSystem.cs +++ b/Content.Shared/DeviceNetwork/Systems/SharedDeviceListSystem.cs @@ -17,6 +17,7 @@ public abstract class SharedDeviceListSystem : EntitySystem /// The entity to update. /// The devices to store. /// Whether to merge or replace the devices stored. + /// If the component should be dirtied upon this call. /// Device list component public DeviceListUpdateResult UpdateDeviceList(EntityUid uid, IEnumerable devices, bool merge = false, DeviceListComponent? deviceList = null) { diff --git a/Content.Shared/DeviceNetwork/Systems/SharedNetworkConfiguratorSystem.cs b/Content.Shared/DeviceNetwork/Systems/SharedNetworkConfiguratorSystem.cs index 1af5393ae4..29400e110c 100644 --- a/Content.Shared/DeviceNetwork/Systems/SharedNetworkConfiguratorSystem.cs +++ b/Content.Shared/DeviceNetwork/Systems/SharedNetworkConfiguratorSystem.cs @@ -14,8 +14,6 @@ public abstract class SharedNetworkConfiguratorSystem : EntitySystem SubscribeLocalEvent(HandleNetworkConfiguratorState); } - - private void GetNetworkConfiguratorState(EntityUid uid, NetworkConfiguratorComponent comp, ref ComponentGetState args) { @@ -34,19 +32,6 @@ public abstract class SharedNetworkConfiguratorSystem : EntitySystem } } -[Serializable, NetSerializable] -public sealed class ManualDeviceListSyncMessage : BoundUserInterfaceMessage -{ - public ManualDeviceListSyncMessage(EntityUid? device, HashSet? devices) - { - Device = device; - Devices = devices; - } - - public EntityUid? Device { get; } - public HashSet? Devices { get; } -} - public sealed class ClearAllOverlaysEvent : InstantActionEvent { }