Remove uses of TransformComponent.ChildEntities (#22442)

* Make output of ChildEnumerator non-nullable

* Remove uses of ChildEntities

* poke tests

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Leon Friedrich
2023-12-16 11:09:50 -05:00
committed by GitHub
parent aa08cc3e53
commit 9a3342d972
12 changed files with 26 additions and 21 deletions

View File

@@ -772,18 +772,20 @@ public sealed partial class AdminVerbSystem
{
foreach (var grid in station.Grids)
{
foreach (var ent in Transform(grid).ChildEntities)
var enumerator = Transform(grid).ChildEnumerator;
while (enumerator.MoveNext(out var ent))
{
yield return ent;
}
}
}
else if (HasComp<MapComponent>(target))
{
foreach (var possibleGrid in Transform(target).ChildEntities)
var enumerator = Transform(target).ChildEnumerator;
while (enumerator.MoveNext(out var possibleGrid))
{
foreach (var ent in Transform(possibleGrid).ChildEntities)
var enumerator2 = Transform(possibleGrid).ChildEnumerator;
while (enumerator2.MoveNext(out var ent))
{
yield return ent;
}
@@ -791,7 +793,8 @@ public sealed partial class AdminVerbSystem
}
else
{
foreach (var ent in Transform(target).ChildEntities)
var enumerator = Transform(target).ChildEnumerator;
while (enumerator.MoveNext(out var ent))
{
yield return ent;
}

View File

@@ -292,7 +292,7 @@ public sealed partial class CargoSystem
var children = xform.ChildEnumerator;
while (children.MoveNext(out var child))
{
if (!CanSell(child.Value, _xformQuery.GetComponent(child.Value)))
if (!CanSell(child, _xformQuery.GetComponent(child)))
return false;
}

View File

@@ -342,8 +342,8 @@ public sealed class PricingSystem : EntitySystem
{
var xform = Transform(grid);
var price = 0.0;
foreach (var child in xform.ChildEntities)
var enumerator = xform.ChildEnumerator;
while (enumerator.MoveNext(out var child))
{
if (predicate is null || predicate(child))
{

View File

@@ -64,7 +64,9 @@ namespace Content.Server.Construction.Commands
var changed = 0;
var tagSystem = _entManager.EntitySysManager.GetEntitySystem<TagSystem>();
foreach (var child in xformQuery.GetComponent(gridId.Value).ChildEntities)
var enumerator = xformQuery.GetComponent(gridId.Value).ChildEnumerator;
while (enumerator.MoveNext(out var child))
{
if (!_entManager.EntityExists(child))
{

View File

@@ -72,7 +72,8 @@ namespace Content.Server.Construction.Commands
var underplating = _tileDefManager[TilePrototypeId];
var underplatingTile = new Tile(underplating.TileId);
var changed = 0;
foreach (var child in _entManager.GetComponent<TransformComponent>(gridId.Value).ChildEntities)
var enumerator = _entManager.GetComponent<TransformComponent>(gridId.Value).ChildEnumerator;
while (enumerator.MoveNext(out var child))
{
if (!_entManager.EntityExists(child))
{

View File

@@ -46,10 +46,9 @@ public sealed class ResaveCommand : LocalizedCommands
{
loader.SaveMap(mapId, fn.ToString());
}
else
else if (mapXform.ChildEnumerator.MoveNext(out var child))
{
loader.Save(mapXform.ChildEntities.First(), fn.ToString());
loader.Save(child, fn.ToString());
}
_mapManager.DeleteMap(mapId);

View File

@@ -137,7 +137,7 @@ public sealed class SuitSensorSystem : EntitySystem
sensor.StationId = stationUid;
}
RecursiveSensor(child.Value, stationUid, sensorQuery, xformQuery);
RecursiveSensor(child, stationUid, sensorQuery, xformQuery);
}
}

View File

@@ -454,7 +454,7 @@ public sealed class NPCUtilitySystem : EntitySystem
while (enumerator.MoveNext(out var child))
{
RecursiveAdd(child.Value, entities);
RecursiveAdd(child, entities);
}
}

View File

@@ -236,10 +236,9 @@ public sealed class ArrivalsSystem : EntitySystem
}
var children = xform.ChildEnumerator;
while (children.MoveNext(out var child))
{
DumpChildren(child.Value, ref args, pendingEntQuery, arrivalsBlacklistQuery, mobQuery, xformQuery);
DumpChildren(child, ref args, pendingEntQuery, arrivalsBlacklistQuery, mobQuery, xformQuery);
}
}

View File

@@ -501,10 +501,10 @@ public sealed partial class ShuttleSystem
var childEnumerator = xform.ChildEnumerator;
while (childEnumerator.MoveNext(out var child))
{
if (!_buckleQuery.TryGetComponent(child.Value, out var buckle) || buckle.Buckled)
if (!_buckleQuery.TryGetComponent(child, out var buckle) || buckle.Buckled)
continue;
toKnock.Add(child.Value);
toKnock.Add(child);
}
}

View File

@@ -148,7 +148,7 @@ public sealed partial class ShuttleSystem
if (!dockQuery.TryGetComponent(child, out var dock))
continue;
return (child.Value, dock);
return (child, dock);
}
return null;

View File

@@ -341,7 +341,8 @@ public sealed class TemperatureSystem : EntitySystem
{
RecalculateAndApplyParentThresholds(root, temperatureQuery, transformQuery, tempThresholdsQuery);
foreach (var child in Transform(root).ChildEntities)
var enumerator = Transform(root).ChildEnumerator;
while (enumerator.MoveNext(out var child))
{
RecursiveThresholdUpdate(child, temperatureQuery, transformQuery, tempThresholdsQuery);
}