Atmos optimizations (#1944)
* Adds IFireAct, ITemperatureExpose * Use AtmosDirection instead of Direction for Atmos * Refactor atmos to heavily rely on arrays and bitflags. Adds F A S T M O S and reduces atmos tech debt heavily. * Optimize and fix more stuff * Kinda improve superconduction * Pipenet is a word * T U R B O M O S * Address reviews * Small optimization * Superconduct is also a word * Remove check * Cleanup tile atmosphere * Correct a comment
This commit is contained in:
committed by
GitHub
parent
3758eb1b60
commit
fb0ac3d70e
@@ -129,17 +129,21 @@ namespace Content.Server.Atmos
|
||||
[ViewVariables]
|
||||
public float Volume { get; set; }
|
||||
|
||||
public GasMixture()
|
||||
public GasMixture() : this(null)
|
||||
{
|
||||
_atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
}
|
||||
|
||||
public GasMixture(float volume)
|
||||
public GasMixture(AtmosphereSystem? atmosphereSystem)
|
||||
{
|
||||
_atmosphereSystem = atmosphereSystem ?? EntitySystem.Get<AtmosphereSystem>();
|
||||
}
|
||||
|
||||
public GasMixture(float volume, AtmosphereSystem? atmosphereSystem = null)
|
||||
{
|
||||
if (volume < 0)
|
||||
volume = 0;
|
||||
Volume = volume;
|
||||
_atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
_atmosphereSystem = atmosphereSystem ?? EntitySystem.Get<AtmosphereSystem>();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -224,12 +228,12 @@ namespace Content.Server.Atmos
|
||||
public GasMixture RemoveRatio(float ratio)
|
||||
{
|
||||
if(ratio <= 0)
|
||||
return new GasMixture(Volume);
|
||||
return new GasMixture(Volume, _atmosphereSystem);
|
||||
|
||||
if (ratio > 1)
|
||||
ratio = 1;
|
||||
|
||||
var removed = new GasMixture {Volume = Volume, Temperature = Temperature};
|
||||
var removed = new GasMixture(_atmosphereSystem) {Volume = Volume, Temperature = Temperature};
|
||||
|
||||
for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
|
||||
{
|
||||
@@ -252,7 +256,7 @@ namespace Content.Server.Atmos
|
||||
public void CopyFromMutable(GasMixture sample)
|
||||
{
|
||||
if (Immutable) return;
|
||||
sample._moles.AsSpan().CopyTo(_moles.AsSpan());
|
||||
sample._moles.CopyTo(_moles, 0);
|
||||
Temperature = sample.Temperature;
|
||||
}
|
||||
|
||||
@@ -485,8 +489,7 @@ namespace Content.Server.Atmos
|
||||
var temperature = Temperature;
|
||||
var energy = ThermalEnergy;
|
||||
|
||||
// TODO ATMOS Take reaction priority into account!
|
||||
foreach (var prototype in IoCManager.Resolve<IPrototypeManager>().EnumeratePrototypes<GasReactionPrototype>())
|
||||
foreach (var prototype in _atmosphereSystem.GasReactions)
|
||||
{
|
||||
if (energy < prototype.MinimumEnergyRequirement ||
|
||||
temperature < prototype.MinimumTemperatureRequirement)
|
||||
@@ -508,7 +511,7 @@ namespace Content.Server.Atmos
|
||||
if (!doReaction)
|
||||
continue;
|
||||
|
||||
reaction = prototype.React(this, holder);
|
||||
reaction = prototype.React(this, holder, _atmosphereSystem.EventBus);
|
||||
if(reaction.HasFlag(ReactionResult.StopReactions))
|
||||
break;
|
||||
}
|
||||
@@ -588,7 +591,7 @@ namespace Content.Server.Atmos
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var newMixture = new GasMixture()
|
||||
var newMixture = new GasMixture(_atmosphereSystem)
|
||||
{
|
||||
_moles = (float[])_moles.Clone(),
|
||||
_molesArchived = (float[])_molesArchived.Clone(),
|
||||
|
||||
Reference in New Issue
Block a user