ECS Atmos Part 5: Moves all logic from GridAtmosphereComponent to AtmosphereSystem. (#4331)
This commit is contained in:
committed by
GitHub
parent
354ef6daf3
commit
4112847142
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
@@ -20,6 +21,11 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
/// </summary>
|
||||
private const int LagCheckIterations = 30;
|
||||
|
||||
/// <summary>
|
||||
/// Check current execution time every n instances processed.
|
||||
/// </summary>
|
||||
private const int InvalidCoordinatesLagCheckIterations = 50;
|
||||
|
||||
private int _currentRunAtmosphereIndex = 0;
|
||||
private bool _simulationPaused = false;
|
||||
|
||||
@@ -30,10 +36,13 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
if(!atmosphere.ProcessingPaused)
|
||||
atmosphere.CurrentRunTiles = new Queue<TileAtmosphere>(atmosphere.ActiveTiles);
|
||||
|
||||
if (!TryGetMapGrid(atmosphere, out var mapGrid))
|
||||
throw new Exception("Tried to process a grid atmosphere on an entity that isn't a grid!");
|
||||
|
||||
var number = 0;
|
||||
while (atmosphere.CurrentRunTiles.TryDequeue(out var tile))
|
||||
{
|
||||
EqualizePressureInZone(atmosphere, tile, atmosphere.UpdateCounter);
|
||||
EqualizePressureInZone(mapGrid, atmosphere, tile, atmosphere.UpdateCounter);
|
||||
|
||||
if (number++ < LagCheckIterations) continue;
|
||||
number = 0;
|
||||
@@ -69,22 +78,22 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ProcessExcitedGroups(GridAtmosphereComponent atmosphere)
|
||||
private bool ProcessExcitedGroups(GridAtmosphereComponent gridAtmosphere)
|
||||
{
|
||||
if(!atmosphere.ProcessingPaused)
|
||||
atmosphere.CurrentRunExcitedGroups = new Queue<ExcitedGroup>(atmosphere.ExcitedGroups);
|
||||
if(!gridAtmosphere.ProcessingPaused)
|
||||
gridAtmosphere.CurrentRunExcitedGroups = new Queue<ExcitedGroup>(gridAtmosphere.ExcitedGroups);
|
||||
|
||||
var number = 0;
|
||||
while (atmosphere.CurrentRunExcitedGroups.TryDequeue(out var excitedGroup))
|
||||
while (gridAtmosphere.CurrentRunExcitedGroups.TryDequeue(out var excitedGroup))
|
||||
{
|
||||
excitedGroup.BreakdownCooldown++;
|
||||
excitedGroup.DismantleCooldown++;
|
||||
|
||||
if(excitedGroup.BreakdownCooldown > Atmospherics.ExcitedGroupBreakdownCycles)
|
||||
excitedGroup.SelfBreakdown(this, ExcitedGroupsSpaceIsAllConsuming);
|
||||
ExcitedGroupSelfBreakdown(gridAtmosphere, excitedGroup, ExcitedGroupsSpaceIsAllConsuming);
|
||||
|
||||
else if(excitedGroup.DismantleCooldown > Atmospherics.ExcitedGroupsDismantleCycles)
|
||||
excitedGroup.Dismantle();
|
||||
ExcitedGroupDismantle(gridAtmosphere, excitedGroup);
|
||||
|
||||
if (number++ < LagCheckIterations) continue;
|
||||
number = 0;
|
||||
@@ -195,7 +204,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
atmosphere.CurrentRunAtmosDevices = new Queue<AtmosDeviceComponent>(atmosphere.AtmosDevices);
|
||||
|
||||
var time = _gameTiming.CurTime;
|
||||
var updateEvent = new AtmosDeviceUpdateEvent(atmosphere);
|
||||
var updateEvent = new AtmosDeviceUpdateEvent();
|
||||
var number = 0;
|
||||
while (atmosphere.CurrentRunAtmosDevices.TryDequeue(out var device))
|
||||
{
|
||||
@@ -237,8 +246,14 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
atmosphere.Timer += frameTime;
|
||||
|
||||
if (atmosphere.InvalidatedCoords.Count != 0)
|
||||
atmosphere.Revalidate();
|
||||
if ((atmosphere.InvalidatedCoords.Count != 0 || atmosphere.RevalidatePaused) && TryGetMapGrid(atmosphere, out var mapGrid))
|
||||
if (!GridRevalidate(mapGrid, atmosphere))
|
||||
{
|
||||
atmosphere.RevalidatePaused = true;
|
||||
return;
|
||||
}
|
||||
|
||||
atmosphere.RevalidatePaused = false;
|
||||
|
||||
if (atmosphere.Timer < AtmosTime)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user