diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs b/Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs index 8d754d1b3a..4b64195e93 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs @@ -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(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; } diff --git a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs index 80e7cf71e0..f1a7f62051 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs @@ -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; } diff --git a/Content.Server/Cargo/Systems/PricingSystem.cs b/Content.Server/Cargo/Systems/PricingSystem.cs index 509e99a28a..5bbe1e5a6d 100644 --- a/Content.Server/Cargo/Systems/PricingSystem.cs +++ b/Content.Server/Cargo/Systems/PricingSystem.cs @@ -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)) { diff --git a/Content.Server/Construction/Commands/FixRotationsCommand.cs b/Content.Server/Construction/Commands/FixRotationsCommand.cs index bdbfaf170d..9c99035573 100644 --- a/Content.Server/Construction/Commands/FixRotationsCommand.cs +++ b/Content.Server/Construction/Commands/FixRotationsCommand.cs @@ -64,7 +64,9 @@ namespace Content.Server.Construction.Commands var changed = 0; var tagSystem = _entManager.EntitySysManager.GetEntitySystem(); - 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)) { diff --git a/Content.Server/Construction/Commands/TileWallsCommand.cs b/Content.Server/Construction/Commands/TileWallsCommand.cs index 731d4da7f8..14d16dfb98 100644 --- a/Content.Server/Construction/Commands/TileWallsCommand.cs +++ b/Content.Server/Construction/Commands/TileWallsCommand.cs @@ -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(gridId.Value).ChildEntities) + var enumerator = _entManager.GetComponent(gridId.Value).ChildEnumerator; + while (enumerator.MoveNext(out var child)) { if (!_entManager.EntityExists(child)) { diff --git a/Content.Server/Maps/ResaveCommand.cs b/Content.Server/Maps/ResaveCommand.cs index 1b2e48294f..a966070d3e 100644 --- a/Content.Server/Maps/ResaveCommand.cs +++ b/Content.Server/Maps/ResaveCommand.cs @@ -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); diff --git a/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs b/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs index 4629a1bf55..bb662a15ea 100644 --- a/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs +++ b/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs @@ -137,7 +137,7 @@ public sealed class SuitSensorSystem : EntitySystem sensor.StationId = stationUid; } - RecursiveSensor(child.Value, stationUid, sensorQuery, xformQuery); + RecursiveSensor(child, stationUid, sensorQuery, xformQuery); } } diff --git a/Content.Server/NPC/Systems/NPCUtilitySystem.cs b/Content.Server/NPC/Systems/NPCUtilitySystem.cs index 375d2b3c19..641b8c20e1 100644 --- a/Content.Server/NPC/Systems/NPCUtilitySystem.cs +++ b/Content.Server/NPC/Systems/NPCUtilitySystem.cs @@ -454,7 +454,7 @@ public sealed class NPCUtilitySystem : EntitySystem while (enumerator.MoveNext(out var child)) { - RecursiveAdd(child.Value, entities); + RecursiveAdd(child, entities); } } diff --git a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs index 79d26ea14f..7ff0e0b297 100644 --- a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs +++ b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs @@ -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); } } diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index 15f1da5c28..763e89e4f8 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -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); } } diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs index 854ce538dc..f817878c2e 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs @@ -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; diff --git a/Content.Server/Temperature/Systems/TemperatureSystem.cs b/Content.Server/Temperature/Systems/TemperatureSystem.cs index 2ab9ce74c6..9f7057d9b6 100644 --- a/Content.Server/Temperature/Systems/TemperatureSystem.cs +++ b/Content.Server/Temperature/Systems/TemperatureSystem.cs @@ -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); }