Device link visualizer (#11054)
* shuffles devicelist to shared, adds an overlay for devicelist * adds space property to overlay * moves networkconfigurator to shared, makes devicelistsystem clientside check activedevicelist * dirties components upon change, adds networkedcomponent to sharednetworkconfigurator * state handlers for networked components * whoops * lots of shuffling, renaming, and access changes * randomizes color for every new entity added to the overlay * adds a client-side action to clear all network overlays if they're active * clones action (oops) * localization, adds a command for clearing network link overlays (in case the action disappears) * moves the entity manager up into the bui fields * makes that a dependency * attempts to just directly get the color from the dict when drawing, now * fixes up a few comments * adds dirty on init to devicelistcomponent * hacky solution related to mapping with a networkconfigurator * more stricter bound on that hacky solution * just checks if the life stage is initialized instead of if the entity was initialized * moves getalldevices to shared * readds linq import * tries to ensure that the show button is toggled on if the device we're trying to configure is currently being tracked by the overlay * some reorganization
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using System.Linq;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
@@ -11,13 +12,14 @@ using Content.Shared.Popups;
|
||||
using Content.Shared.Verbs;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.DeviceNetwork.Systems;
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class NetworkConfiguratorSystem : EntitySystem
|
||||
public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
{
|
||||
[Dependency] private readonly DeviceListSystem _deviceListSystem = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
@@ -44,6 +46,7 @@ public sealed class NetworkConfiguratorSystem : EntitySystem
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorRemoveDeviceMessage>(OnRemoveDevice);
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorClearDevicesMessage>(OnClearDevice);
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorButtonPressedMessage>(OnConfigButtonPressed);
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, ManualDeviceListSyncMessage>(ManualDeviceListSync);
|
||||
|
||||
SubscribeLocalEvent<DeviceListComponent, ComponentRemove>(OnComponentRemoved);
|
||||
}
|
||||
@@ -217,6 +220,7 @@ public sealed class NetworkConfiguratorSystem : EntitySystem
|
||||
return;
|
||||
|
||||
configurator.ActiveDeviceList = targetUid;
|
||||
Dirty(configurator);
|
||||
_uiSystem.GetUiOrNull(configurator.Owner, NetworkConfiguratorUiKey.Configure)?.Open(actor.PlayerSession);
|
||||
}
|
||||
|
||||
@@ -299,10 +303,25 @@ public sealed class NetworkConfiguratorSystem : EntitySystem
|
||||
UpdateUiState(uid, component);
|
||||
break;
|
||||
case NetworkConfiguratorButtonKey.Show:
|
||||
_deviceListSystem.ToggleVisualization(component.ActiveDeviceList.Value);
|
||||
// This should be done client-side.
|
||||
// _deviceListSystem.ToggleVisualization(component.ActiveDeviceList.Value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user