Atmos device performance improvements (#26493)
* Atmos device performance improvements * AtmosDirection perf improvements * Fix errors * Add GasTileOverlayComponent arguments * Make excite no longer invalidate a tile
This commit is contained in:
@@ -86,7 +86,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
DebugTools.Assert(atmosphere.Tiles.GetValueOrDefault(tile.GridIndices) == tile);
|
||||
UpdateAdjacentTiles(ent, tile, activate: true);
|
||||
UpdateTileAir(ent, tile, volume);
|
||||
InvalidateVisuals(uid, tile.GridIndices, visuals);
|
||||
InvalidateVisuals(ent, tile);
|
||||
|
||||
if (number++ < InvalidCoordinatesLagCheckIterations)
|
||||
continue;
|
||||
@@ -313,15 +313,17 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ProcessActiveTiles(GridAtmosphereComponent atmosphere, GasTileOverlayComponent visuals)
|
||||
private bool ProcessActiveTiles(
|
||||
Entity<GridAtmosphereComponent, GasTileOverlayComponent, MapGridComponent, TransformComponent> ent)
|
||||
{
|
||||
var atmosphere = ent.Comp1;
|
||||
if(!atmosphere.ProcessingPaused)
|
||||
QueueRunTiles(atmosphere.CurrentRunTiles, atmosphere.ActiveTiles);
|
||||
|
||||
var number = 0;
|
||||
while (atmosphere.CurrentRunTiles.TryDequeue(out var tile))
|
||||
{
|
||||
ProcessCell(atmosphere, tile, atmosphere.UpdateCounter, visuals);
|
||||
ProcessCell(ent, tile, atmosphere.UpdateCounter);
|
||||
|
||||
if (number++ < LagCheckIterations)
|
||||
continue;
|
||||
@@ -337,8 +339,10 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ProcessExcitedGroups(GridAtmosphereComponent gridAtmosphere)
|
||||
private bool ProcessExcitedGroups(
|
||||
Entity<GridAtmosphereComponent, GasTileOverlayComponent, MapGridComponent, TransformComponent> ent)
|
||||
{
|
||||
var gridAtmosphere = ent.Comp1;
|
||||
if (!gridAtmosphere.ProcessingPaused)
|
||||
{
|
||||
gridAtmosphere.CurrentRunExcitedGroups.Clear();
|
||||
@@ -356,7 +360,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
excitedGroup.DismantleCooldown++;
|
||||
|
||||
if (excitedGroup.BreakdownCooldown > Atmospherics.ExcitedGroupBreakdownCycles)
|
||||
ExcitedGroupSelfBreakdown(gridAtmosphere, excitedGroup);
|
||||
ExcitedGroupSelfBreakdown(ent, excitedGroup);
|
||||
else if (excitedGroup.DismantleCooldown > Atmospherics.ExcitedGroupsDismantleCycles)
|
||||
DeactivateGroupTiles(gridAtmosphere, excitedGroup);
|
||||
// TODO ATMOS. What is the point of this? why is this only de-exciting the group? Shouldn't it also dismantle it?
|
||||
@@ -411,15 +415,17 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ProcessHotspots(GridAtmosphereComponent atmosphere)
|
||||
private bool ProcessHotspots(
|
||||
Entity<GridAtmosphereComponent, GasTileOverlayComponent, MapGridComponent, TransformComponent> ent)
|
||||
{
|
||||
var atmosphere = ent.Comp1;
|
||||
if(!atmosphere.ProcessingPaused)
|
||||
QueueRunTiles(atmosphere.CurrentRunTiles, atmosphere.HotspotTiles);
|
||||
|
||||
var number = 0;
|
||||
while (atmosphere.CurrentRunTiles.TryDequeue(out var hotspot))
|
||||
{
|
||||
ProcessHotspot(atmosphere, hotspot);
|
||||
ProcessHotspot(ent, hotspot);
|
||||
|
||||
if (number++ < LagCheckIterations)
|
||||
continue;
|
||||
@@ -507,8 +513,11 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
return num * AtmosTime;
|
||||
}
|
||||
|
||||
private bool ProcessAtmosDevices(GridAtmosphereComponent atmosphere)
|
||||
private bool ProcessAtmosDevices(
|
||||
Entity<GridAtmosphereComponent, GasTileOverlayComponent, MapGridComponent, TransformComponent> ent,
|
||||
Entity<MapAtmosphereComponent?> map)
|
||||
{
|
||||
var atmosphere = ent.Comp1;
|
||||
if (!atmosphere.ProcessingPaused)
|
||||
{
|
||||
atmosphere.CurrentRunAtmosDevices.Clear();
|
||||
@@ -521,7 +530,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
var time = _gameTiming.CurTime;
|
||||
var number = 0;
|
||||
var ev = new AtmosDeviceUpdateEvent(RealAtmosTime());
|
||||
var ev = new AtmosDeviceUpdateEvent(RealAtmosTime(), (ent, ent.Comp1, ent.Comp2), map);
|
||||
while (atmosphere.CurrentRunAtmosDevices.TryDequeue(out var device))
|
||||
{
|
||||
RaiseLocalEvent(device, ref ev);
|
||||
@@ -565,12 +574,11 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
var ent = _currentRunAtmosphere[_currentRunAtmosphereIndex];
|
||||
var (owner, atmosphere, visuals, grid, xform) = ent;
|
||||
|
||||
if (!TryComp(owner, out TransformComponent? x)
|
||||
|| x.MapUid == null
|
||||
|| TerminatingOrDeleted(x.MapUid.Value)
|
||||
|| x.MapID == MapId.Nullspace)
|
||||
if (xform.MapUid == null
|
||||
|| TerminatingOrDeleted(xform.MapUid.Value)
|
||||
|| xform.MapID == MapId.Nullspace)
|
||||
{
|
||||
Log.Error($"Attempted to process atmos without a map? Entity: {ToPrettyString(owner)}. Map: {ToPrettyString(x?.MapUid)}. MapId: {x?.MapID}");
|
||||
Log.Error($"Attempted to process atmos without a map? Entity: {ToPrettyString(owner)}. Map: {ToPrettyString(xform?.MapUid)}. MapId: {xform?.MapID}");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -585,6 +593,8 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
// We subtract it so it takes lost time into account.
|
||||
atmosphere.Timer -= AtmosTime;
|
||||
|
||||
var map = new Entity<MapAtmosphereComponent?>(xform.MapUid.Value, _mapAtmosQuery.CompOrNull(xform.MapUid.Value));
|
||||
|
||||
switch (atmosphere.State)
|
||||
{
|
||||
case AtmosphereProcessingState.Revalidate:
|
||||
@@ -614,7 +624,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
atmosphere.State = AtmosphereProcessingState.ActiveTiles;
|
||||
continue;
|
||||
case AtmosphereProcessingState.ActiveTiles:
|
||||
if (!ProcessActiveTiles(ent, ent))
|
||||
if (!ProcessActiveTiles(ent))
|
||||
{
|
||||
atmosphere.ProcessingPaused = true;
|
||||
return;
|
||||
@@ -625,7 +635,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
atmosphere.State = ExcitedGroups ? AtmosphereProcessingState.ExcitedGroups : AtmosphereProcessingState.HighPressureDelta;
|
||||
continue;
|
||||
case AtmosphereProcessingState.ExcitedGroups:
|
||||
if (!ProcessExcitedGroups(atmosphere))
|
||||
if (!ProcessExcitedGroups(ent))
|
||||
{
|
||||
atmosphere.ProcessingPaused = true;
|
||||
return;
|
||||
@@ -645,7 +655,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
atmosphere.State = AtmosphereProcessingState.Hotspots;
|
||||
continue;
|
||||
case AtmosphereProcessingState.Hotspots:
|
||||
if (!ProcessHotspots(atmosphere))
|
||||
if (!ProcessHotspots(ent))
|
||||
{
|
||||
atmosphere.ProcessingPaused = true;
|
||||
return;
|
||||
@@ -680,7 +690,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
atmosphere.State = AtmosphereProcessingState.AtmosDevices;
|
||||
continue;
|
||||
case AtmosphereProcessingState.AtmosDevices:
|
||||
if (!ProcessAtmosDevices(atmosphere))
|
||||
if (!ProcessAtmosDevices(ent, map))
|
||||
{
|
||||
atmosphere.ProcessingPaused = true;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user