* 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
66 lines
2.2 KiB
C#
66 lines
2.2 KiB
C#
using Content.Shared.DeviceNetwork;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Shared.Enums;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Client.NetworkConfigurator;
|
|
|
|
public sealed class NetworkConfiguratorLinkOverlay : Overlay
|
|
{
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
private readonly DeviceListSystem _deviceListSystem;
|
|
|
|
private Dictionary<EntityUid, Color> _colors = new();
|
|
|
|
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
|
|
|
public NetworkConfiguratorLinkOverlay()
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
_deviceListSystem = _entityManager.System<DeviceListSystem>();
|
|
}
|
|
|
|
public void ClearEntity(EntityUid uid)
|
|
{
|
|
_colors.Remove(uid);
|
|
}
|
|
|
|
protected override void Draw(in OverlayDrawArgs args)
|
|
{
|
|
foreach (var tracker in _entityManager.EntityQuery<NetworkConfiguratorActiveLinkOverlayComponent>())
|
|
{
|
|
if (_entityManager.Deleted(tracker.Owner) || !_entityManager.TryGetComponent(tracker.Owner, out DeviceListComponent? deviceList))
|
|
{
|
|
_entityManager.RemoveComponentDeferred<NetworkConfiguratorActiveLinkOverlayComponent>(tracker.Owner);
|
|
continue;
|
|
}
|
|
|
|
if (!_colors.TryGetValue(tracker.Owner, out var color))
|
|
{
|
|
color = new Color(
|
|
_random.Next(0, 255),
|
|
_random.Next(0, 255),
|
|
_random.Next(0, 255));
|
|
_colors.Add(tracker.Owner, color);
|
|
}
|
|
|
|
var sourceTransform = _entityManager.GetComponent<TransformComponent>(tracker.Owner);
|
|
|
|
foreach (var device in _deviceListSystem.GetAllDevices(tracker.Owner, deviceList))
|
|
{
|
|
if (_entityManager.Deleted(device))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var linkTransform = _entityManager.GetComponent<TransformComponent>(device);
|
|
|
|
args.WorldHandle.DrawLine(sourceTransform.WorldPosition, linkTransform.WorldPosition, _colors[tracker.Owner]);
|
|
}
|
|
}
|
|
}
|
|
}
|