diff --git a/Content.Server/Administration/Commands/DeleteComponent.cs b/Content.Server/Administration/Commands/DeleteComponent.cs index e2018c84ae..f4b2a00760 100644 --- a/Content.Server/Administration/Commands/DeleteComponent.cs +++ b/Content.Server/Administration/Commands/DeleteComponent.cs @@ -33,9 +33,8 @@ namespace Content.Server.Administration.Commands var i = 0; - foreach (var component in components) + foreach (var (uid, component) in components) { - var uid = component.Owner; entityManager.RemoveComponent(uid, component); i++; } diff --git a/Content.Server/Administration/Commands/DeleteEntitiesWithComponent.cs b/Content.Server/Administration/Commands/DeleteEntitiesWithComponent.cs index 9983ca36d9..578ef2e414 100644 --- a/Content.Server/Administration/Commands/DeleteEntitiesWithComponent.cs +++ b/Content.Server/Administration/Commands/DeleteEntitiesWithComponent.cs @@ -31,7 +31,7 @@ namespace Content.Server.Administration.Commands var entityManager = IoCManager.Resolve(); - var entitiesWithComponents = components.Select(c => entityManager.GetAllComponents(c).Select(x => x.Owner)); + var entitiesWithComponents = components.Select(c => entityManager.GetAllComponents(c).Select(x => x.Uid)); var entitiesWithAllComponents = entitiesWithComponents.Skip(1).Aggregate(new HashSet(entitiesWithComponents.First()), (h, e) => { h.IntersectWith(e); return h; }); var count = 0; diff --git a/Content.Server/Administration/Commands/FindEntitiesWithComponents.cs b/Content.Server/Administration/Commands/FindEntitiesWithComponents.cs index c3092a2d44..b583b56db6 100644 --- a/Content.Server/Administration/Commands/FindEntitiesWithComponents.cs +++ b/Content.Server/Administration/Commands/FindEntitiesWithComponents.cs @@ -43,7 +43,7 @@ namespace Content.Server.Administration.Commands var entityManager = IoCManager.Resolve(); var entityIds = new HashSet(); - var entitiesWithComponents = components.Select(c => entityManager.GetAllComponents(c).Select(x => x.Owner)).ToArray(); + var entitiesWithComponents = components.Select(c => entityManager.GetAllComponents(c).Select(x => x.Uid)).ToArray(); var entitiesWithAllComponents = entitiesWithComponents.Skip(1).Aggregate(new HashSet(entitiesWithComponents.First()), (h, e) => { h.IntersectWith(e); return h; }); foreach (var entity in entitiesWithAllComponents) diff --git a/Content.Server/Pinpointer/PinpointerSystem.cs b/Content.Server/Pinpointer/PinpointerSystem.cs index f201baaa0f..63b39b388c 100644 --- a/Content.Server/Pinpointer/PinpointerSystem.cs +++ b/Content.Server/Pinpointer/PinpointerSystem.cs @@ -13,9 +13,13 @@ public sealed class PinpointerSystem : SharedPinpointerSystem [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + private EntityQuery _xformQuery; + public override void Initialize() { base.Initialize(); + _xformQuery = GetEntityQuery(); + SubscribeLocalEvent(OnActivate); SubscribeLocalEvent(OnLocateTarget); } @@ -71,7 +75,7 @@ public sealed class PinpointerSystem : SharedPinpointerSystem { if (!EntityManager.ComponentFactory.TryGetRegistration(component.Component, out var reg)) { - Logger.Error($"Unable to find component registration for {component.Component} for pinpointer!"); + Log.Error($"Unable to find component registration for {component.Component} for pinpointer!"); DebugTools.Assert(false); return; } @@ -100,10 +104,7 @@ public sealed class PinpointerSystem : SharedPinpointerSystem /// private EntityUid? FindTargetFromComponent(EntityUid uid, Type whitelist, TransformComponent? transform = null) { - var xformQuery = GetEntityQuery(); - - if (transform == null) - xformQuery.TryGetComponent(uid, out transform); + _xformQuery.Resolve(uid, ref transform, false); if (transform == null) return null; @@ -111,15 +112,15 @@ public sealed class PinpointerSystem : SharedPinpointerSystem // sort all entities in distance increasing order var mapId = transform.MapID; var l = new SortedList(); - var worldPos = _transform.GetWorldPosition(transform, xformQuery); + var worldPos = _transform.GetWorldPosition(transform); - foreach (var comp in EntityManager.GetAllComponents(whitelist)) + foreach (var (otherUid, _) in EntityManager.GetAllComponents(whitelist)) { - if (!xformQuery.TryGetComponent(comp.Owner, out var compXform) || compXform.MapID != mapId) + if (!_xformQuery.TryGetComponent(otherUid, out var compXform) || compXform.MapID != mapId) continue; - var dist = (_transform.GetWorldPosition(compXform, xformQuery) - worldPos).LengthSquared(); - l.TryAdd(dist, comp.Owner); + var dist = (_transform.GetWorldPosition(compXform) - worldPos).LengthSquared(); + l.TryAdd(dist, otherUid); } // return uid with a smallest distance diff --git a/Content.Server/StationEvents/Events/StationEventSystem.cs b/Content.Server/StationEvents/Events/StationEventSystem.cs index e372c2eae8..93ad069665 100644 --- a/Content.Server/StationEvents/Events/StationEventSystem.cs +++ b/Content.Server/StationEvents/Events/StationEventSystem.cs @@ -138,7 +138,7 @@ public abstract class StationEventSystem : GameRuleSystem where T : Compon filter ??= _ => true; // augh. sorry sloth there's no better API and my goal today isn't adding 50 entitymanager methods :waa: - var stations = EntityManager.GetAllComponents(typeof(StationEventEligibleComponent)).Select(x => x.Owner).Where(filter).ToArray(); + var stations = EntityManager.GetAllComponents(typeof(StationEventEligibleComponent)).Select(x => x.Uid).Where(filter).ToArray(); if (stations.Length == 0) {