var (owner, atmosphere) = ent;
if (!atmosphere.ProcessingPaused)
{
- atmosphere.CurrentRunInvalidatedCoordinates = new Queue<Vector2i>(atmosphere.InvalidatedCoords);
+ atmosphere.CurrentRunInvalidatedCoordinates.Clear();
+ atmosphere.CurrentRunInvalidatedCoordinates.EnsureCapacity(atmosphere.InvalidatedCoords.Count);
+ foreach (var tile in atmosphere.InvalidatedCoords)
+ {
+ atmosphere.CurrentRunInvalidatedCoordinates.Enqueue(tile);
+ }
atmosphere.InvalidatedCoords.Clear();
}
return true;
}
+ private void QueueRunTiles(
+ Queue<TileAtmosphere> queue,
+ HashSet<TileAtmosphere> tiles)
+ {
+
+ queue.Clear();
+ queue.EnsureCapacity(tiles.Count);
+ foreach (var tile in tiles)
+ {
+ queue.Enqueue(tile);
+ }
+ }
+
private bool ProcessTileEqualize(Entity<GridAtmosphereComponent> ent, GasTileOverlayComponent? visuals)
{
var (uid, atmosphere) = ent;
if (!atmosphere.ProcessingPaused)
- atmosphere.CurrentRunTiles = new Queue<TileAtmosphere>(atmosphere.ActiveTiles);
+ QueueRunTiles(atmosphere.CurrentRunTiles, atmosphere.ActiveTiles);
if (!TryComp(uid, out MapGridComponent? mapGridComp))
throw new Exception("Tried to process a grid atmosphere on an entity that isn't a grid!");
private bool ProcessActiveTiles(GridAtmosphereComponent atmosphere, GasTileOverlayComponent? visuals)
{
if(!atmosphere.ProcessingPaused)
- atmosphere.CurrentRunTiles = new Queue<TileAtmosphere>(atmosphere.ActiveTiles);
+ QueueRunTiles(atmosphere.CurrentRunTiles, atmosphere.ActiveTiles);
var number = 0;
while (atmosphere.CurrentRunTiles.TryDequeue(out var tile))
private bool ProcessExcitedGroups(GridAtmosphereComponent gridAtmosphere)
{
- if(!gridAtmosphere.ProcessingPaused)
- gridAtmosphere.CurrentRunExcitedGroups = new Queue<ExcitedGroup>(gridAtmosphere.ExcitedGroups);
+ if (!gridAtmosphere.ProcessingPaused)
+ {
+ gridAtmosphere.CurrentRunExcitedGroups.Clear();
+ gridAtmosphere.CurrentRunExcitedGroups.EnsureCapacity(gridAtmosphere.ExcitedGroups.Count);
+ foreach (var group in gridAtmosphere.ExcitedGroups)
+ {
+ gridAtmosphere.CurrentRunExcitedGroups.Enqueue(group);
+ }
+ }
var number = 0;
while (gridAtmosphere.CurrentRunExcitedGroups.TryDequeue(out var excitedGroup))
{
var atmosphere = ent.Comp;
if (!atmosphere.ProcessingPaused)
- atmosphere.CurrentRunTiles = new Queue<TileAtmosphere>(atmosphere.HighPressureDelta);
+ QueueRunTiles(atmosphere.CurrentRunTiles, atmosphere.HighPressureDelta);
// Note: This is still processed even if space wind is turned off since this handles playing the sounds.
private bool ProcessHotspots(GridAtmosphereComponent atmosphere)
{
if(!atmosphere.ProcessingPaused)
- atmosphere.CurrentRunTiles = new Queue<TileAtmosphere>(atmosphere.HotspotTiles);
+ QueueRunTiles(atmosphere.CurrentRunTiles, atmosphere.HotspotTiles);
var number = 0;
while (atmosphere.CurrentRunTiles.TryDequeue(out var hotspot))
private bool ProcessSuperconductivity(GridAtmosphereComponent atmosphere)
{
if(!atmosphere.ProcessingPaused)
- atmosphere.CurrentRunTiles = new Queue<TileAtmosphere>(atmosphere.SuperconductivityTiles);
+ QueueRunTiles(atmosphere.CurrentRunTiles, atmosphere.SuperconductivityTiles);
var number = 0;
while (atmosphere.CurrentRunTiles.TryDequeue(out var superconductivity))
private bool ProcessPipeNets(GridAtmosphereComponent atmosphere)
{
- if(!atmosphere.ProcessingPaused)
- atmosphere.CurrentRunPipeNet = new Queue<IPipeNet>(atmosphere.PipeNets);
+ if (!atmosphere.ProcessingPaused)
+ {
+ atmosphere.CurrentRunPipeNet.Clear();
+ atmosphere.CurrentRunPipeNet.EnsureCapacity(atmosphere.PipeNets.Count);
+ foreach (var net in atmosphere.PipeNets)
+ {
+ atmosphere.CurrentRunPipeNet.Enqueue(net);
+ }
+ }
var number = 0;
while (atmosphere.CurrentRunPipeNet.TryDequeue(out var pipenet))
private bool ProcessAtmosDevices(GridAtmosphereComponent atmosphere)
{
if (!atmosphere.ProcessingPaused)
- atmosphere.CurrentRunAtmosDevices = new Queue<Entity<AtmosDeviceComponent>>(atmosphere.AtmosDevices);
+ {
+ atmosphere.CurrentRunAtmosDevices.Clear();
+ atmosphere.CurrentRunAtmosDevices.EnsureCapacity(atmosphere.AtmosDevices.Count);
+ foreach (var device in atmosphere.AtmosDevices)
+ {
+ atmosphere.CurrentRunAtmosDevices.Enqueue(device);
+ }
+ }
var time = _gameTiming.CurTime;
var number = 0;