-
Notifications
You must be signed in to change notification settings - Fork 33
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
Atmos Update #379
base: master
Are you sure you want to change the base?
Atmos Update #379
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
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 | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -14,6 +14,12 @@ public sealed partial class FrezonProductionReaction : IGasReactionEffect | |||||||||||||||||||||
{ | ||||||||||||||||||||||
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale) | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
//LPP-start | ||||||||||||||||||||||
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium); | ||||||||||||||||||||||
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f) | ||||||||||||||||||||||
return ReactionResult.NoReaction; | ||||||||||||||||||||||
//LPP-end | ||||||||||||||||||||||
|
||||||||||||||||||||||
Comment on lines
+17
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Улучшить документацию кода Комментарии 'LPP-start' и 'LPP-end' не несут смысловой нагрузки. Следует заменить их на описательные комментарии. - //LPP-start
+ // Проверка ингибирования реакции гипернобилием при высокой температуре
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;
- //LPP-end 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
var initialN2 = mixture.GetMoles(Gas.Nitrogen); | ||||||||||||||||||||||
var initialOxy = mixture.GetMoles(Gas.Oxygen); | ||||||||||||||||||||||
var initialTrit = mixture.GetMoles(Gas.Tritium); | ||||||||||||||||||||||
|
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); | ||||||||||||||||||||
|
||||||||||||||||||||
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); | ||||||||||||||||||||
Comment on lines
+32
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Рекомендуется добавить ограничение энергии реакции При высоких значениях var energyUsed = heatEfficiency * Atmospherics.HalonCombustionEnergy;
+energyUsed = Math.Min(energyUsed, Atmospherics.FireMaximumEnergy);
var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true); 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
return ReactionResult.Reacting; | ||||||||||||||||||||
} | ||||||||||||||||||||
} |
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) | ||||||||||||||||||
Comment on lines
+21
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Сложная формула расчета эффективности требует документации Формула использует несколько коэффициентов (0.3f, 2.75f, 0.25f) без объяснения их значений. Рекомендуется добавить комментарии, объясняющие происхождение этих значений. +// Temperature coefficient (0.3) controls reaction rate with temperature
+// Frezon coefficient (2.75) and BZ coefficient (0.25) represent stoichiometric ratios
var heatEfficiency = Math.Min(temperature*0.3f, Math.Min(initialFrezon*2.75f, initialBZ*0.25f)); 📝 Committable suggestion
Suggested change
|
||||||||||||||||||
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); | ||||||||||||||||||
|
||||||||||||||||||
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; | ||||||||||||||||||
} | ||||||||||||||||||
} |
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; | ||||||||||
Comment on lines
+15
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Исправьте сравнение температуры: используйте Кельвины вместо Цельсия В коде температура измеряется в Кельвинах, поэтому сравнение с Примените следующий дифф для исправления сравнения температуры: -if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
+if (initialHyperNoblium >= 5.0f && mixture.Temperature > 293.15f) 📝 Committable suggestion
Suggested change
|
||||||||||
|
||||||||||
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) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Логическая ошибка в условии прекращения реакции Условие Рекомендуется пересмотреть данное условие и использовать более понятную проверку, например: - if (nobFormed <= 0 || (initialTritium - 5f) * nobFormed < 0 || (initialNitrogen - 10f) * nobFormed < 0)
+ if (nobFormed <= 0 || initialTritium < 5f || initialNitrogen < 10f) 📝 Committable suggestion
Suggested change
|
||||||||||||
return ReactionResult.NoReaction; | ||||||||||||
|
||||||||||||
var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true); | ||||||||||||
|
||||||||||||
var reductionFactor = Math.Clamp(initialTritium/(initialTritium+initialBZ), 0.001f, 1f); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Риск деления на ноль при вычислении В выражении Рекомендуется добавить проверку и обработку этого случая: + if (initialTritium + initialBZ == 0f)
+ reductionFactor = 0.001f;
+ else
+ reductionFactor = Math.Clamp(initialTritium / (initialTritium + initialBZ), 0.001f, 1f); 📝 Committable suggestion
Suggested change
|
||||||||||||
|
||||||||||||
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; | ||||||||||||
} | ||||||||||||
} |
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; | ||
} | ||
} |
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; | ||||||||||
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Исправьте сравнение температуры: используйте Кельвины вместо Цельсия В коде температура измеряется в Кельвинах, поэтому сравнение с Примените следующий дифф для исправления сравнения температуры: -if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
+if (initialHyperNoblium >= 5.0f && mixture.Temperature > 293.15f) 📝 Committable suggestion
Suggested change
|
||||||||||
|
||||||||||
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; | ||||||||||
} | ||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Исправьте сравнение температуры: используйте Кельвины вместо Цельсия
В коде температура измеряется в Кельвинах, поэтому сравнение с
20f
может быть некорректным. Рекомендуется использовать значение293.15f
(что соответствует 20°C в Кельвинах) для правильного сравнения.Примените следующий дифф для исправления сравнения температуры:
📝 Committable suggestion