Optimize allocations in MetabolismComponent and TileAtmosphere

This commit is contained in:
Pieter-Jan Briers
2020-12-22 18:28:54 +01:00
parent 9a3dee2042
commit 8e8594063d
2 changed files with 8 additions and 8 deletions

View File

@@ -145,20 +145,20 @@ namespace Content.Server.GameObjects.Components.Metabolism
private float SuffocatingPercentage()
{
var percentages = new float[Atmospherics.TotalNumberOfGases];
var total = 0f;
foreach (var (gas, deficit) in DeficitGases)
{
if (!NeedsGases.TryGetValue(gas, out var needed))
var lack = 1f;
if (NeedsGases.TryGetValue(gas, out var needed))
{
percentages[(int) gas] = 1;
continue;
lack = deficit / needed;
}
percentages[(int) gas] = deficit / needed;
total += lack / Atmospherics.TotalNumberOfGases;
}
return percentages.Average();
return total;
}
private float GasProducedMultiplier(Gas gas, float usedAverage)