Fix lungs having negative moles in gas mixtures
This commit is contained in:
@@ -76,21 +76,7 @@ namespace Content.Server.GameObjects.Components.Body.Behavior
|
|||||||
|
|
||||||
public void Transfer(GasMixture from, GasMixture to, float ratio)
|
public void Transfer(GasMixture from, GasMixture to, float ratio)
|
||||||
{
|
{
|
||||||
var removed = from.RemoveRatio(ratio);
|
to.Merge(from.RemoveRatio(ratio));
|
||||||
var toOld = to.Gases.ToArray();
|
|
||||||
|
|
||||||
to.Merge(removed);
|
|
||||||
|
|
||||||
for (var gas = 0; gas < Atmospherics.TotalNumberOfGases; gas++)
|
|
||||||
{
|
|
||||||
var newAmount = to.GetMoles(gas);
|
|
||||||
var oldAmount = toOld[gas];
|
|
||||||
var delta = newAmount - oldAmount;
|
|
||||||
|
|
||||||
removed.AdjustMoles(gas, -delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
from.Merge(removed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToBloodstream(GasMixture mixture)
|
public void ToBloodstream(GasMixture mixture)
|
||||||
@@ -204,20 +190,7 @@ namespace Content.Server.GameObjects.Components.Body.Behavior
|
|||||||
bloodstream.PumpToxins(Air);
|
bloodstream.PumpToxins(Air);
|
||||||
|
|
||||||
var lungRemoved = Air.RemoveRatio(0.5f);
|
var lungRemoved = Air.RemoveRatio(0.5f);
|
||||||
var toOld = to.Gases.ToArray();
|
|
||||||
|
|
||||||
to.Merge(lungRemoved);
|
to.Merge(lungRemoved);
|
||||||
|
|
||||||
for (var gas = 0; gas < Atmospherics.TotalNumberOfGases; gas++)
|
|
||||||
{
|
|
||||||
var newAmount = to.GetMoles(gas);
|
|
||||||
var oldAmount = toOld[gas];
|
|
||||||
var delta = newAmount - oldAmount;
|
|
||||||
|
|
||||||
lungRemoved.AdjustMoles(gas, -delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
Air.Merge(lungRemoved);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user