Atmos scaling cvar changes (#22501)

This commit is contained in:
Leon Friedrich
2023-12-15 17:02:21 -05:00
committed by GitHub
parent a88730fcfa
commit 477327f952
16 changed files with 76 additions and 40 deletions

View File

@@ -43,11 +43,22 @@ namespace Content.Server.Atmos.EntitySystems
/// <summary>
/// Calculates the heat capacity for a gas mixture.
/// </summary>
public float GetHeatCapacity(GasMixture mixture)
/// <param name="mixture">The mixture whose heat capacity should be calculated</param>
/// <param name="applyScaling"> Whether the internal heat capacity scaling should be applied. This should not be
/// used outside of atmospheric related heat transfer.</param>
/// <returns></returns>
public float GetHeatCapacity(GasMixture mixture, bool applyScaling)
{
return GetHeatCapacityCalculation(mixture.Moles, mixture.Immutable);
var scale = GetHeatCapacityCalculation(mixture.Moles, mixture.Immutable);
// By default GetHeatCapacityCalculation() has the heat-scale divisor pre-applied.
// So if we want the un-scaled heat capacity, we have to multiply by the scale.
return applyScaling ? scale : scale * HeatScale;
}
private float GetHeatCapacity(GasMixture mixture)
=> GetHeatCapacityCalculation(mixture.Moles, mixture.Immutable);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private float GetHeatCapacityCalculation(float[] moles, bool space)
{
@@ -320,7 +331,9 @@ namespace Content.Server.Atmos.EntitySystems
var req = prototype.MinimumRequirements[i];
if (!(mixture.GetMoles(i) < req)) continue;
if (!(mixture.GetMoles(i) < req))
continue;
doReaction = false;
break;
}
@@ -328,7 +341,7 @@ namespace Content.Server.Atmos.EntitySystems
if (!doReaction)
continue;
reaction = prototype.React(mixture, holder, this);
reaction = prototype.React(mixture, holder, this, HeatScale);
if(reaction.HasFlag(ReactionResult.StopReactions))
break;
}

View File

@@ -3,6 +3,7 @@ using Content.Server.Atmos.Components;
using Content.Server.Atmos.Reactions;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Utility;
@@ -558,4 +559,12 @@ public sealed partial class AtmosphereSystem
InvalidateVisuals(uid, position, overlay);
}
}
public TileRef GetTileRef(TileAtmosphere tile)
{
if (!TryComp(tile.GridIndex, out MapGridComponent? grid))
return default;
_map.TryGetTileRef(tile.GridIndex, grid, tile.GridIndices, out var tileRef);
return tileRef;
}
}

View File

@@ -1,13 +1,12 @@
using Content.Server.Administration.Logs;
using Content.Server.Atmos.Components;
using Content.Server.Body.Systems;
using Content.Server.Maps;
using Content.Server.Fluids.EntitySystems;
using Content.Server.NodeContainer.EntitySystems;
using Content.Shared.Atmos.EntitySystems;
using Content.Shared.Maps;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Map;
@@ -33,6 +32,8 @@ public sealed partial class AtmosphereSystem : SharedAtmosphereSystem
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
[Dependency] private readonly TileSystem _tile = default!;
[Dependency] private readonly MapSystem _map = default!;
[Dependency] public readonly PuddleSystem Puddle = default!;
private const float ExposedUpdateDelay = 1f;
private float _exposedTimer = 0f;
@@ -80,7 +81,7 @@ public sealed partial class AtmosphereSystem : SharedAtmosphereSystem
return;
var query = EntityQueryEnumerator<AtmosExposedComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var exposed, out var transform))
while (query.MoveNext(out var uid, out _, out var transform))
{
var air = GetContainingMixture(uid, transform:transform);

View File

@@ -83,7 +83,7 @@ public sealed class HeatExchangerSystem : EntitySystem
else
xfer = outlet.Air.Remove(-n);
float CXfer = _atmosphereSystem.GetHeatCapacity(xfer);
float CXfer = _atmosphereSystem.GetHeatCapacity(xfer, true);
if (CXfer < Atmospherics.MinimumHeatCapacity)
return;
@@ -94,7 +94,7 @@ public sealed class HeatExchangerSystem : EntitySystem
float CEnv = 0f;
if (environment != null)
{
CEnv = _atmosphereSystem.GetHeatCapacity(environment);
CEnv = _atmosphereSystem.GetHeatCapacity(environment, true);
hasEnv = CEnv >= Atmospherics.MinimumHeatCapacity && environment.TotalMoles > 0f;
if (hasEnv)
radTemp = environment.Temperature;