Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[port] TGgases Try 2 #1008

Merged
merged 7 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions Content.Server/ADT/Atmos/Reactions/BZProductionReaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;

namespace Content.Server.Atmos.Reactions;

[UsedImplicitly]
public sealed partial class BZProductionReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;

var initialNitrousOxide = mixture.GetMoles(Gas.NitrousOxide);
var initialPlasma = mixture.GetMoles(Gas.Plasma);

var environmentEfficiency = mixture.Volume / mixture.Pressure;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Возможное деление на ноль в вычислениях environmentEfficiency и ratioEfficiency

В строке 20 может произойти деление на ноль, если mixture.Pressure равно нулю. В строке 22 может произойти деление на ноль, если initialPlasma равно нулю. Это может привести к исключению DivideByZeroException.

Рекомендуется добавить проверки перед делением, чтобы убедиться, что знаменатели не равны нулю:

+            if (mixture.Pressure == 0)
+                return ReactionResult.NoReaction;

             var environmentEfficiency = mixture.Volume / mixture.Pressure;

+            if (initialPlasma == 0)
+                return ReactionResult.NoReaction;

             var ratioEfficiency = Math.Min(initialNitrousOxide / initialPlasma, 1);

Also applies to: 22-22

var ratioEfficiency = Math.Min(initialNitrousOxide / initialPlasma, 1);

var bZFormed = Math.Min(0.01f * ratioEfficiency * environmentEfficiency, Math.Min(initialNitrousOxide * 0.4f, initialPlasma * 0.8f));

if (initialNitrousOxide - bZFormed * 0.4f < 0 || initialPlasma - (0.8f - bZFormed) < 0 || bZFormed <= 0)
return ReactionResult.NoReaction;

var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);

var amountDecomposed = 0.0f;
var nitrousOxideDecomposedFactor = Math.Max(4.0f * (initialPlasma / (initialNitrousOxide + initialPlasma) - 0.75f), 0);
if (nitrousOxideDecomposedFactor > 0)
{
amountDecomposed = 0.4f * bZFormed * nitrousOxideDecomposedFactor;
mixture.AdjustMoles(Gas.Oxygen, amountDecomposed);
mixture.AdjustMoles(Gas.Nitrogen, 0.5f * amountDecomposed);
}

mixture.AdjustMoles(Gas.BZ, Math.Max(0f, bZFormed * (1.0f - nitrousOxideDecomposedFactor)));
mixture.AdjustMoles(Gas.NitrousOxide, -0.4f * bZFormed);
mixture.AdjustMoles(Gas.Plasma, -0.8f * bZFormed * (1.0f - nitrousOxideDecomposedFactor));

var energyReleased = bZFormed * (Atmospherics.BZFormationEnergy + nitrousOxideDecomposedFactor * (Atmospherics.NitrousOxideDecompositionEnergy - Atmospherics.BZFormationEnergy));

var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
mixture.Temperature = Math.Max((mixture.Temperature * oldHeatCapacity + energyReleased) / newHeatCapacity, Atmospherics.TCMB);

return ReactionResult.Reacting;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;

namespace Content.Server.Atmos.Reactions;

[UsedImplicitly]
public sealed partial class HalonOxygenAbsorptionReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;

var initialHalon = mixture.GetMoles(Gas.Halon);
var initialOxygen = mixture.GetMoles(Gas.Oxygen);

var temperature = mixture.Temperature;

var heatEfficiency = Math.Min(temperature / (Atmospherics.FireMinimumTemperatureToExist * 10f), Math.Min(initialHalon, initialOxygen * 20f));
if (heatEfficiency <= 0f || initialHalon - heatEfficiency < 0f || initialOxygen - heatEfficiency * 20f < 0f)
return ReactionResult.NoReaction;

var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);

mixture.AdjustMoles(Gas.Halon, -heatEfficiency);
mixture.AdjustMoles(Gas.Oxygen, -heatEfficiency * 20f);
mixture.AdjustMoles(Gas.CarbonDioxide, heatEfficiency * 5f);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Подтверждаю необходимость проверок на отрицательные значения

