Misc Atmos Improvements (#5613)

* Revert "Remove atmos archiving."

This reverts commit 7fa10bd17b.

* Explosive Depressurization now brings tiles down to TCMB.

* Tiles now specify heat capacity.

* Do not serialize archived gas mixture values.

* Remove bad idea

* dumb typo

* Space gas mixtures now have a harcoded heat capacity.
This is a bit of a hack, but rooms exposed to space now cool down properly when monstermos is disabled.
Huge thanks to @LemonInTheDark for helping me with this!

* Clean up heat capacity methods

* Better logging based on the original monstermos' logging

* Comment explosive depressurization hack better
This commit is contained in:
Vera Aguilera Puerto
2021-11-30 11:42:48 +01:00
committed by GitHub
parent 9db2fbefe1
commit 94fa6efefb
11 changed files with 157 additions and 31 deletions

View File

@@ -26,6 +26,8 @@ namespace Content.Server.Atmos
[DataField("moles")] [ViewVariables]
public float[] Moles = new float[Atmospherics.AdjustedNumberOfGases];
public float[] MolesArchived = new float[Atmospherics.AdjustedNumberOfGases];
[DataField("temperature")] [ViewVariables]
private float _temperature = Atmospherics.TCMB;
@@ -70,6 +72,8 @@ namespace Content.Server.Atmos
}
}
public float TemperatureArchived { get; private set; }
[DataField("volume")] [ViewVariables]
public float Volume { get; set; }
@@ -90,6 +94,13 @@ namespace Content.Server.Atmos
Immutable = true;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Archive()
{
Moles.AsSpan().CopyTo(MolesArchived.AsSpan());
TemperatureArchived = Temperature;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float GetMoles(int gasId)
{
@@ -240,6 +251,7 @@ namespace Content.Server.Atmos
{
// The arrays MUST have a specific length.
Array.Resize(ref Moles, Atmospherics.AdjustedNumberOfGases);
Array.Resize(ref MolesArchived, Atmospherics.AdjustedNumberOfGases);
}
public override bool Equals(object? obj)
@@ -254,10 +266,12 @@ namespace Content.Server.Atmos
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Moles.SequenceEqual(other.Moles)
&& MolesArchived.SequenceEqual(other.MolesArchived)
&& _temperature.Equals(other._temperature)
&& ReactionResults.SequenceEqual(other.ReactionResults)
&& Immutable == other.Immutable
&& LastShare.Equals(other.LastShare)
&& TemperatureArchived.Equals(other.TemperatureArchived)
&& Volume.Equals(other.Volume);
}
@@ -268,10 +282,13 @@ namespace Content.Server.Atmos
for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
{
var moles = Moles[i];
var molesArchived = MolesArchived[i];
hashCode.Add(moles);
hashCode.Add(molesArchived);
}
hashCode.Add(_temperature);
hashCode.Add(TemperatureArchived);
hashCode.Add(Immutable);
hashCode.Add(LastShare);
hashCode.Add(Volume);
@@ -284,9 +301,11 @@ namespace Content.Server.Atmos
var newMixture = new GasMixture()
{
Moles = (float[])Moles.Clone(),
MolesArchived = (float[])MolesArchived.Clone(),
_temperature = _temperature,
Immutable = Immutable,
LastShare = LastShare,
TemperatureArchived = TemperatureArchived,
Volume = Volume,
};
return newMixture;