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

Revert "atmos gas interaction reworks" #39

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
37 changes: 9 additions & 28 deletions Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@ public sealed partial class AtmosphereSystem
[ViewVariables(VVAccess.ReadWrite)]
public string? HotspotSound { get; private set; } = "/Audio/Effects/fire.ogg";

private const float min_moles_for_hotspot=.5f; //min moles of fuel+ox to allow combustion

private float GetHotspotTotalFuel(TileAtmosphere tile){
if (tile==null || tile.Air==null) return 0f;
return tile.Air.GetMoles(Gas.Plasma)+tile.Air.GetMoles(Gas.Ammonia)+tile.Air.GetMoles(Gas.Tritium);
}
private float GetHotspotTotalOxidizer(TileAtmosphere tile){
if (tile==null || tile.Air==null) return 0f;
//nitro is .5 because of how it breaks down. (into 1 mole of n2, .5 mole of o2)
return tile.Air.GetMoles(Gas.Oxygen)+tile.Air.GetMoles(Gas.NitrousOxide)*.5f;
}


private void ProcessHotspot(
Entity<GridAtmosphereComponent, GasTileOverlayComponent, MapGridComponent, TransformComponent> ent,
TileAtmosphere tile)
Expand All @@ -59,9 +46,9 @@ private void ProcessHotspot(
ExcitedGroupResetCooldowns(tile.ExcitedGroup);

if ((tile.Hotspot.Temperature < Atmospherics.FireMinimumTemperatureToExist) || (tile.Hotspot.Volume <= 1f)
|| tile.Air == null || GetHotspotTotalFuel(tile)<min_moles_for_hotspot || GetHotspotTotalOxidizer(tile)<min_moles_for_hotspot )
|| tile.Air == null || tile.Air.GetMoles(Gas.Oxygen) < 0.5f || (tile.Air.GetMoles(Gas.Plasma) < 0.5f && tile.Air.GetMoles(Gas.Tritium) < 0.5f))
{
tile.Hotspot = new Hotspot();
tile.Hotspot = new Hotspot();
InvalidateVisuals(ent, tile);
return;
}
Expand Down Expand Up @@ -134,31 +121,25 @@ private void ProcessHotspot(
// TODO ATMOS Maybe destroy location here?
}

//this function is called by items which make a hotspot in order to register the hotspot
private void HotspotExpose(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile,
float exposedTemperature, float exposedVolume, bool soh = false, EntityUid? sparkSourceUid = null)
{
const float min_moles_to_validate=.33f;
if (tile.Air == null)
return;

// var oxygen = tile.Air.GetMoles(Gas.Oxygen);

//if (oxygen < 0.5f)
// return;
var oxygen = tile.Air.GetMoles(Gas.Oxygen);

float plasma = tile.Air.GetMoles(Gas.Plasma);
float tritium = tile.Air.GetMoles(Gas.Tritium);
float oxygen = tile.Air.GetMoles(Gas.Oxygen);
if (oxygen < 0.5f)
return;

//allow the hotspot if it would cause an ignition (oxy/n2o+assorted gasses). we allow n2o because it's an oxidizer, and thermal decomposition.
bool allowhotspotignite= GetHotspotTotalFuel(tile)>=min_moles_for_hotspot && GetHotspotTotalOxidizer(tile)>=min_moles_for_hotspot;
var plasma = tile.Air.GetMoles(Gas.Plasma);
var tritium = tile.Air.GetMoles(Gas.Tritium);

if (tile.Hotspot.Valid)
{
if (soh)
{
if (allowhotspotignite)
if (plasma > 0.5f || tritium > 0.5f)
{
if (tile.Hotspot.Temperature < exposedTemperature)
tile.Hotspot.Temperature = exposedTemperature;
Expand All @@ -170,7 +151,7 @@ private void HotspotExpose(GridAtmosphereComponent gridAtmosphere, TileAtmospher
return;
}

if ((exposedTemperature > Atmospherics.FireMinimumTemperatureToExist) && allowhotspotignite)
if ((exposedTemperature > Atmospherics.PlasmaMinimumBurnTemperature) && (plasma > 0.5f || tritium > 0.5f))
{
if (sparkSourceUid.HasValue)
_adminLog.Add(LogType.Flammable, LogImpact.High, $"Heat/spark of {ToPrettyString(sparkSourceUid.Value)} caused atmos ignition of gas: {tile.Air.Temperature.ToString():temperature}K - {oxygen}mol Oxygen, {plasma}mol Plasma, {tritium}mol Tritium");
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Atmos/IGasReactionEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public partial interface IGasReactionEffect
/// <param name="heatScale">Scaling factor that should be applied to all heat input or outputs.</param>
ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem,
float heatScale);
}
}
}
34 changes: 34 additions & 0 deletions Content.Server/Atmos/Reactions/AmmoniaOxygenReaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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 AmmoniaOxygenReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var nAmmonia = mixture.GetMoles(Gas.Ammonia);
var nOxygen = mixture.GetMoles(Gas.Oxygen);
var nTotal = mixture.TotalMoles;

// Concentration-dependent reaction rate
var fAmmonia = nAmmonia/nTotal;
var fOxygen = nOxygen/nTotal;
var rate = MathF.Pow(fAmmonia, 2) * MathF.Pow(fOxygen, 2);

var deltaMoles = nAmmonia / Atmospherics.AmmoniaOxygenReactionRate * 2 * rate;

if (deltaMoles <= 0 || nAmmonia - deltaMoles < 0)
return ReactionResult.NoReaction;

mixture.AdjustMoles(Gas.Ammonia, -deltaMoles);
mixture.AdjustMoles(Gas.Oxygen, -deltaMoles);
mixture.AdjustMoles(Gas.NitrousOxide, deltaMoles / 2);
mixture.AdjustMoles(Gas.WaterVapor, deltaMoles * 1.5f);

return ReactionResult.Reacting;
}
}
71 changes: 0 additions & 71 deletions Content.Server/Atmos/Reactions/AmoniaOxygen_fire.cs

