Exemple #1
0
		// --- SCIENCE DATA ---------------------------------------------------------

		// return true if there is experiment data on the vessel
		public static bool HasData(Vessel v)
		{
			// stock science system
			if (!Features.Science)
			{
				// if vessel is loaded
				if (v.loaded)
				{
					// iterate over all science containers/experiments and return true if there is data
					return Lib.HasModule<IScienceDataContainer>(v, k => k.GetData().Length > 0);
				}
				// if not loaded
				else
				{
					// iterate over all science containers/experiments proto modules and return true if there is data
					return Lib.HasModule(v.protoVessel, "ModuleScienceContainer", k => k.moduleValues.GetNodes("ScienceData").Length > 0)
						|| Lib.HasModule(v.protoVessel, "ModuleScienceExperiment", k => k.moduleValues.GetNodes("ScienceData").Length > 0);
				}
			}
			// our own science system
			else
			{
				return DB.Vessel(v).drive.files.Count > 0;
			}
		}
Exemple #2
0
 // return true if it make sense to trigger a malfunction on the vessel
 public static bool CanMalfunction(Vessel v)
 {
     if (v.loaded)
     {
         return(Lib.HasModule <Reliability>(v, k => !k.broken));
     }
     else
     {
         return(Lib.HasModule(v.protoVessel, "Reliability", k => !Lib.Proto.GetBool(k, "broken")));
     }
 }
Exemple #3
0
        public Comforts(Vessel v, 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;

            // if loaded
            if (v.loaded)
            {
                // scan parts for comfort
                foreach (Comfort c in Lib.FindModules <Comfort>(v))
                {
                    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;
                    }
                }

                // scan parts for gravity ring
                if (ResourceCache.Info(v, "ElectricCharge").amount >= 0.01)
                {
                    firm_ground |= Lib.HasModule <GravityRing>(v, k => k.deployed);
                }
            }
            // if not loaded
            else
            {
                // scan parts for comfort
                foreach (ProtoPartModuleSnapshot m in Lib.FindModules(v.protoVessel, "Comfort"))
                {
                    switch (Lib.Proto.GetString(m, "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;
                    }
                }

                // scan parts for gravity ring
                if (ResourceCache.Info(v, "ElectricCharge").amount >= 0.01)
                {
                    firm_ground |= Lib.HasModule(v.protoVessel, "GravityRing", k => Lib.Proto.GetBool(k, "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;
            }
            if (plants)
            {
                factor += PreferencesComfort.Instance.plants;
            }
            factor = Lib.Clamp(factor, 0.1, 1.0);
        }
Exemple #4
0
        public Comforts(Vessel v, 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;

            // if loaded
            if (v.loaded)
            {
                // scan parts for comfort
                foreach (Comfort c in Lib.FindModules <Comfort>(v))
                {
                    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;
                    }
                }

                // scan parts for gravity ring
                if (ResourceCache.Info(v, "ElectricCharge").amount >= 0.01)
                {
                    this.firm_ground |= Lib.HasModule <GravityRing>(v, k => k.deployed);
                }
            }
            // if not loaded
            else
            {
                // scan parts for comfort
                foreach (ProtoPartModuleSnapshot m in Lib.FindModules(v.protoVessel, "Comfort"))
                {
                    switch (Lib.Proto.GetString(m, "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;
                    }
                }

                // scan parts for gravity ring
                if (ResourceCache.Info(v, "ElectricCharge").amount >= 0.01)
                {
                    this.firm_ground |= Lib.HasModule(v.protoVessel, "GravityRing", k => Lib.Proto.GetBool(k, "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);
        }