示例#1
0
        public Comforts(List <Part> parts, bool env_firm_ground, bool env_not_alone, bool env_call_home)
        {
            // environment factors
            firm_ground = env_firm_ground;
            not_alone   = env_not_alone;
            call_home   = env_call_home;

            // for each parts
            foreach (Part p in parts)
            {
                // for each modules in part
                foreach (PartModule m in p.Modules)
                {
                    // skip disabled modules
                    if (!m.isEnabled)
                    {
                        continue;
                    }

                    // comfort
                    if (m.moduleName == "Comfort")
                    {
                        Comfort c = m as Comfort;
                        switch (c.bonus)
                        {
                        case "firm-ground": firm_ground = true; break;

                        case "not-alone": not_alone = true; break;

                        case "call-home": call_home = true; break;

                        case "exercise": exercise = true; break;

                        case "panorama": panorama = true; break;

                        case "plants": plants = true; break;
                        }
                    }
                    // gravity ring
                    // - ignoring if ec is present or not here
                    else if (m.moduleName == "GravityRing")
                    {
                        GravityRing ring = m as GravityRing;
                        firm_ground |= ring.deployed;
                    }
                }
            }

            // calculate factor
            factor = 0.1;
            if (firm_ground)
            {
                factor += PreferencesComfort.Instance.firmGround;
            }
            if (not_alone)
            {
                factor += PreferencesComfort.Instance.notAlone;
            }
            if (call_home)
            {
                factor += PreferencesComfort.Instance.callHome;
            }
            if (exercise)
            {
                factor += PreferencesComfort.Instance.exercise;
            }
            if (panorama)
            {
                factor += PreferencesComfort.Instance.panorama;
            }
            factor = Lib.Clamp(factor, 0.1, 1.0);
        }
示例#2
0
        public Comforts(List <Part> parts, bool firm_ground, bool not_alone, bool call_home)
        {
            // environment factors
            this.firm_ground = firm_ground;
            this.not_alone   = not_alone;
            this.call_home   = call_home;

            // for each parts
            foreach (Part p in parts)
            {
                // for each modules in part
                foreach (PartModule m in p.Modules)
                {
                    // skip disabled modules
                    if (!m.isEnabled)
                    {
                        continue;
                    }

                    // comfort
                    if (m.moduleName == "Comfort")
                    {
                        Comfort c = m as Comfort;
                        switch (c.bonus)
                        {
                        case "firm-ground": this.firm_ground = true; break;

                        case "not-alone":   this.not_alone = true;   break;

                        case "call-home":   this.call_home = true;   break;

                        case "exercise":    this.exercise = true;    break;

                        case "panorama":    this.panorama = true;    break;
                        }
                    }
                    // gravity ring
                    // - ignoring if ec is present or not here
                    else if (m.moduleName == "GravityRing")
                    {
                        GravityRing ring = m as GravityRing;
                        this.firm_ground |= ring.deployed;
                    }
                }
            }

            // calculate factor
            factor = 0.1;
            if (firm_ground)
            {
                factor += Settings.ComfortFirmGround;
            }
            if (not_alone)
            {
                factor += Settings.ComfortNotAlone;
            }
            if (call_home)
            {
                factor += Settings.ComfortCallHome;
            }
            if (exercise)
            {
                factor += Settings.ComfortExercise;
            }
            if (panorama)
            {
                factor += Settings.ComfortPanorama;
            }
            factor = Lib.Clamp(factor, 0.1, 1.0);
        }