Анализ кодовой базы показывает, что проверки на отрицательные значения являются общепринятой практикой в атмосферных реакциях. Рекомендуется добавить следующие проверки после корректировки молей:

  • Проверить mixture.GetMoles(Gas.Halon) после уменьшения на heatEfficiency
  • Проверить mixture.GetMoles(Gas.Oxygen) после уменьшения на heatEfficiency * 20f
  • Проверить mixture.GetMoles(Gas.CarbonDioxide) после увеличения на heatEfficiency * 5f

За пример реализации можно взять проверки из AmmoniaOxygenReaction.cs.

🔗 Analysis chain

Добавьте проверку на отрицательные значения

Рекомендуется добавить проверки на отрицательные значения после корректировки количества молей для обеспечения безопасности:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Поиск подобных проверок в других реакциях
rg -l "AdjustMoles.*if.*< 0" --type cs

Length of output: 40


Script:

#!/bin/bash
# Check AdjustMoles implementation
ast-grep --pattern 'AdjustMoles($$$) { $$$ }'

# Look for broader patterns in gas reactions
rg -l "class.*Reaction.*Gas" --type cs

# Check for any value checks in reactions
rg "if.*Moles.*[<>]" --type cs

Length of output: 5097


var energyUsed = heatEfficiency * Atmospherics.HalonCombustionEnergy;
var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
mixture.Temperature = Math.Max((mixture.Temperature * oldHeatCapacity + energyUsed) / newHeatCapacity, Atmospherics.TCMB);

return ReactionResult.Reacting;
}
}
40 changes: 40 additions & 0 deletions Content.Server/ADT/Atmos/Reactions/HealiumProductionReaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;

namespace Content.Server.Atmos.Reactions;

[UsedImplicitly]
public sealed partial class HealiumProductionReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;

var initialBZ = mixture.GetMoles(Gas.BZ);
var initialFrezon = mixture.GetMoles(Gas.Frezon);

var temperature = mixture.Temperature;
var heatEfficiency = Math.Min(temperature * 0.3f, Math.Min(initialFrezon * 2.75f, initialBZ * 0.25f));

if (heatEfficiency <= 0 || initialFrezon - heatEfficiency * 2.75f < 0 || initialBZ - heatEfficiency * 0.25f < 0)
return ReactionResult.NoReaction;

var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);

mixture.AdjustMoles(Gas.Frezon, -heatEfficiency * 2.75f);
mixture.AdjustMoles(Gas.BZ, -heatEfficiency * 0.25f);
mixture.AdjustMoles(Gas.Healium, heatEfficiency * 3);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Обнаружен дисбаланс массы в реакции

В текущей реакции не соблюдается закон сохранения массы:

  • Входящая масса: 162.5 г (137.5 г Frezon + 25 г BZ)
  • Исходящая масса: 120 г (Healium)
  • Разница: 42.5 г избыточной массы на входе
🔗 Analysis chain

Проверить баланс массы в реакции

Реакция преобразует Frezon и BZ в Healium с разными коэффициентами. Необходимо убедиться в сохранении массы:

  • Frezon: -2.75
  • BZ: -0.25
  • Healium: +3.0
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Поиск других реакций с похожими коэффициентами
ast-grep --pattern 'mixture.AdjustMoles(Gas.$_, $_ * $_)'

Length of output: 445


Script:

#!/bin/bash
# Search for gas definitions and properties
rg -A 5 "enum Gas" 
rg "MolarMass" --type cs

Length of output: 6714


Script:

#!/bin/bash
# Search for gas prototype files
fd -e yaml -e yml | xargs rg "type: Gas" -A 10

Length of output: 13070


Script:

#!/bin/bash
# Try to find gas definitions in Resources/Prototypes directory
fd . Resources/Prototypes -t f | grep -i gas

Length of output: 799


Script:

#!/bin/bash
# Check contents of gas definition files
cat Resources/Prototypes/ADT/Atmospherics/gases.yml Resources/Prototypes/Atmospherics/gases.yml Resources/Prototypes/ADT/Reagents/gases.yml Resources/Prototypes/Reagents/gases.yml

Length of output: 20007


var energyReleased = heatEfficiency * Atmospherics.HealiumFormationEnergy;

var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
mixture.Temperature = Math.Max((mixture.Temperature * oldHeatCapacity + energyReleased) / newHeatCapacity, Atmospherics.TCMB);

return ReactionResult.Reacting;
}
}
59 changes: 59 additions & 0 deletions Content.Server/ADT/Atmos/Reactions/HydrogenFireReaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;

