Unique gas serialization for atmos (#1629)

* Add unique gas mixture serialization for atmos

* Refactor doAfterEventArgs

* Adds atmos commands

* Roundstard now has correct ratio of gases

* Fixed hashcode for gasmixture, better grid atmos serialization

* Airlocks create gas based on adjacent tiles now.

* Enables barotrauma component damage
This commit is contained in:
Víctor Aguilera Puerto
2020-08-09 16:52:59 +02:00
committed by GitHub
parent 4fe1083bfb
commit 7293d985a5
9 changed files with 11060 additions and 49 deletions

View File

@@ -1,6 +1,7 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using Content.Server.Atmos.Reactions;
using Content.Server.Interfaces;
@@ -520,9 +521,10 @@ namespace Content.Server.Atmos
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Equals(_moles, other._moles)
&& Equals(_molesArchived, other._molesArchived)
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)
@@ -531,12 +533,28 @@ namespace Content.Server.Atmos
public override int GetHashCode()
{
return HashCode.Combine(_moles, _molesArchived, _temperature, Immutable, LastShare, TemperatureArchived, Volume);
var hashCode = new HashCode();
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);
return hashCode.ToHashCode();
}
public object Clone()
{
return new GasMixture()
var newMixture = new GasMixture()
{
_moles = (float[])_moles.Clone(),
_molesArchived = (float[])_molesArchived.Clone(),
@@ -546,6 +564,7 @@ namespace Content.Server.Atmos
TemperatureArchived = TemperatureArchived,
Volume = Volume,
};
return newMixture;
}
}
}