Remove 700 usages of Component.Owner (#21100)

This commit is contained in:
DrSmugleaf
2023-10-19 12:34:31 -07:00
committed by GitHub
parent 5825ffb95c
commit f560f88eb5
261 changed files with 2291 additions and 2036 deletions

View File

@@ -1,10 +1,9 @@
using Content.Client.NetworkConfigurator.Systems;
using Content.Shared.DeviceNetwork;
using Content.Shared.DeviceNetwork.Components;
using Robust.Client.Graphics;
using Robust.Shared.Enums;
using Robust.Shared.Random;
using Robust.Shared.Map;
using Robust.Shared.Random;
namespace Content.Client.NetworkConfigurator;
@@ -28,24 +27,25 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay
protected override void Draw(in OverlayDrawArgs args)
{
foreach (var tracker in _entityManager.EntityQuery<NetworkConfiguratorActiveLinkOverlayComponent>())
var query = _entityManager.EntityQueryEnumerator<NetworkConfiguratorActiveLinkOverlayComponent>();
while (query.MoveNext(out var uid, out _))
{
if (_entityManager.Deleted(tracker.Owner) || !_entityManager.TryGetComponent(tracker.Owner, out DeviceListComponent? deviceList))
if (_entityManager.Deleted(uid) || !_entityManager.TryGetComponent(uid, out DeviceListComponent? deviceList))
{
_entityManager.RemoveComponentDeferred<NetworkConfiguratorActiveLinkOverlayComponent>(tracker.Owner);
_entityManager.RemoveComponentDeferred<NetworkConfiguratorActiveLinkOverlayComponent>(uid);
continue;
}
if (!Colors.TryGetValue(tracker.Owner, out var color))
if (!Colors.TryGetValue(uid, out var color))
{
color = new Color(
_random.Next(0, 255),
_random.Next(0, 255),
_random.Next(0, 255));
Colors.Add(tracker.Owner, color);
Colors.Add(uid, color);
}
var sourceTransform = _entityManager.GetComponent<TransformComponent>(tracker.Owner);
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,
@@ -53,7 +53,7 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay
continue;
}
foreach (var device in _deviceListSystem.GetAllDevices(tracker.Owner, deviceList))
foreach (var device in _deviceListSystem.GetAllDevices(uid, deviceList))
{
if (_entityManager.Deleted(device))
{
@@ -66,7 +66,7 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay
continue;
}
args.WorldHandle.DrawLine(sourceTransform.WorldPosition, linkTransform.WorldPosition, Colors[tracker.Owner]);
args.WorldHandle.DrawLine(sourceTransform.WorldPosition, linkTransform.WorldPosition, Colors[uid]);
}
}
}