namespace Content.Server.Atmos.Reactions
{
[UsedImplicitly]
[DataDefinition]
public sealed partial class HydrogenFireReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;

var energyReleased = 0f;
var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
var temperature = mixture.Temperature;
var location = holder as TileAtmosphere;
mixture.ReactionResults[GasReaction.Fire] = 0;

var initialOxygen = mixture.GetMoles(Gas.Oxygen);
var initialHydrogen = mixture.GetMoles(Gas.Hydrogen);

var burnedFuel = Math.Min(initialHydrogen / Atmospherics.FireH2BurnRateDelta, Math.Min(initialOxygen / (Atmospherics.FireH2BurnRateDelta * Atmospherics.H2OxygenFullBurn), Math.Min(initialHydrogen, initialOxygen * 0.5f)));

if (burnedFuel > 0)
{
energyReleased += Atmospherics.FireH2EnergyReleased * burnedFuel;

mixture.AdjustMoles(Gas.WaterVapor, burnedFuel);
mixture.AdjustMoles(Gas.Hydrogen, -burnedFuel);
mixture.AdjustMoles(Gas.Oxygen, -burnedFuel * 0.5f);

mixture.ReactionResults[GasReaction.Fire] += burnedFuel;
}

if (energyReleased > 0)
{
var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
mixture.Temperature = (temperature * oldHeatCapacity + energyReleased) / newHeatCapacity;
}

if (location != null)
{
temperature = mixture.Temperature;
if (temperature > Atmospherics.FireMinimumTemperatureToExist)
{
atmosphereSystem.HotspotExpose(location.GridIndex, location.GridIndices, temperature, mixture.Volume);
}
}

return mixture.ReactionResults[GasReaction.Fire] != 0 ? ReactionResult.Reacting : ReactionResult.NoReaction;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;

namespace Content.Server.Atmos.Reactions;

[UsedImplicitly]
public sealed partial class HyperNobliumProductionReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;

var initialNitrogen = mixture.GetMoles(Gas.Nitrogen);
var initialTritium = mixture.GetMoles(Gas.Tritium);
var initialBZ = mixture.GetMoles(Gas.BZ);

var nobFormed = Math.Min((initialNitrogen + initialTritium) * 0.01f, Math.Min(initialTritium * 5f, initialNitrogen * 10f));
if (nobFormed <= 0 || (initialTritium - 5f) * nobFormed < 0 || (initialNitrogen - 10f) * nobFormed < 0)
return ReactionResult.NoReaction;

var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);

var reductionFactor = Math.Clamp(initialTritium / (initialTritium + initialBZ), 0.001f, 1f);

mixture.AdjustMoles(Gas.Tritium, -5f * nobFormed * reductionFactor);
mixture.AdjustMoles(Gas.Nitrogen, -10f * nobFormed);
mixture.AdjustMoles(Gas.HyperNoblium, nobFormed);

var energyReleased = nobFormed * (Atmospherics.NobliumFormationEnergy / Math.Max(initialBZ, 1));

var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
mixture.Temperature = Math.Max((mixture.Temperature * oldHeatCapacity + energyReleased) / newHeatCapacity, Atmospherics.TCMB);

return ReactionResult.Reacting;
}
}
39 changes: 39 additions & 0 deletions Content.Server/ADT/Atmos/Reactions/NitriumDecompositionReaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;

namespace Content.Server.Atmos.Reactions;

[UsedImplicitly]
public sealed partial class NitriumDecompositionReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;

var initialNitrium = mixture.GetMoles(Gas.Nitrium);

var temperature = mixture.Temperature;
var heatEfficiency = Math.Min(temperature / Atmospherics.NitriumDecompositionTempDivisor, initialNitrium);

if (heatEfficiency <= 0 || initialNitrium - heatEfficiency < 0)
return ReactionResult.NoReaction;

var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);

mixture.AdjustMoles(Gas.Nitrium, -heatEfficiency);
mixture.AdjustMoles(Gas.Hydrogen, heatEfficiency);
mixture.AdjustMoles(Gas.Nitrogen, heatEfficiency);

var energyReleased = heatEfficiency * Atmospherics.NitriumDecompositionEnergy;

var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
mixture.Temperature = Math.Max((mixture.Temperature * oldHeatCapacity + energyReleased) / newHeatCapacity, Atmospherics.TCMB);

