Exemple #1
0
    private float HandleBreathing(GasMix breathGasMix)
    {
        float oxygenPressure = breathGasMix.GetPressure(Gas.Oxygen);

        float oxygenUsed = 0;

        if (oxygenPressure < OXYGEN_SAFE_MIN)
        {
            if (Random.value < 0.2)
            {
                PostToChatMessage.SendGasp(base.gameObject);
            }

            if (oxygenPressure > 0)
            {
                float ratio = 1 - oxygenPressure / OXYGEN_SAFE_MIN;

                ApplyDamage(Mathf.Min(5 * ratio, 3), DamageType.Oxy);
                bloodSystem.OxygenLevel += 30 * ratio;

                oxygenUsed = breathGasMix.GetMoles(Gas.Oxygen) * ratio;
            }
            else
            {
                ApplyDamage(3, DamageType.Oxy);
            }
        }
        else
        {
            oxygenUsed = breathGasMix.GetMoles(Gas.Oxygen);
            bloodSystem.OxygenLevel += 30;
        }

        return(oxygenUsed);
    }
Exemple #2
0
    private float HandleBreathing(GasMix breathGasMix)
    {
        float oxygenPressure = breathGasMix.GetPressure(Gas.Oxygen);

        float oxygenUsed = 0;

        if (oxygenPressure < OXYGEN_SAFE_MIN)
        {
            if (Random.value < 0.1)
            {
                PostToChatMessage.SendGasp(base.gameObject);
            }

            if (oxygenPressure > 0)
            {
                float ratio = 1 - oxygenPressure / OXYGEN_SAFE_MIN;
                bloodSystem.OxygenDamage += 1 * ratio;
                oxygenUsed = breathGasMix.GetMoles(Gas.Oxygen) * ratio;
            }
            else
            {
                bloodSystem.OxygenDamage += 1;
            }
            IsSuffocating = true;
        }
        else
        {
            oxygenUsed                = breathGasMix.GetMoles(Gas.Oxygen);
            IsSuffocating             = false;
            bloodSystem.OxygenDamage -= 2.5f;
            breatheCooldown           = 4;
        }
        return(oxygenUsed);
    }