CVars for atmos (#2633)
* Monstermos is a word! * Atmos CVars * Cache CVars in AtmosphereSystem. Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
committed by
GitHub
parent
8177be3061
commit
6bb1e9fa5d
@@ -9,6 +9,7 @@ using Content.Server.GameObjects.Components.Atmos.Piping;
|
||||
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.GameObjects.EntitySystems.Atmos;
|
||||
using Content.Shared;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Maps;
|
||||
using Robust.Server.GameObjects.EntitySystems.TileLookup;
|
||||
@@ -16,10 +17,9 @@ using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.ComponentDependencies;
|
||||
using Robust.Shared.GameObjects.Components.Map;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.Configuration;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -49,16 +49,6 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
/// </summary>
|
||||
private const int LagCheckIterations = 30;
|
||||
|
||||
/// <summary>
|
||||
/// Max milliseconds allowed for atmos updates.
|
||||
/// </summary>
|
||||
private const float LagCheckMaxMilliseconds = 5f;
|
||||
|
||||
/// <summary>
|
||||
/// How much time before atmos updates are ran.
|
||||
/// </summary>
|
||||
private const float AtmosTime = 1/26f;
|
||||
|
||||
public override string Name => "GridAtmosphere";
|
||||
|
||||
private bool _paused = false;
|
||||
@@ -256,7 +246,12 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
tile.Air ??= new GasMixture(GetVolumeForCells(1), AtmosphereSystem){Temperature = Atmospherics.T20C};
|
||||
}
|
||||
|
||||
// By removing the active tile, we effectively remove its excited group, if any.
|
||||
RemoveActiveTile(tile);
|
||||
|
||||
// Then we activate the tile again.
|
||||
AddActiveTile(tile);
|
||||
|
||||
tile.BlockedAirflow = GetBlockedDirections(indices);
|
||||
|
||||
// TODO ATMOS: Query all the contents of this tile (like walls) and calculate the correct thermal conductivity
|
||||
@@ -478,20 +473,23 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
public virtual void Update(float frameTime)
|
||||
{
|
||||
_timer += frameTime;
|
||||
var atmosTime = 1f/AtmosphereSystem.AtmosTickRate;
|
||||
|
||||
if (_invalidatedCoords.Count != 0)
|
||||
Revalidate();
|
||||
|
||||
if (_timer < AtmosTime)
|
||||
if (_timer < atmosTime)
|
||||
return;
|
||||
|
||||
// We subtract it so it takes lost time into account.
|
||||
_timer -= AtmosTime;
|
||||
_timer -= atmosTime;
|
||||
|
||||
var maxProcessTime = AtmosphereSystem.AtmosMaxProcessTime;
|
||||
|
||||
switch (_state)
|
||||
{
|
||||
case ProcessState.TileEqualize:
|
||||
if (!ProcessTileEqualize(_paused))
|
||||
if (!ProcessTileEqualize(_paused, maxProcessTime))
|
||||
{
|
||||
_paused = true;
|
||||
return;
|
||||
@@ -501,7 +499,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
_state = ProcessState.ActiveTiles;
|
||||
return;
|
||||
case ProcessState.ActiveTiles:
|
||||
if (!ProcessActiveTiles(_paused))
|
||||
if (!ProcessActiveTiles(_paused, maxProcessTime))
|
||||
{
|
||||
_paused = true;
|
||||
return;
|
||||
@@ -511,7 +509,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
_state = ProcessState.ExcitedGroups;
|
||||
return;
|
||||
case ProcessState.ExcitedGroups:
|
||||
if (!ProcessExcitedGroups(_paused))
|
||||
if (!ProcessExcitedGroups(_paused, maxProcessTime))
|
||||
{
|
||||
_paused = true;
|
||||
return;
|
||||
@@ -521,7 +519,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
_state = ProcessState.HighPressureDelta;
|
||||
return;
|
||||
case ProcessState.HighPressureDelta:
|
||||
if (!ProcessHighPressureDelta(_paused))
|
||||
if (!ProcessHighPressureDelta(_paused, maxProcessTime))
|
||||
{
|
||||
_paused = true;
|
||||
return;
|
||||
@@ -531,7 +529,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
_state = ProcessState.Hotspots;
|
||||
break;
|
||||
case ProcessState.Hotspots:
|
||||
if (!ProcessHotspots(_paused))
|
||||
if (!ProcessHotspots(_paused, maxProcessTime))
|
||||
{
|
||||
_paused = true;
|
||||
return;
|
||||
@@ -541,7 +539,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
_state = ProcessState.Superconductivity;
|
||||
break;
|
||||
case ProcessState.Superconductivity:
|
||||
if (!ProcessSuperconductivity(_paused))
|
||||
if (!ProcessSuperconductivity(_paused, maxProcessTime))
|
||||
{
|
||||
_paused = true;
|
||||
return;
|
||||
@@ -551,7 +549,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
_state = ProcessState.PipeNet;
|
||||
break;
|
||||
case ProcessState.PipeNet:
|
||||
if (!ProcessPipeNets(_paused))
|
||||
if (!ProcessPipeNets(_paused, maxProcessTime))
|
||||
{
|
||||
_paused = true;
|
||||
return;
|
||||
@@ -561,21 +559,24 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
_state = ProcessState.PipeNetDevices;
|
||||
break;
|
||||
case ProcessState.PipeNetDevices:
|
||||
if (!ProcessPipeNetDevices(_paused))
|
||||
if (!ProcessPipeNetDevices(_paused, maxProcessTime))
|
||||
{
|
||||
_paused = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_paused = false;
|
||||
_state = ProcessState.TileEqualize;
|
||||
// Next state depends on whether monstermos equalization is enabled or not.
|
||||
// Note: We do this here instead of on the tile equalization step to prevent ending it early.
|
||||
// Therefore, a change to this CVar might only be applied after that step is over.
|
||||
_state = AtmosphereSystem.MonstermosEqualization ? ProcessState.TileEqualize : ProcessState.ActiveTiles;
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateCounter++;
|
||||
}
|
||||
|
||||
public virtual bool ProcessTileEqualize(bool resumed = false)
|
||||
public virtual bool ProcessTileEqualize(bool resumed = false, float lagCheck = 5f)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -591,7 +592,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
if (number++ < LagCheckIterations) continue;
|
||||
number = 0;
|
||||
// Process the rest next time.
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= LagCheckMaxMilliseconds)
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= lagCheck)
|
||||
{
|
||||
_tileEqualizeLastProcess = _stopwatch.Elapsed.TotalMilliseconds;
|
||||
return false;
|
||||
@@ -602,10 +603,12 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool ProcessActiveTiles(bool resumed = false)
|
||||
public virtual bool ProcessActiveTiles(bool resumed = false, float lagCheck = 5f)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
var spaceWind = AtmosphereSystem.SpaceWind;
|
||||
|
||||
if(!resumed)
|
||||
_currentRunTiles = new Queue<TileAtmosphere>(_activeTiles);
|
||||
|
||||
@@ -613,12 +616,12 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
while (_currentRunTiles.Count > 0)
|
||||
{
|
||||
var tile = _currentRunTiles.Dequeue();
|
||||
tile.ProcessCell(UpdateCounter);
|
||||
tile.ProcessCell(UpdateCounter, spaceWind);
|
||||
|
||||
if (number++ < LagCheckIterations) continue;
|
||||
number = 0;
|
||||
// Process the rest next time.
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= LagCheckMaxMilliseconds)
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= lagCheck)
|
||||
{
|
||||
_activeTilesLastProcess = _stopwatch.Elapsed.TotalMilliseconds;
|
||||
return false;
|
||||
@@ -629,10 +632,12 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool ProcessExcitedGroups(bool resumed = false)
|
||||
public virtual bool ProcessExcitedGroups(bool resumed = false, float lagCheck = 5f)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
var spaceIsAllConsuming = AtmosphereSystem.ExcitedGroupsSpaceIsAllConsuming;
|
||||
|
||||
if(!resumed)
|
||||
_currentRunExcitedGroups = new Queue<ExcitedGroup>(_excitedGroups);
|
||||
|
||||
@@ -644,7 +649,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
excitedGroup.DismantleCooldown++;
|
||||
|
||||
if(excitedGroup.BreakdownCooldown > Atmospherics.ExcitedGroupBreakdownCycles)
|
||||
excitedGroup.SelfBreakdown();
|
||||
excitedGroup.SelfBreakdown(spaceIsAllConsuming);
|
||||
|
||||
else if(excitedGroup.DismantleCooldown > Atmospherics.ExcitedGroupsDismantleCycles)
|
||||
excitedGroup.Dismantle();
|
||||
@@ -652,7 +657,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
if (number++ < LagCheckIterations) continue;
|
||||
number = 0;
|
||||
// Process the rest next time.
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= LagCheckMaxMilliseconds)
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= lagCheck)
|
||||
{
|
||||
_excitedGroupLastProcess = _stopwatch.Elapsed.TotalMilliseconds;
|
||||
return false;
|
||||
@@ -663,7 +668,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool ProcessHighPressureDelta(bool resumed = false)
|
||||
public virtual bool ProcessHighPressureDelta(bool resumed = false, float lagCheck = 5f)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -682,7 +687,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
if (number++ < LagCheckIterations) continue;
|
||||
number = 0;
|
||||
// Process the rest next time.
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= LagCheckMaxMilliseconds)
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= lagCheck)
|
||||
{
|
||||
_highPressureDeltaLastProcess = _stopwatch.Elapsed.TotalMilliseconds;
|
||||
return false;
|
||||
@@ -693,7 +698,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool ProcessHotspots(bool resumed = false)
|
||||
protected virtual bool ProcessHotspots(bool resumed = false, float lagCheck = 5f)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -709,7 +714,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
if (number++ < LagCheckIterations) continue;
|
||||
number = 0;
|
||||
// Process the rest next time.
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= LagCheckMaxMilliseconds)
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= lagCheck)
|
||||
{
|
||||
_hotspotsLastProcess = _stopwatch.Elapsed.TotalMilliseconds;
|
||||
return false;
|
||||
@@ -720,7 +725,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool ProcessSuperconductivity(bool resumed = false)
|
||||
protected virtual bool ProcessSuperconductivity(bool resumed = false, float lagCheck = 5f)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -736,7 +741,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
if (number++ < LagCheckIterations) continue;
|
||||
number = 0;
|
||||
// Process the rest next time.
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= LagCheckMaxMilliseconds)
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= lagCheck)
|
||||
{
|
||||
_superconductivityLastProcess = _stopwatch.Elapsed.TotalMilliseconds;
|
||||
return false;
|
||||
@@ -747,7 +752,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool ProcessPipeNets(bool resumed = false)
|
||||
protected virtual bool ProcessPipeNets(bool resumed = false, float lagCheck = 5f)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -763,7 +768,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
if (number++ < LagCheckIterations) continue;
|
||||
number = 0;
|
||||
// Process the rest next time.
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= LagCheckMaxMilliseconds)
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= lagCheck)
|
||||
{
|
||||
_pipeNetLastProcess = _stopwatch.Elapsed.TotalMilliseconds;
|
||||
return false;
|
||||
@@ -774,7 +779,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool ProcessPipeNetDevices(bool resumed = false)
|
||||
protected virtual bool ProcessPipeNetDevices(bool resumed = false, float lagCheck = 5f)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
|
||||
@@ -790,7 +795,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
if (number++ < LagCheckIterations) continue;
|
||||
number = 0;
|
||||
// Process the rest next time.
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= LagCheckMaxMilliseconds)
|
||||
if (_stopwatch.Elapsed.TotalMilliseconds >= lagCheck)
|
||||
{
|
||||
_pipeNetDevicesLastProcess = _stopwatch.Elapsed.TotalMilliseconds;
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user