Adds tritium fire reaction and water vapor, fix gas reactions (#1623)
hehe Tritfire go BRRRR
This commit is contained in:
committed by
GitHub
parent
cc9f16e738
commit
b5a976b173
@@ -35,6 +35,13 @@ namespace Content.Server.Atmos
|
||||
[ViewVariables]
|
||||
public float LastShare { get; private set; } = 0;
|
||||
|
||||
[ViewVariables]
|
||||
public readonly Dictionary<GasReaction, float> ReactionResults = new Dictionary<GasReaction, float>()
|
||||
{
|
||||
// We initialize the dictionary here.
|
||||
{ GasReaction.Fire, 0f }
|
||||
};
|
||||
|
||||
[ViewVariables]
|
||||
public float HeatCapacity
|
||||
{
|
||||
@@ -107,8 +114,6 @@ namespace Content.Server.Atmos
|
||||
}
|
||||
}
|
||||
|
||||
public float ReactionResultFire { get; set; }
|
||||
|
||||
[ViewVariables]
|
||||
public float ThermalEnergy => Temperature * HeatCapacity;
|
||||
|
||||
@@ -452,19 +457,25 @@ namespace Content.Server.Atmos
|
||||
temperature < prototype.MinimumTemperatureRequirement)
|
||||
continue;
|
||||
|
||||
var doReaction = true;
|
||||
for (var i = 0; i < prototype.MinimumRequirements.Length; i++)
|
||||
{
|
||||
if(i > Atmospherics.TotalNumberOfGases)
|
||||
throw new IndexOutOfRangeException("Reaction Gas Minimum Requirements Array Prototype exceeds total number of gases!");
|
||||
|
||||
var req = prototype.MinimumRequirements[i];
|
||||
if (GetMoles(i) < req)
|
||||
continue;
|
||||
|
||||
reaction = prototype.React(this, holder);
|
||||
if(reaction.HasFlag(ReactionResult.StopReactions))
|
||||
break;
|
||||
if (!(GetMoles(i) < req)) continue;
|
||||
doReaction = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!doReaction)
|
||||
continue;
|
||||
|
||||
reaction = prototype.React(this, holder);
|
||||
if(reaction.HasFlag(ReactionResult.StopReactions))
|
||||
break;
|
||||
}
|
||||
|
||||
return reaction;
|
||||
|
||||
@@ -16,6 +16,11 @@ namespace Content.Server.Atmos.Reactions
|
||||
StopReactions = 2,
|
||||
}
|
||||
|
||||
public enum GasReaction : byte
|
||||
{
|
||||
Fire = 0,
|
||||
}
|
||||
|
||||
[Prototype("gasReaction")]
|
||||
public class GasReactionPrototype : IPrototype, IIndexedPrototype
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using CannyFastMath;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Shared.Atmos;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.Atmos.Reactions
|
||||
@@ -53,7 +54,7 @@ namespace Content.Server.Atmos.Reactions
|
||||
|
||||
energyReleased += Atmospherics.FirePhoronEnergyReleased * (phoronBurnRate);
|
||||
|
||||
mixture.ReactionResultFire += (phoronBurnRate) * (1 + oxygenBurnRate);
|
||||
mixture.ReactionResults[GasReaction.Fire] += (phoronBurnRate) * (1 + oxygenBurnRate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,15 +70,15 @@ namespace Content.Server.Atmos.Reactions
|
||||
temperature = mixture.Temperature;
|
||||
if (temperature > Atmospherics.FireMinimumTemperatureToExist)
|
||||
{
|
||||
location.HotspotExpose(temperature, Atmospherics.CellVolume);
|
||||
location.HotspotExpose(temperature, mixture.Volume);
|
||||
|
||||
// TODO ATMOS Expose temperature all items on cell
|
||||
|
||||
location.TemperatureExpose(mixture, temperature, Atmospherics.CellVolume);
|
||||
location.TemperatureExpose(mixture, temperature, mixture.Volume);
|
||||
}
|
||||
}
|
||||
|
||||
return mixture.ReactionResultFire != 0 ? ReactionResult.Reacting : ReactionResult.NoReaction;
|
||||
return mixture.ReactionResults[GasReaction.Fire] != 0 ? ReactionResult.Reacting : ReactionResult.NoReaction;
|
||||
}
|
||||
|
||||
public void ExposeData(ObjectSerializer serializer)
|
||||
|
||||
78
Content.Server/Atmos/Reactions/TritiumFireReaction.cs
Normal file
78
Content.Server/Atmos/Reactions/TritiumFireReaction.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
#nullable enable
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Shared.Atmos;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.Atmos.Reactions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class TritiumFireReaction : IGasReactionEffect
|
||||
{
|
||||
public void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
}
|
||||
|
||||
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder)
|
||||
{
|
||||
var energyReleased = 0f;
|
||||
var oldHeatCapacity = mixture.HeatCapacity;
|
||||
var temperature = mixture.Temperature;
|
||||
var location = holder as TileAtmosphere;
|
||||
mixture.ReactionResults[GasReaction.Fire] = 0f;
|
||||
var burnedFuel = 0f;
|
||||
var initialTrit = mixture.GetMoles(Gas.Tritium);
|
||||
|
||||
if (mixture.GetMoles(Gas.Oxygen) < initialTrit ||
|
||||
Atmospherics.MinimumTritiumOxyburnEnergy > (temperature * oldHeatCapacity))
|
||||
{
|
||||
burnedFuel = mixture.GetMoles(Gas.Oxygen) / Atmospherics.TritiumBurnOxyFactor;
|
||||
if (burnedFuel > initialTrit)
|
||||
burnedFuel = initialTrit;
|
||||
|
||||
mixture.AdjustMoles(Gas.Tritium, -burnedFuel);
|
||||
}
|
||||
else
|
||||
{
|
||||
burnedFuel = initialTrit;
|
||||
mixture.SetMoles(Gas.Tritium, mixture.GetMoles(Gas.Tritium ) * (1 - 1 / Atmospherics.TritiumBurnTritFactor));
|
||||
mixture.AdjustMoles(Gas.Oxygen, -mixture.GetMoles(Gas.Tritium));
|
||||
energyReleased += (Atmospherics.FireHydrogenEnergyReleased * burnedFuel * (Atmospherics.TritiumBurnTritFactor - 1));
|
||||
}
|
||||
|
||||
if (burnedFuel > 0)
|
||||
{
|
||||
energyReleased += (Atmospherics.FireHydrogenEnergyReleased * burnedFuel);
|
||||
|
||||
// TODO ATMOS Radiation pulse here!
|
||||
|
||||
// Conservation of mass is important.
|
||||
mixture.AdjustMoles(Gas.WaterVapor, burnedFuel);
|
||||
|
||||
mixture.ReactionResults[GasReaction.Fire] += burnedFuel;
|
||||
}
|
||||
|
||||
if (energyReleased > 0)
|
||||
{
|
||||
var newHeatCapacity = mixture.HeatCapacity;
|
||||
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
|
||||
mixture.Temperature = ((temperature * oldHeatCapacity + energyReleased) / newHeatCapacity);
|
||||
}
|
||||
|
||||
if (location != null)
|
||||
{
|
||||
temperature = mixture.Temperature;
|
||||
if (temperature > Atmospherics.FireMinimumTemperatureToExist)
|
||||
{
|
||||
location.HotspotExpose(temperature, mixture.Volume);
|
||||
|
||||
// TODO ATMOS Expose temperature all items on cell
|
||||
|
||||
location.TemperatureExpose(mixture, temperature, mixture.Volume);
|
||||
}
|
||||
}
|
||||
|
||||
return mixture.ReactionResults[GasReaction.Fire] != 0 ? ReactionResult.Reacting : ReactionResult.NoReaction;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Content.Server.Atmos.Reactions;
|
||||
using Content.Server.GameObjects.Components.Atmos;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Interfaces;
|
||||
@@ -686,7 +687,7 @@ namespace Content.Server.Atmos
|
||||
|
||||
if (Hotspot.Bypassing)
|
||||
{
|
||||
Hotspot.Volume = Air.ReactionResultFire * Atmospherics.FireGrowthRate;
|
||||
Hotspot.Volume = Air.ReactionResults[GasReaction.Fire] * Atmospherics.FireGrowthRate;
|
||||
Hotspot.Temperature = Air.Temperature;
|
||||
}
|
||||
else
|
||||
@@ -697,7 +698,7 @@ namespace Content.Server.Atmos
|
||||
affected.Temperature = Hotspot.Temperature;
|
||||
affected.React(this);
|
||||
Hotspot.Temperature = affected.Temperature;
|
||||
Hotspot.Volume = affected.ReactionResultFire * Atmospherics.FireGrowthRate;
|
||||
Hotspot.Volume = affected.ReactionResults[GasReaction.Fire] * Atmospherics.FireGrowthRate;
|
||||
AssumeAir(affected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,8 +143,12 @@ namespace Content.Shared.Atmos
|
||||
/// <summary>
|
||||
/// Total number of gases. Increase this if you want to add more!
|
||||
/// </summary>
|
||||
public const int TotalNumberOfGases = 5;
|
||||
public const int TotalNumberOfGases = 6;
|
||||
|
||||
/// <summary>
|
||||
/// Amount of heat released per mole of burnt hydrogen or tritium (hydrogen isotope)
|
||||
/// </summary>
|
||||
public const float FireHydrogenEnergyReleased = 560000f;
|
||||
public const float FireMinimumTemperatureToExist = T0C + 100f;
|
||||
public const float FireMinimumTemperatureToSpread = T0C + 150f;
|
||||
public const float FireSpreadRadiosityScale = 0.85f;
|
||||
@@ -159,6 +163,14 @@ namespace Content.Shared.Atmos
|
||||
public const float PhoronOxygenFullburn = 10f;
|
||||
public const float PhoronBurnRateDelta = 9f;
|
||||
|
||||
/// <summary>
|
||||
/// This is calculated to help prevent singlecap bombs (Overpowered tritium/oxygen single tank bombs)
|
||||
/// </summary>
|
||||
public const float MinimumTritiumOxyburnEnergy = 2000000f;
|
||||
|
||||
public const float TritiumBurnOxyFactor = 100f;
|
||||
public const float TritiumBurnTritFactor = 10f;
|
||||
|
||||
/// <summary>
|
||||
/// Determines at what pressure the ultra-high pressure red icon is displayed.
|
||||
/// </summary>
|
||||
@@ -208,5 +220,6 @@ namespace Content.Shared.Atmos
|
||||
CarbonDioxide = 2,
|
||||
Phoron = 3,
|
||||
Tritium = 4,
|
||||
WaterVapor = 5,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,3 +31,11 @@
|
||||
gasOverlaySprite: /Textures/Effects/atmospherics.rsi
|
||||
gasOverlayState: tritium
|
||||
color: 13FF4B
|
||||
|
||||
- type: gas
|
||||
id: 5
|
||||
name: Water Vapor
|
||||
specificHeat: 40
|
||||
gasOverlaySprite: /Textures/Effects/atmospherics.rsi
|
||||
gasOverlayState: water_vapor
|
||||
color: bffffd
|
||||
|
||||
@@ -9,3 +9,16 @@
|
||||
- 0.01 # phoron
|
||||
effects:
|
||||
- !type:PhoronFireReaction {}
|
||||
|
||||
- type: gasReaction
|
||||
id: TritiumFire
|
||||
priority: -1
|
||||
minimumTemperature: 373.149 # Same as Atmospherics.FireMinimumTemperatureToExist
|
||||
minimumRequirements: # In this case, same as minimum mole count.
|
||||
- 0.01 # oxygen
|
||||
- 0 # nitrogen
|
||||
- 0 # carbon dioxide
|
||||
- 0 # phoron
|
||||
- 0.01 # tritium
|
||||
effects:
|
||||
- !type:TritiumFireReaction {}
|
||||
|
||||
Reference in New Issue
Block a user