Add atmos time compression (#21954)
Add atmos.speedup which is effectively a atmos-only time compression CVar. This adjusts heat capacities and transfer rates to effectively globally speed up the time constants of atmos. This allows faster response to heating/cooling changes and faster cleanups (by buffing scrubbers, pumps, and everything else) that is tunable through one global time compression CVar. It also achieves this without any thermodynamic unsoundness.
This commit is contained in:
@@ -56,7 +56,7 @@ public sealed class AirFilterSystem : EntitySystem
|
||||
if (!GetAir(uid, out var air))
|
||||
return;
|
||||
|
||||
var ratio = MathF.Min(1f, args.dt * filter.TransferRate);
|
||||
var ratio = MathF.Min(1f, args.dt * filter.TransferRate * _atmosphere.PumpSpeedup());
|
||||
var removed = air.RemoveRatio(ratio);
|
||||
// nothing left to remove from the volume
|
||||
if (MathHelper.CloseToPercent(removed.TotalMoles, 0f))
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
public bool ExcitedGroupsSpaceIsAllConsuming { get; private set; }
|
||||
public float AtmosMaxProcessTime { get; private set; }
|
||||
public float AtmosTickRate { get; private set; }
|
||||
public float Speedup { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Time between each atmos sub-update. If you are writing an atmos device, use AtmosDeviceUpdateEvent.dt
|
||||
@@ -49,6 +50,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
_cfg.OnValueChanged(CCVars.Superconduction, value => Superconduction = value, true);
|
||||
_cfg.OnValueChanged(CCVars.AtmosMaxProcessTime, value => AtmosMaxProcessTime = value, true);
|
||||
_cfg.OnValueChanged(CCVars.AtmosTickRate, value => AtmosTickRate = value, true);
|
||||
_cfg.OnValueChanged(CCVars.AtmosSpeedup, value => Speedup = value, true);
|
||||
_cfg.OnValueChanged(CCVars.ExcitedGroups, value => ExcitedGroups = value, true);
|
||||
_cfg.OnValueChanged(CCVars.ExcitedGroupsSpaceIsAllConsuming, value => ExcitedGroupsSpaceIsAllConsuming = value, true);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,17 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
Span<float> tmp = stackalloc float[moles.Length];
|
||||
NumericsHelpers.Multiply(moles, GasSpecificHeats, tmp);
|
||||
return MathF.Max(NumericsHelpers.HorizontalAdd(tmp), Atmospherics.MinimumHeatCapacity);
|
||||
// Adjust heat capacity by speedup, because this is primarily what
|
||||
// determines how quickly gases heat up/cool.
|
||||
return MathF.Max(NumericsHelpers.HorizontalAdd(tmp), Atmospherics.MinimumHeatCapacity) / Speedup;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return speedup factor for pumped or flow-based devices that depend on MaxTransferRate.
|
||||
/// </summary>
|
||||
public float PumpSpeedup()
|
||||
{
|
||||
return MathF.Sqrt(Speedup);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user