예제 #1
0
    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);
            breathGasMix.AddGas(Gas.CarbonDioxide, oxygenUsed);
        }

        gasMix          += breathGasMix;
        container.GasMix = gasMix;

        return(oxygenUsed > 0);
    }
예제 #2
0
        public void React(GasMix gasMix, MetaDataNode node)
        {
            var oxyMoles = gasMix.GetMoles(Gas.Oxygen);

            gasMix.AddGas(Gas.Plasma, oxyMoles);
            gasMix.RemoveGas(Gas.Oxygen, oxyMoles);
        }
예제 #3
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);
        }
예제 #4
0
        public float React(ref GasMix gasMix, Vector3 tilePos)
        {
            gasMix.AddGas(Gas.Plasma, 1f);

            gasMix.RemoveGas(Gas.Oxygen, 1f);

            return(0f);
        }
예제 #5
0
 /// <summary>
 /// Takes reagents from blood and puts them into a GasMix as gases
 /// </summary>
 public void GasExchangeFromBlood(GasMix atmos, ReagentMix blood, ReagentMix toProcess)
 {
     foreach (var Reagent in toProcess.reagents.m_dict)
     {
         blood.Remove(Reagent.Key, Reagent.Value);
         if (!canBreathAnywhere)
         {
             atmos.AddGas(GAS2ReagentSingleton.Instance.GetReagentToGas(Reagent.Key), Reagent.Value);
         }
     }
 }
예제 #6
0
        /// <summary>
        /// Takes reagents from blood and puts them into a GasMix as gases
        /// </summary>
        public void GasExchangeFromBlood(GasMix atmos, ReagentMix blood, ReagentMix toProcess)
        {
            foreach (var reagent in toProcess.reagents.m_dict)
            {
                blood.Remove(reagent.Key, float.MaxValue);

                if (canBreathAnywhere || Gas.ReagentToGas.TryGetValue(reagent.Key, out var gas) == false)
                {
                    continue;
                }

                atmos.AddGas(gas, reagent.Value);
            }
        }
예제 #7
0
        private void ModeScrub()
        {
            // Scrub out a portion of each specified gas.
            // If all these gases exceed transfer amount, reduce each gas scrub mole count proportionally.

            float scrubbableMolesAvailable = 0;

            lock (metaNode.GasMix.GasesArray)                         //no Double lock
            {
                foreach (GasValues gas in metaNode.GasMix.GasesArray) //doesn't appear to modify list while iterating
                {
                    if (FilteredGases.Contains(gas.GasSO))
                    {
                        scrubbingGasMoles[gas.GasSO] = gas.Moles * (IsExpandedRange ? 0.05f : 0.20f) * Effectiveness;
                        scrubbableMolesAvailable    += scrubbingGasMoles[gas.GasSO];
                    }
                }
            }

            if (scrubbableMolesAvailable.Approx(0))
            {
                return;                                                 // No viable gases found
            }
            float molesToTransfer = scrubbableMolesAvailable.Clamp(0, nominalMolesTransferCap * Effectiveness);
            float ratio           = molesToTransfer / scrubbableMolesAvailable;

            ratio = ratio.Clamp(0, 1);

            // actual scrubbing
            for (int i = 0; i < Gas.Gases.Count; i++)
            {
                GasSO gas            = Gas.Gases[i];
                float transferAmount = scrubbingGasMoles[i] * ratio;
                if (transferAmount.Approx(0))
                {
                    continue;
                }

                metaNode.GasMix.RemoveGas(gas, transferAmount);
                if (selfSufficient == false)
                {
                    pipeMix.AddGas(gas, transferAmount);
                }
            }
            Array.Clear(scrubbingGasMoles, 0, scrubbingGasMoles.Length);
        }
예제 #8
0
        public void React(GasMix gasMix, Vector3 tilePos, Matrix matrix)
        {
            gasMix.AddGas(Gas.Plasma, 1f);

            gasMix.RemoveGas(Gas.Oxygen, 1f);
        }