Removes hacky behavior from DeviceListSystem (#11255)

This commit is contained in:
Flipp Syder
2022-09-13 23:09:43 -07:00
committed by GitHub
parent 737002248b
commit ec6cdbd51a
5 changed files with 8 additions and 64 deletions

View File

@@ -12,10 +12,16 @@ public sealed class DeviceListSystem : SharedDeviceListSystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DeviceListComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<DeviceListComponent, BeforeBroadcastAttemptEvent>(OnBeforeBroadcast);
SubscribeLocalEvent<DeviceListComponent, BeforePacketSentEvent>(OnBeforePacketSent);
}
public void OnInit(EntityUid uid, DeviceListComponent component, ComponentInit args)
{
Dirty(component);
}
/// <summary>
/// Gets the given device list as a dictionary
/// </summary>

View File

@@ -46,7 +46,6 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorRemoveDeviceMessage>(OnRemoveDevice);
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorClearDevicesMessage>(OnClearDevice);
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorButtonPressedMessage>(OnConfigButtonPressed);
SubscribeLocalEvent<NetworkConfiguratorComponent, ManualDeviceListSyncMessage>(ManualDeviceListSync);
SubscribeLocalEvent<DeviceListComponent, ComponentRemove>(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
}