Example #1
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);
         }
     }
 }
Example #2
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);
            }
        }
Example #3
0
        private void BloodToLiver(ReagentMix blood)
        {
            float tickPullProcessingAmnt = RelatedPart.TotalModified * processAmount;
            float drawnAmount            = 0;

            //debug.AppendLine("==== STAGE 1 || BLOOD TO PROCESSING ====");

            //figure out how much we are going to process or remove
            lock (blood.reagents)
            {
                foreach (var reagent in blood.reagents.m_dict)
                {
                    bool alcohol = Alcohols.HashAlcoholicReagents.Contains(reagent.Key);
                    bool toxic   = Toxins.Contains(reagent.Key);
                    if (alcohol || toxic)
                    {
                        float amount = Mathf.Min(tickPullProcessingAmnt, reagent.Value);
                        amount = Mathf.Min(amount,
                                           (processingContainer.MaxCapacity - processingContainer.ReagentMixTotal) - drawnAmount);
                        tempArray.Add(new Tuple <Reagent, float>(reagent.Key, amount));

                        if (processingContainer.IsFull)
                        {
                            Logger.LogTrace("Liver is full, please try again. or don't.", Category.Health);
                            break;
                        }

                        drawnAmount            += amount;
                        tickPullProcessingAmnt -= amount;
                        if (tickPullProcessingAmnt <= 0)
                        {
                            break;
                        }
                    }
                }
            }

            //debug.AppendLine($"Drawn from blood to liver: {drawnAmount}");

            //take what we are gonna process or remove, out of the blood
            foreach (Tuple <Reagent, float> reagent in tempArray)
            {
                //debug.AppendLine($"{reagent.Item2.ToString(CultureInfo.DefaultThreadCurrentCulture)} of {reagent.Item1}\n");
                processingContainer.CurrentReagentMix.Add(reagent.Item1, reagent.Item2);
                blood.Remove(reagent.Item1, reagent.Item2);
            }

            tempArray.Clear();
        }