Exemplo n.º 1
0
        internal static DMCollectScience fetchBioSurveyScience(CelestialBody body, DMScienceContainer DMScience, string Biome)
        {
            ExperimentSituations        targetSituation;
            List <ExperimentSituations> situations;
            AvailablePart aPart;
            string        name;

            name = DMUtils.availableScience["All"].FirstOrDefault(n => n.Value == DMScience).Key;
            DMUtils.DebugLog("Checking Contract Requirements");

            //Determine if the science part is available if applicable
            if (DMScience.sciPart != "None")
            {
                DMUtils.DebugLog("Checking For Part {0} Now", DMScience.sciPart);
                aPart = PartLoader.getPartInfoByName(DMScience.sciPart);
                if (aPart == null)
                {
                    return(null);
                }
                if (!ResearchAndDevelopment.PartModelPurchased(aPart))
                {
                    return(null);
                }
                DMUtils.DebugLog("Part: [{0}] Purchased; Contract Meets Requirements", aPart.name);
            }

            //Make sure our experiment is OK
            if (DMScience.exp == null)
            {
                return(null);
            }

            //Choose an acceptable experimental situation for a given science experiment
            if ((situations = DMUtils.availableSituations(DMScience.exp, DMScience.sitMask, body)).Count == 0)
            {
                return(null);
            }
            else
            {
                DMUtils.DebugLog("Acceptable Situations Found");
                targetSituation = situations[rand.Next(0, situations.Count)];
                DMUtils.DebugLog("Experimental Situation: {0}", targetSituation);
            }

            if (targetSituation != ExperimentSituations.SrfLanded)
            {
                Biome = "";
            }

            return(new DMCollectScience(body, targetSituation, Biome, name, 1));
        }