mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-06-09 10:06:49 +02:00
b582f2e156
* cleanup * fix some localizations * fix typo * review and test fix * rename * minus one --------- Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
60 lines
2.4 KiB
C#
60 lines
2.4 KiB
C#
using System.Runtime.CompilerServices;
|
|
using Content.Shared.Atmos;
|
|
using Content.Shared.Atmos.Reactions;
|
|
|
|
namespace Content.Client.Atmos.EntitySystems;
|
|
|
|
public sealed partial class AtmosphereSystem
|
|
{
|
|
/*
|
|
Partial class for operations involving GasMixtures.
|
|
|
|
Any method that is overridden here is usually because the server-sided implementation contains
|
|
code that would escape sandbox. As such these methods are overridden here with a safe
|
|
implementation.
|
|
*/
|
|
|
|
/// <inheritdoc/>
|
|
/// <remarks>No-op on client as reactions aren't entirely in shared.
|
|
/// Don't call it. Smile.</remarks>
|
|
public override ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder)
|
|
{
|
|
// Reactions don't work on client so don't even try.
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override bool IsMixtureFuel(GasMixture mixture, float epsilon = Atmospherics.Epsilon)
|
|
{
|
|
var tmp = new float[Atmospherics.AdjustedNumberOfGases];
|
|
NumericsHelpers.Multiply(mixture.Moles, GasFuelMask, tmp);
|
|
return NumericsHelpers.HorizontalAdd(tmp) > epsilon;
|
|
}
|
|
|
|
public override bool IsMixtureOxidizer(GasMixture mixture, float epsilon = Atmospherics.Epsilon)
|
|
{
|
|
var tmp = new float[Atmospherics.AdjustedNumberOfGases];
|
|
NumericsHelpers.Multiply(mixture.Moles, GasOxidizerMask, tmp);
|
|
return NumericsHelpers.HorizontalAdd(tmp) > epsilon;
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
protected override float GetHeatCapacityCalculation(float[] moles, bool space)
|
|
{
|
|
// Little hack to make space gas mixtures have heat capacity, therefore allowing them to cool down rooms.
|
|
if (space && MathHelper.CloseTo(NumericsHelpers.HorizontalAdd(moles), 0f))
|
|
{
|
|
return Atmospherics.SpaceHeatCapacity;
|
|
}
|
|
|
|
// explicit stackalloc call is banned on client tragically.
|
|
// the JIT does not stackalloc this during runtime,
|
|
// though this isnt the hottest code path so it should be fine
|
|
// the gc can eat a little as a treat
|
|
var tmp = new float[moles.Length];
|
|
NumericsHelpers.Multiply(moles, GasMolarHeatCapacities, tmp);
|
|
// 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);
|
|
}
|
|
}
|