This file was deleted.

59 changes: 59 additions & 0 deletions Content.Server/Atmos/Reactions/FrezonCoolantReaction.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;

/// <summary>
/// Takes in nitrogen and frezon and cools down the surrounding area.
/// </summary>
[UsedImplicitly]
public sealed partial class FrezonCoolantReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
var temperature = mixture.Temperature;

var energyModifier = 1f;
var scale = (temperature - Atmospherics.FrezonCoolLowerTemperature) /
(Atmospherics.FrezonCoolMidTemperature - Atmospherics.FrezonCoolLowerTemperature);

if (scale > 1f)
{
// Scale energy but not frezon usage if we're in a very, very hot place
energyModifier = Math.Min(scale, Atmospherics.FrezonCoolMaximumEnergyModifier);
scale = 1f;
}

if (scale <= 0)
return ReactionResult.NoReaction;

var initialNit = mixture.GetMoles(Gas.Nitrogen);
var initialFrezon = mixture.GetMoles(Gas.Frezon);

var burnRate = initialFrezon * scale / Atmospherics.FrezonCoolRateModifier;

var energyReleased = 0f;
if (burnRate > Atmospherics.MinimumHeatCapacity)
{
var nitAmt = Math.Min(burnRate * Atmospherics.FrezonNitrogenCoolRatio, initialNit);
var frezonAmt = Math.Min(burnRate, initialFrezon);
mixture.AdjustMoles(Gas.Nitrogen, -nitAmt);
mixture.AdjustMoles(Gas.Frezon, -frezonAmt);
mixture.AdjustMoles(Gas.NitrousOxide, nitAmt + frezonAmt);
energyReleased = burnRate * Atmospherics.FrezonCoolEnergyReleased * energyModifier;
}

energyReleased /= heatScale; // adjust energy to make sure speedup doesn't cause mega temperature rise
if (energyReleased >= 0f)
return ReactionResult.NoReaction;

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

return ReactionResult.Reacting;
}
}
56 changes: 0 additions & 56 deletions Content.Server/Atmos/Reactions/FrezonOxygen_dissapation.cs

This file was deleted.

55 changes: 0 additions & 55 deletions Content.Server/Atmos/Reactions/FrezonPlasma_cooldown.cs

This file was deleted.

Loading
Loading