Esempio n. 1
0
        /// <summary>
        /// Heals damage caused by lack of blood reagent by consume reagent
        /// </summary>
        /// <param name="reagentMix">Reagent mix to consume reagent from</param>
        /// <param name="amount">Amount to consume</param>
        public void OxyHeal(ReagentMix reagentMix, float amount)
        {
            if (Oxy <= 0)
            {
                return;
            }
            var toConsume = Mathf.Min(amount, Oxy * bloodReagentConsumed * bloodThroughput);

            AffectDamage(-reagentMix.Subtract(requiredReagent, toConsume) / bloodReagentConsumed * bloodThroughput, (int)DamageType.Oxy);
        }
Esempio n. 2
0
        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;
            }
        }
    public virtual void PossibleReaction(BodyPart sender, ReagentMix reagentMix, float limitedreactionAmount)
    {
        foreach (var ingredient in ingredients.m_dict)
        {
            reagentMix.Subtract(ingredient.Key, limitedreactionAmount * ingredient.Value);
        }

        foreach (var result in results.m_dict)
        {
            var reactionResult = limitedreactionAmount * result.Value;
            reagentMix.Add(result.Key, reactionResult);
        }

        foreach (var effect in effects)
        {
            effect.Apply(sender, limitedreactionAmount);
        }
    }