예제 #1
0
        /// <summary>
        /// Add to the current EVA amount
        /// </summary>
        /// <param name="name"></param>
        /// <param name="amount"></param>
        /// <returns>Returns the amount of EVA LS after adding</returns>
        public static double AddEVAAmount(string name, double amount, EVA_Resource choice)
        {
            try
            {
                switch (choice)
                {
                case EVA_Resource.LifeSupport:
                    evals_info[name].ls_current =
                        Math.Min(evals_info[name].ls_current + amount,
                                 evals_info[name].ls_max);
                    break;

                case EVA_Resource.Propellant:
                    evals_info[name].prop_current =
                        Math.Min(evals_info[name].prop_current + amount,
                                 evals_info[name].prop_max);
                    break;
                }
            }
            catch (KeyNotFoundException e)
            {
                Log("AddEVAAmount Exception thrown: Kerbal " + name + " not found to update tracking!");
                Log(e.ToString());
            }

            return(evals_info[name].ls_current);
        }
예제 #2
0
        /// <summary>
        /// Returns the current maximum EVA LifeSupport given the state
        /// of the astronaut complex
        /// </summary>
        /// <param name="choice">Which resource to return</param>
        /// <returns></returns>
        public static double MaxAllowedEVA(EVA_Resource choice, string astro_level = "")
        {
            // Default astro_level value is "" instead of null
            // to capture the case where the input to this method
            // is a missing ConfigNode value.

            float lvl;

            if (astro_level == "")
            {
                lvl = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex);
            }
            else
            {
                lvl = Convert.ToSingle(astro_level);
            }

            Util.Log("Astronaut Complex Level " + lvl);

            // If Astronaut Complex is fully upgraded, EVA LS gets higher value

            if (choice == EVA_Resource.Propellant)
            {
                if (lvl == 1.0f)
                {
                    return(Config.EVA_PROP_LVL_3);
                }
                else
                {
                    return(Config.EVA_PROP_LVL_2);
                }
            }
            else if (choice == EVA_Resource.LifeSupport)
            {
                if (lvl == 0f)
                {
                    return(Config.EVA_LS_LVL_1);
                }
                else if (lvl == 0.5f)
                {
                    return(Config.EVA_LS_LVL_2);
                }
                else
                {
                    return(Config.EVA_LS_LVL_3);
                }
            }

            Util.Log("CheckThis -> Incorrect index, throwing exception");
            throw new ArgumentException("Index for SimpleSurvival Util.CurrentEVAMax must be [0,1].");
        }
예제 #3
0
        /// <summary>
        /// Set the amount of EVA LifeSupport a Kerbal currently has
        /// </summary>
        /// <param name="name">The Kerbal's name</param>
        /// <param name="amount">The current amount</param>
        public static void SetCurrentAmount(string name, double amount, EVA_Resource choice)
        {
            try
            {
                switch (choice)
                {
                case EVA_Resource.LifeSupport:
                    evals_info[name].ls_current = amount;
                    break;

                case EVA_Resource.Propellant:
                    evals_info[name].prop_current = amount;
                    break;
                }
            }
            catch (KeyNotFoundException e)
            {
                Log("SetCurrentEVAAmount Exception thrown: Kerbal " + name + " not found to update tracking!");
                Log(e.ToString());
            }
        }