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

@@ -17,6 +17,7 @@ public sealed class RulesSystem : EntitySystem
public bool IsTrue(EntityUid uid, RulesPrototype rules)
{
var inRange = new HashSet<Entity<IComponent>>();
foreach (var rule in rules.Rules)
{
switch (rule)
@@ -72,12 +73,13 @@ public sealed class RulesSystem : EntitySystem
var count = 0;
// TODO: Update this when we get the callback version
foreach (var comp in _lookup.GetComponentsInRange<AccessReaderComponent>(xform.MapID,
worldPos, access.Range))
var entities = new HashSet<Entity<AccessReaderComponent>>();
_lookup.GetEntitiesInRange(xform.MapID, worldPos, access.Range, entities);
foreach (var comp in entities)
{
if (!_reader.AreAccessTagsAllowed(access.Access, comp) ||
access.Anchored &&
(!xformQuery.TryGetComponent(comp.Owner, out var compXform) ||
(!xformQuery.TryGetComponent(comp, out var compXform) ||
!compXform.Anchored))
{
continue;
@@ -113,12 +115,12 @@ public sealed class RulesSystem : EntitySystem
foreach (var compType in nearbyComps.Components.Values)
{
// TODO: Update this when we get the callback version
foreach (var comp in _lookup.GetComponentsInRange(compType.Component.GetType(), xform.MapID,
worldPos, nearbyComps.Range))
inRange.Clear();
_lookup.GetEntitiesInRange(compType.Component.GetType(), xform.MapID, worldPos, nearbyComps.Range, inRange);
foreach (var comp in inRange)
{
if (nearbyComps.Anchored &&
(!xformQuery.TryGetComponent(comp.Owner, out var compXform) ||
(!xformQuery.TryGetComponent(comp, out var compXform) ||
!compXform.Anchored))
{
continue;