Skip to content

Commit

Permalink
feat: /tg/ gases
Browse files Browse the repository at this point in the history
  • Loading branch information
Spatison committed Dec 9, 2024
1 parent 08ecd6b commit 0cfbe74
Show file tree
Hide file tree
Showing 55 changed files with 2,607 additions and 149 deletions.
15 changes: 14 additions & 1 deletion Content.Client/Atmos/Consoles/AtmosAlarmEntryContainer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ public sealed partial class AtmosAlarmEntryContainer : BoxContainer
[Gas.Plasma] = "P",
[Gas.Tritium] = "T",
[Gas.WaterVapor] = "H₂O",
// WD EDIT START
[Gas.BZ] = "BZ",
[Gas.Pluoxium] = "TCO₃",
[Gas.Hydrogen] = "H₂",
[Gas.Nitrium] = "NT₂",
[Gas.Healium] = "FBZ",
[Gas.HyperNoblium] = "TN₂",
[Gas.ProtoNitrate] = "HTCO₃",
[Gas.Zauker] = "(NT)₃",
[Gas.Halon] = "Ha",
[Gas.Helium] = "He",
[Gas.AntiNoblium] = "AN",
// WD EDIT END
};

public AtmosAlarmEntryContainer(NetEntity uid, EntityCoordinates? coordinates)
Expand Down Expand Up @@ -212,4 +225,4 @@ private Color GetAlarmStateColor(AtmosAlarmType alarmType)

return StyleNano.DisabledFore;
}
}
}
2 changes: 1 addition & 1 deletion Content.Client/Atmos/Overlays/GasTileOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected override void FrameUpdate(FrameEventArgs args)
for (var i = 0; i < _gasCount; i++)
{
var delays = _frameDelays[i];
if (delays.Length == 0)
if (delays == null || delays.Length == 0) // WD EDIT
continue;

var frameCount = _frameCounter[i];
Expand Down
64 changes: 38 additions & 26 deletions Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ private void ProcessHotspot(
ExcitedGroupResetCooldowns(tile.ExcitedGroup);

if ((tile.Hotspot.Temperature < Atmospherics.FireMinimumTemperatureToExist) || (tile.Hotspot.Volume <= 1f)
|| 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.Air == null || tile.Air.GetMoles(Gas.Oxygen) < 0.5f || (tile.Air.GetMoles(Gas.Plasma) < 0.5f && tile.Air.GetMoles(Gas.Tritium) < 0.5f
&& tile.Air.GetMoles(Gas.Hydrogen) < 0.5f && tile.Air.GetMoles(Gas.HyperNoblium) > 5f)) // WD EDIT
{
tile.Hotspot = new Hotspot();
InvalidateVisuals(ent, tile);
Expand Down Expand Up @@ -109,40 +110,51 @@ private void HotspotExpose(GridAtmosphereComponent gridAtmosphere, TileAtmospher

var plasma = tile.Air.GetMoles(Gas.Plasma);
var tritium = tile.Air.GetMoles(Gas.Tritium);
var hydrogen = tile.Air.GetMoles(Gas.Hydrogen); // WD EDIT
var hypernoblium = tile.Air.GetMoles(Gas.HyperNoblium); // WD EDIT

if (tile.Hotspot.Valid)
{
if (soh)
{
if (plasma > 0.5f || tritium > 0.5f)
{
if (tile.Hotspot.Temperature < exposedTemperature)
tile.Hotspot.Temperature = exposedTemperature;
if (tile.Hotspot.Volume < exposedVolume)
tile.Hotspot.Volume = exposedVolume;
}
}
// WD EDIT START
if (!soh)
return;

if ((!(plasma > 0.5f) || !(hypernoblium < 5f))
&& (!(tritium > 0.5f) || !(hypernoblium < 5f))
&& (!(hydrogen > 0.5f) || !(hypernoblium < 5f)))
return;

if (tile.Hotspot.Temperature < exposedTemperature)
tile.Hotspot.Temperature = exposedTemperature;
if (tile.Hotspot.Volume < exposedVolume)
tile.Hotspot.Volume = exposedVolume;
// WD EDIT END

return;
}

if ((exposedTemperature > Atmospherics.PlasmaMinimumBurnTemperature) && (plasma > 0.5f || tritium > 0.5f))
// WD EDIT START
if (!(exposedTemperature > Atmospherics.PlasmaMinimumBurnTemperature)
|| (!(plasma > 0.5f) || !(hypernoblium < 5f))
&& (!(tritium > 0.5f) || !(hypernoblium < 5f))
&& (!(hydrogen > 0.5f) || !(hypernoblium < 5f)))
return;
// WD EDIT END

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, {hydrogen}mol Hydrogen");

tile.Hotspot = new Hotspot
{
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");
Volume = exposedVolume * 25f,
Temperature = exposedTemperature,
SkippedFirstProcess = tile.CurrentCycle > gridAtmosphere.UpdateCounter,
Valid = true,
State = 1
};

tile.Hotspot = new Hotspot
{
Volume = exposedVolume * 25f,
Temperature = exposedTemperature,
SkippedFirstProcess = tile.CurrentCycle > gridAtmosphere.UpdateCounter,
Valid = true,
State = 1
};

AddActiveTile(gridAtmosphere, tile);
gridAtmosphere.HotspotTiles.Add(tile);
}
AddActiveTile(gridAtmosphere, tile);
gridAtmosphere.HotspotTiles.Add(tile);
}

private void PerformHotspotExposure(TileAtmosphere tile)
Expand Down
13 changes: 12 additions & 1 deletion Content.Server/Atmos/Portable/PortableScrubberComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,18 @@ public sealed partial class PortableScrubberComponent : Component
Gas.WaterVapor,
Gas.Ammonia,
Gas.NitrousOxide,
Gas.Frezon
Gas.Frezon,
Gas.BZ,
Gas.Pluoxium,
Gas.Hydrogen,
Gas.Nitrium,
Gas.Healium,
Gas.HyperNoblium,
Gas.ProtoNitrate,
Gas.Zauker,
Gas.Halon,
Gas.Helium,
Gas.AntiNoblium
};

[ViewVariables(VVAccess.ReadWrite)]
Expand Down
7 changes: 7 additions & 0 deletions Content.Server/Atmos/Reactions/FrezonCoolantReaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ public sealed partial class FrezonCoolantReaction : IGasReactionEffect
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);

