private bool Breathe(IGasMixContainer node) { breatheCooldown--; //not timebased, but tickbased if (breatheCooldown > 0) { return(false); } // if no internal breathing is possible, get the from the surroundings IGasMixContainer container = GetInternalGasMix() ?? node; GasMix gasMix = container.GasMix; GasMix breathGasMix = gasMix.RemoveVolume(AtmosConstants.BREATH_VOLUME, true); float oxygenUsed = HandleBreathing(breathGasMix); if (oxygenUsed > 0) { breathGasMix.RemoveGas(Gas.Oxygen, oxygenUsed); node.GasMix.AddGas(Gas.CarbonDioxide, oxygenUsed); registerTile.Matrix.MetaDataLayer.UpdateSystemsAt(registerTile.LocalPositionClient); } gasMix += breathGasMix; container.GasMix = gasMix; return(oxygenUsed > 0); }
public void React(GasMix gasMix, Vector3 tilePos, Matrix matrix) { var oxyMoles = gasMix.GetMoles(Gas.Oxygen); gasMix.AddGas(Gas.Plasma, oxyMoles); gasMix.RemoveGas(Gas.Oxygen, oxyMoles); }
public void React(GasMix gasMix, MetaDataNode node) { var oxyMoles = gasMix.GetMoles(Gas.Oxygen); gasMix.AddGas(Gas.Plasma, oxyMoles); gasMix.RemoveGas(Gas.Oxygen, oxyMoles); }
public float React(ref GasMix gasMix, Vector3 tilePos) { gasMix.AddGas(Gas.Plasma, 1f); gasMix.RemoveGas(Gas.Oxygen, 1f); return(0f); }
private bool Breathe(IGasMixContainer node) { breatheCooldown--; //not timebased, but tickbased if (breatheCooldown > 0) { return(false); } // if no internal breathing is possible, get the from the surroundings IGasMixContainer container = GetInternalGasMix() ?? node; GasMix gasMix = container.GasMix; float plasmaConsumed = 0; bool carbonDioxideInhaled = false; bool gasFiltered = false; float oxygenUsed = HandleBreathingOxygen(gasMix); if (isWearingGasMask()) { gasFiltered = HandleWearingGasMask(gasMix); } if (gasFiltered == false) { plasmaConsumed = HandleBreathingPlasma(gasMix); carbonDioxideInhaled = HandleBreathingCarbonDioxide(gasMix); } if (oxygenUsed > 0) { gasMix.RemoveGas(Gas.Oxygen, oxygenUsed); node.GasMix.AddGas(Gas.CarbonDioxide, oxygenUsed); registerTile.Matrix.MetaDataLayer.UpdateSystemsAt(registerTile.LocalPositionClient, SystemType.AtmosSystem); } if (plasmaConsumed > 0) { gasMix.RemoveGas(Gas.Plasma, plasmaConsumed); registerTile.Matrix.MetaDataLayer.UpdateSystemsAt(registerTile.LocalPositionClient, SystemType.AtmosSystem); } if (oxygenUsed > 0 || plasmaConsumed > 0 || carbonDioxideInhaled) { return(true); } return(false); }
/// <summary> /// Takes gases from a GasMix and puts them into blood as a reagent /// </summary> public void GasExchangeToBlood(GasMix atmos, ReagentMix blood, ReagentMix toProcess) { foreach (var Reagent in toProcess) { blood.Add(Reagent.Key, Reagent.Value); if (!canBreathAnywhere) { atmos.RemoveGas(GAS2ReagentSingleton.Instance.GetReagentToGas(Reagent.Key), Reagent.Value); } } }
public void TransferSpecifiedTo(MixAndVolume toTransfer, Gas?SpecifiedGas = null, Chemistry.Reagent Reagent = null, Vector2?amount = null) { if (SpecifiedGas != null) { float ToRemovegas = 0; var Gas = SpecifiedGas.GetValueOrDefault(Atmospherics.Gas.Oxygen); if (amount != null) { ToRemovegas = amount.Value.y; } else { ToRemovegas = gasMix.Gases[Gas]; } float TransferredEnergy = ToRemovegas * Gas.MolarHeatCapacity * gasMix.Temperature; gasMix.RemoveGas(Gas, ToRemovegas); float CachedInternalEnergy = toTransfer.InternalEnergy + TransferredEnergy; //- TransferredEnergy; toTransfer.gasMix.AddGas(Gas, ToRemovegas); toTransfer.gasMix.InternalEnergy = CachedInternalEnergy; } if (Reagent != null) { float ToRemovegas = 0; if (amount != null) { ToRemovegas = amount.Value.x; } else { ToRemovegas = Mix[Reagent]; } float TransferredEnergy = ToRemovegas * Reagent.heatDensity * Mix.Temperature; float CachedInternalEnergy = Mix.InternalEnergy; Mix.Subtract(Reagent, ToRemovegas); Mix.InternalEnergy = CachedInternalEnergy - TransferredEnergy; CachedInternalEnergy = toTransfer.Mix.InternalEnergy; toTransfer.Mix.Add(Reagent, ToRemovegas); CachedInternalEnergy += TransferredEnergy; toTransfer.Mix.InternalEnergy = CachedInternalEnergy; } }
private bool Breathe(IGasMixContainer node) { // if no internal breathing is possible, get the from the surroundings IGasMixContainer container = GetInternalGasMix() ?? node; GasMix gasMix = container.GasMix; GasMix breathGasMix = gasMix.RemoveVolume(AtmosConstants.BREATH_VOLUME, true); float oxygenUsed = HandleBreathing(breathGasMix); if (oxygenUsed > 0) { breathGasMix.RemoveGas(Gas.Oxygen, oxygenUsed); breathGasMix.AddGas(Gas.CarbonDioxide, oxygenUsed); } gasMix += breathGasMix; container.GasMix = gasMix; return(oxygenUsed > 0); }
public void React(GasMix gasMix, Vector3 tilePos, Matrix matrix) { gasMix.AddGas(Gas.Plasma, 1f); gasMix.RemoveGas(Gas.Oxygen, 1f); }
private bool HandleWearingGasMask(GasMix gasMix) { bool filtered = false; // if there is too much CO2 in the air if (gasMix.GetMoles(Gas.CarbonDioxide) >= 30) { GasMix gasMix2 = gasMix; gasMix2.RemoveGas(Gas.CarbonDioxide, 30); HandleBreathingCarbonDioxide(gasMix2); filtered = true; } // if there is too much plasma in the air if (gasMix.GetMoles(Gas.Plasma) >= 25) { GasMix gasMix2 = gasMix; gasMix2.RemoveGas(Gas.Plasma, 25); float plasmaBreathedWithMask = HandleBreathingPlasma(gasMix2); if (plasmaBreathedWithMask > 0) { gasMix.RemoveGas(Gas.Plasma, plasmaBreathedWithMask); registerTile.Matrix.MetaDataLayer.UpdateSystemsAt(registerTile.LocalPositionClient, SystemType.AtmosSystem); } filtered = true; } //if there's not enough to cause the plasma or CO2 warnings, skip the breathe messages if ((gasMix.GetMoles(Gas.Plasma) < PLASMA_WARNING_LEVEL && gasMix.GetMoles(Gas.Plasma) > 0) || (gasMix.GetMoles(Gas.CarbonDioxide) < CARBON_DIOXIDE_WARNING_LEVEL && gasMix.GetMoles(Gas.CarbonDioxide) > 0)) { return(true); } //if somehow both are 0 return false if (gasMix.GetMoles(Gas.Plasma) == 0 && gasMix.GetMoles(Gas.CarbonDioxide) == 0) { return(false); } if (DMMath.Prob(90)) { return(true); } if (!filtered) { // 10% chance of message var theirPronoun = gameObject.Player() != null ? gameObject.Player().Script.characterSettings.TheirPronoun(gameObject.Player().Script) : "its"; Chat.AddActionMsgToChat( gameObject, GasMaskFiltered.PickRandom(), string.Format( GasMaskFilteredOthers.PickRandom(), gameObject.ExpensiveName(), string.Format(plasmaLowOthersMessages.PickRandom(), gameObject.ExpensiveName(), theirPronoun)) ); return(true); } return(false); }