Only auto-enable internals when necessary (#28248)

* Only auto-enable internals when necessary

* Add toxic gas check

* Rename Any -> AnyPositive
This commit is contained in:
Leon Friedrich
2024-05-31 14:28:11 +12:00
committed by GitHub
parent dee9634c01
commit 54337911d3
16 changed files with 189 additions and 34 deletions

View File

@@ -3,6 +3,7 @@ using Content.Server.Atmos.EntitySystems;
using Content.Server.Body.Components;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Chemistry.Components;
using Content.Shared.Clothing;
using Content.Shared.Inventory.Events;
@@ -77,23 +78,32 @@ public sealed class LungSystem : EntitySystem
if (!_solutionContainerSystem.ResolveSolution(uid, lung.SolutionName, ref lung.Solution, out var solution))
return;
foreach (var gas in Enum.GetValues<Gas>())
GasToReagent(lung.Air, solution);
_solutionContainerSystem.UpdateChemicals(lung.Solution.Value);
}
private void GasToReagent(GasMixture gas, Solution solution)
{
foreach (var gasId in Enum.GetValues<Gas>())
{
var i = (int) gas;
var moles = lung.Air[i];
var i = (int) gasId;
var moles = gas[i];
if (moles <= 0)
continue;
var reagent = _atmosphereSystem.GasReagents[i];
if (reagent is null) continue;
if (reagent is null)
continue;
var amount = moles * Atmospherics.BreathMolesToReagentMultiplier;
solution.AddReagent(reagent, amount);
// We don't remove the gas from the lung mix,
// that's the responsibility of whatever gas is being metabolized.
// Most things will just want to exhale again.
}
}
_solutionContainerSystem.UpdateChemicals(lung.Solution.Value);
public Solution GasToReagent(GasMixture gas)
{
var solution = new Solution();
GasToReagent(gas, solution);
return solution;
}
}