// WD EDIT START
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;
// WD EDIT END

var temperature = mixture.Temperature;

var energyModifier = 1f;
Expand Down
6 changes: 6 additions & 0 deletions Content.Server/Atmos/Reactions/FrezonProductionReaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public sealed partial class FrezonProductionReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
// WD EDIT START
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;
// WD EDIT END

var initialN2 = mixture.GetMoles(Gas.Nitrogen);
var initialOxy = mixture.GetMoles(Gas.Oxygen);
var initialTrit = mixture.GetMoles(Gas.Tritium);
Expand Down
6 changes: 6 additions & 0 deletions Content.Server/Atmos/Reactions/PlasmaFireReaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ public sealed partial class PlasmaFireReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
// WD EDIT START
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;
// WD EDIT END

var energyReleased = 0f;
var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
var temperature = mixture.Temperature;
Expand Down
6 changes: 6 additions & 0 deletions Content.Server/Atmos/Reactions/TritiumFireReaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ public sealed partial class TritiumFireReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
// WD EDIT START
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;
// WD EDIT END

var energyReleased = 0f;
var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
var temperature = mixture.Temperature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ public sealed partial class GasLeakRuleComponent : Component
Gas.Plasma,
Gas.Tritium,
Gas.Frezon,
Gas.WaterVapor, // the fog
Gas.WaterVapor,
// WD EDIT START
Gas.BZ,
Gas.Hydrogen,
Gas.Halon,
// WD EDIT END
};

/// <summary>
Expand Down
52 changes: 52 additions & 0 deletions Content.Server/_White/Atmos/Reactions/BZProductionReaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Content.Server.Atmos;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;

namespace Content.Server._White.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
@@ -0,0 +1,40 @@
using Content.Server.Atmos;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;

namespace Content.Server._White.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);

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

namespace Content.Server._White.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);

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;
}
}
Loading

0 comments on commit 0cfbe74

Please sign in to comment.