return ReactionResult.Reacting;
}
}
41 changes: 41 additions & 0 deletions Content.Server/ADT/Atmos/Reactions/NitriumProductionReaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;

namespace Content.Server.Atmos.Reactions;

[UsedImplicitly]
public sealed partial class NitriumProductionReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;

var initialTritium = mixture.GetMoles(Gas.Tritium);
var initialNitrogen = mixture.GetMoles(Gas.Nitrogen);
var initialBZ = mixture.GetMoles(Gas.BZ);

var temperature = mixture.Temperature;
var heatEfficiency = Math.Min(temperature / Atmospherics.NitriumFormationTempDivisor, Math.Min(initialTritium, Math.Min(initialNitrogen, initialBZ * 0.05f)));

if (heatEfficiency <= 0 || initialTritium - heatEfficiency < 0 || initialNitrogen - heatEfficiency < 0 || initialBZ - heatEfficiency * 0.05f < 0)
return ReactionResult.NoReaction;

var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
mixture.AdjustMoles(Gas.Tritium, -heatEfficiency);
mixture.AdjustMoles(Gas.Nitrogen, -heatEfficiency);
mixture.AdjustMoles(Gas.BZ, -heatEfficiency * 0.05f);
mixture.AdjustMoles(Gas.Nitrium, heatEfficiency);

var energyUsed = heatEfficiency * Atmospherics.NitriumFormationEnergy;

var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
mixture.Temperature = Math.Max((mixture.Temperature * oldHeatCapacity - energyUsed) / newHeatCapacity, Atmospherics.TCMB);

return ReactionResult.Reacting;
}
}
41 changes: 41 additions & 0 deletions Content.Server/ADT/Atmos/Reactions/PluoxiumProductionReaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;

namespace Content.Server.Atmos.Reactions;

[UsedImplicitly]
public sealed partial class PluoxiumProductionReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;

var initialCarbonDioxide = mixture.GetMoles(Gas.CarbonDioxide);
var initialOxygen = mixture.GetMoles(Gas.Oxygen);
var initialTritium = mixture.GetMoles(Gas.Tritium);

var producedAmount = Math.Min(Atmospherics.PluoxiumMaxRate, Math.Min(initialCarbonDioxide, Math.Min(initialOxygen * 0.5f, initialTritium * 0.01f)));

if (producedAmount <= 0 || initialCarbonDioxide - producedAmount < 0 || initialOxygen - producedAmount * 0.5f < 0 || initialTritium - producedAmount * 0.01f < 0)
return ReactionResult.NoReaction;

mixture.AdjustMoles(Gas.CarbonDioxide, -producedAmount);
mixture.AdjustMoles(Gas.Oxygen, -producedAmount * 0.5f);
mixture.AdjustMoles(Gas.Tritium, -producedAmount * 0.01f);
mixture.AdjustMoles(Gas.Pluoxium, producedAmount);
mixture.AdjustMoles(Gas.Hydrogen, producedAmount * 0.01f);

var energyReleased = producedAmount * Atmospherics.PluoxiumFormationEnergy;

var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Исправить избыточный расчет теплоёмкости.

Теплоёмкость рассчитывается дважды подряд, что является избыточным.

         var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
-        var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
+        mixture.AdjustMoles(Gas.CarbonDioxide, -producedAmount);
+        mixture.AdjustMoles(Gas.Oxygen, -producedAmount * 0.5f);
+        mixture.AdjustMoles(Gas.Tritium, -producedAmount * 0.01f);
+        mixture.AdjustMoles(Gas.Pluoxium, producedAmount);
+        mixture.AdjustMoles(Gas.Hydrogen, producedAmount * 0.01f);
+        var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
mixture.AdjustMoles(Gas.CarbonDioxide, -producedAmount);
mixture.AdjustMoles(Gas.Oxygen, -producedAmount * 0.5f);
mixture.AdjustMoles(Gas.Tritium, -producedAmount * 0.01f);
mixture.AdjustMoles(Gas.Pluoxium, producedAmount);
mixture.AdjustMoles(Gas.Hydrogen, producedAmount * 0.01f);
var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);

if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
mixture.Temperature = Math.Max((mixture.Temperature * oldHeatCapacity + energyReleased) / newHeatCapacity, Atmospherics.TCMB);

return ReactionResult.Reacting;
}
}
Loading
Loading