* Fix TransformComponent.MapPosition warnings in Content.Client * Fix TransformComponent.MapPosition warnings in Content.IntegrationTests * Fix TransformComponent.MapPosition warnings in Content.Shared * Fix TransformComponent.MapPosition warnings in Content.Server * Fix TransformComponent.WorldPosition warnings in Content.Shared * Fix TransformComponent.WorldPosition warnings in Content.Client Excepts ClickableComponent b/c that needs to be ECS'd entirely later * Fix TransformComponent.WorldPosition warnings in Content.Server * Fix TransformComponent.WorldRotation warnings in Content.* * Fix TransformComponent.MapPosition warnings I missed * Fix TransformComponent.WorldMatrix warnings in Content.* * Fix TransformComponent.InvWorldMatrix warnings in Content.* * Fix TransformComponent.GetWorldPositionRotationMatrixWithInv warnings in Content.* * Fix TransformComponent.GetWorldPositionRotationMatrix warnings in Content.* * Fix TransformComponent.GetWorldPositionRotation warnings in Content.* * Fix TransformComponent.Anchored.set warnings in Content.* * Fix TransformComponent.Coordinates.set warnings in Content.* * Fix TransformComponent.LocalPosition.set warnings in Content.* * Fix TransformComponent.AttachToGridOrMap warnings in Content.* * Fix TransformComponent.AttachParent warnings in Content.* * Preempt TransformComponent.LocalRotation.set warnings in Content.Shared * Preempt TransformComponent.LocalRotation.set warnings in Content.Client * Preempt TransformComponent.LocalRotation.set warnings in Content.IntegrationTests * Preempt TransformComponent.LocalRotation.set warnings in Content.Server * Fix/Preempt the remaining obsolete TransformComponent properties/methods in Content.* * ECS ClickableComponent * Fix obsolete SharedTransformSystem methods in Content.* * Fix ExplosionOverlay `SharedTransformSystem` dependency * Maybe fix null eye position breaking tests * MGS requested changes
76 lines
2.7 KiB
C#
76 lines
2.7 KiB
C#
using Content.Client.NetworkConfigurator.Systems;
|
|
using Content.Shared.DeviceNetwork.Components;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Shared.Enums;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Random;
|
|
|
|
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 readonly SharedTransformSystem _xformSystem;
|
|
|
|
public Dictionary<EntityUid, Color> Colors = new();
|
|
public EntityUid? Action;
|
|
|
|
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
|
|
|
public NetworkConfiguratorLinkOverlay()
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
_deviceListSystem = _entityManager.System<DeviceListSystem>();
|
|
_xformSystem = _entityManager.System<SharedTransformSystem>();
|
|
}
|
|
|
|
protected override void Draw(in OverlayDrawArgs args)
|
|
{
|
|
var query = _entityManager.EntityQueryEnumerator<NetworkConfiguratorActiveLinkOverlayComponent>();
|
|
while (query.MoveNext(out var uid, out _))
|
|
{
|
|
if (_entityManager.Deleted(uid) || !_entityManager.TryGetComponent(uid, out DeviceListComponent? deviceList))
|
|
{
|
|
_entityManager.RemoveComponentDeferred<NetworkConfiguratorActiveLinkOverlayComponent>(uid);
|
|
continue;
|
|
}
|
|
|
|
if (!Colors.TryGetValue(uid, out var color))
|
|
{
|
|
color = new Color(
|
|
_random.Next(0, 255),
|
|
_random.Next(0, 255),
|
|
_random.Next(0, 255));
|
|
Colors.Add(uid, color);
|
|
}
|
|
|
|
var sourceTransform = _entityManager.GetComponent<TransformComponent>(uid);
|
|
if (sourceTransform.MapID == MapId.Nullspace)
|
|
{
|
|
// Can happen if the item is outside the client's view. In that case,
|
|
// we don't have a sensible transform to draw, so we need to skip it.
|
|
continue;
|
|
}
|
|
|
|
foreach (var device in _deviceListSystem.GetAllDevices(uid, deviceList))
|
|
{
|
|
if (_entityManager.Deleted(device))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var linkTransform = _entityManager.GetComponent<TransformComponent>(device);
|
|
if (linkTransform.MapID == MapId.Nullspace)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
args.WorldHandle.DrawLine(_xformSystem.GetWorldPosition(sourceTransform), _xformSystem.GetWorldPosition(linkTransform), Colors[uid]);
|
|
}
|
|
}
|
|
}
|
|
}
|