internal void updateRemainingData()
        {
            DMUtils.DebugLog("Updating Existing Data");
            List <ScienceData> dataList = new List <ScienceData>();

            if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ready)
            {
                foreach (IScienceDataContainer container in FlightGlobals.ActiveVessel.FindPartModulesImplementing <IScienceDataContainer>())
                {
                    dataList.AddRange(container.GetData());
                }
                if (dataList.Count > 0)
                {
                    foreach (ScienceData data in dataList)
                    {
                        foreach (DMScienceScenario.DMScienceData DMData in recoveredScienceList)
                        {
                            if (DMData.title == data.title)
                            {
                                ScienceSubject sub = ResearchAndDevelopment.GetSubjectByID(data.subjectID);
                                sub.scientificValue *= DMData.scival;
                                sub.science          = Math.Max(0f, sub.scienceCap - (sub.scienceCap * sub.scientificValue));
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        internal static List <string> fetchBiome(CelestialBody b, ScienceExperiment exp, ExperimentSituations sit)
        {
            DMUtils.DebugLog("Searching For Biomes: Value Sensitive");
            List <string> s = new List <string>();

            if (b.BiomeMap == null)
            {
                DMUtils.DebugLog("No Biomes Present For Target Planet");
                s.Add("");
                return(s);
            }
            else
            {
                for (int j = 0; j < b.BiomeMap.Attributes.Length; j++)
                {
                    string         bName = b.BiomeMap.Attributes[j].name;
                    ScienceSubject subB  = ResearchAndDevelopment.GetSubjectByID(string.Format("{0}@{1}{2}{3}", exp.id, b.name, sit, bName.Replace(" ", "")));
                    if (subB == null)
                    {
                        s.Add(bName);
                        continue;
                    }
                    else
                    {
                        if (subB.scientificValue > 0.5f)
                        {
                            s.Add(bName);
                        }
                    }
                }
            }
            DMUtils.DebugLog("Found Acceptable Biomes");
            return(s);
        }
Exemple #3
0
        //Used for biological survey
        internal static DMCollectScience fetchBioSurveyScience(CelestialBody body)
        {
            string biome = "";

            DMUtils.DebugLog("Checking Contract Requirements");

            //Make sure our experiment is OK
            if (ResearchAndDevelopment.GetExperiment("dmbiodrillscan") == null)
            {
                return(null);
            }

            //Build a list of acceptable biomes if applicable, choose one with remaining science
            DMUtils.DebugLog("Checking For Biome Usage");
            List <string> bList = DMUtils.fetchBiome(body);

            if (bList.Count == 0)
            {
                return(null);
            }
            int i = rand.Next(0, 2);

            if (i == 0)
            {
                biome = bList[rand.Next(0, bList.Count)];
                DMUtils.DebugLog("Acceptable Biome Found: {0}", biome);
            }

            return(new DMCollectScience(body, ExperimentSituations.SrfLanded, biome, "Bio Drill Scan", 1));
        }
Exemple #4
0
        ////Generate fully random science experiment contract parameter
        //internal static DMCollectScience fetchScienceContract(Contract.ContractPrestige p, List<CelestialBody> cR, List<CelestialBody> cUR)
        //{
        //    DMScienceContainer scienceContainer;
        //    CelestialBody body;
        //    ExperimentSituations targetSituation;
        //    List<ExperimentSituations> situations;
        //    ScienceExperiment exp;
        //    ScienceSubject sub;
        //    AvailablePart aPart;
        //    string name;
        //    string biome = "";

        //    //Choose a random science experiment from our list generated at startup
        //    scienceContainer = DMUtils.availableScience["All"].ElementAt(rand.Next(0, DMUtils.availableScience["All"].Count)).Value;
        //    name = DMUtils.availableScience["All"].FirstOrDefault(n => n.Value == scienceContainer).Key;
        //    DMUtils.DebugLog("Checking Contract Requirements");

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

        //    //Select a random Celestial Body based on contract prestige levels
        //    body = DMUtils.nextTargetBody(p, cR, cUR);
        //    if (body == null)
        //        return null;

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

        //    //Choose an acceptable experimental situation for a given science experiment
        //    if ((situations = DMUtils.availableSituations(exp, scienceContainer.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);
        //    }

        //    //Build a list of acceptable biomes if applicable, choose one with remaining science
        //    if (DMUtils.biomeRelevant(targetSituation, scienceContainer.bioMask) && targetSituation != ExperimentSituations.SrfSplashed)
        //    {
        //        DMUtils.DebugLog("Checking For Biome Usage");
        //        List<string> bList = DMUtils.fetchBiome(body, exp, targetSituation);
        //        if (bList.Count == 0)
        //        {
        //            DMUtils.DebugLog("Planet All Tapped Out; No Remaining Science Here");
        //            return null;
        //        }
        //        int i = rand.Next(0, 2);
        //        if (i == 0)
        //        {
        //            biome = bList[rand.Next(0, bList.Count)];
        //            DMUtils.DebugLog("Acceptable Biome Found: {0}", biome);
        //        }
        //    }

        //    //Make sure that our chosen science subject has science remaining to be gathered
        //    if ((sub = ResearchAndDevelopment.GetSubjectByID(string.Format("{0}@{1}{2}{3}", exp.id, body.name, targetSituation, biome.Replace(" ", "")))) != null)
        //    {
        //        if (sub.scientificValue < 0.4f)
        //            return null;
        //    }

        //    return new DMCollectScience(body, targetSituation, biome, name, 0);
        //}

        ////Generate random experiment for a given celestial body
        //internal static DMCollectScience fetchScienceContract(CelestialBody body)
        //{
        //    DMScienceContainer scienceContainer;
        //    ExperimentSituations targetSituation;
        //    List<ExperimentSituations> situations;
        //    ScienceExperiment exp;
        //    ScienceSubject sub;
        //    AvailablePart aPart;
        //    string name;
        //    string biome = "";

        //    //Choose a random science experiment from our list generated at startup
        //    scienceContainer = DMUtils.availableScience["All"].ElementAt(rand.Next(0, DMUtils.availableScience.Count)).Value;
        //    name = DMUtils.availableScience["All"].FirstOrDefault(n => n.Value == scienceContainer).Key;
        //    DMUtils.DebugLog("Checking Contract Requirements");

        //    //Determine if the science part is available if applicable
        //    if (scienceContainer.sciPart != "None")
        //    {
        //        DMUtils.DebugLog("Checking For Part {0} Now", scienceContainer.sciPart);
        //        aPart = PartLoader.getPartInfoByName(scienceContainer.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
        //    exp = scienceContainer.exp;
        //    if (exp == null)
        //        return null;

        //    //Choose an acceptable experimental situation for a given science experiment
        //    if ((situations = DMUtils.availableSituations(exp, scienceContainer.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);
        //    }

        //    //Build a list of acceptable biomes if applicable, choose one with remaining science
        //    if (DMUtils.biomeRelevant(targetSituation, scienceContainer.bioMask) && targetSituation != ExperimentSituations.SrfSplashed)
        //    {
        //        DMUtils.DebugLog("Checking For Biome Usage");
        //        List<string> bList = DMUtils.fetchBiome(body, exp, targetSituation);
        //        if (bList.Count == 0)
        //        {
        //            DMUtils.DebugLog("Planet All Tapped Out; No Remaining Science Here");
        //            return null;
        //        }
        //        int i = rand.Next(0, 2);
        //        if (i == 0)
        //        {
        //            biome = bList[rand.Next(0, bList.Count)];
        //            DMUtils.DebugLog("Acceptable Biome Found: {0}", biome);
        //        }
        //    }

        //    //Make sure that our chosen science subject has science remaining to be gathered
        //    if ((sub = ResearchAndDevelopment.GetSubjectByID(string.Format("{0}@{1}{2}{3}", exp.id, body.name, targetSituation, biome.Replace(" ", "")))) != null)
        //    {
        //        if (sub.scientificValue < 0.4f)
        //            return null;
        //    }

        //    return new DMCollectScience(body, targetSituation, biome, name, 0);
        //}

        ////Generate experiment for a given Celestial Body and experimental situation
        //internal static DMCollectScience fetchScienceContract(CelestialBody body, ExperimentSituations targetSituation)
        //{
        //    DMScienceContainer scienceContainer;
        //    ScienceExperiment exp;
        //    ScienceSubject sub;
        //    AvailablePart aPart;
        //    string name;
        //    string biome = "";

        //    //Choose a random science experiment from our list generated at startup
        //    scienceContainer = DMUtils.availableScience["All"].ElementAt(rand.Next(0, DMUtils.availableScience.Count)).Value;
        //    name = DMUtils.availableScience["All"].FirstOrDefault(n => n.Value == scienceContainer).Key;
        //    DMUtils.DebugLog("Checking Contract Requirements");

        //    //Determine if the science part is available if applicable
        //    if (scienceContainer.sciPart != "None")
        //    {
        //        DMUtils.DebugLog("Checking For Part {0} Now", scienceContainer.sciPart);
        //        aPart = PartLoader.getPartInfoByName(scienceContainer.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
        //    exp = scienceContainer.exp;
        //    if (exp == null)
        //        return null;

        //    //Make sure that the experiment can be conducted in this situation
        //    if (((ExperimentSituations)exp.situationMask & targetSituation) != targetSituation)
        //        return null;

        //    //Build a list of acceptable biomes if applicable, choose one with remaining science
        //    if (DMUtils.biomeRelevant(targetSituation, scienceContainer.bioMask) && targetSituation != ExperimentSituations.SrfSplashed)
        //    {
        //        DMUtils.DebugLog("Checking For Biome Usage");
        //        List<string> bList = DMUtils.fetchBiome(body, exp, targetSituation);
        //        if (bList.Count == 0)
        //        {
        //            DMUtils.DebugLog("Planet All Tapped Out; No Remaining Science Here");
        //            return null;
        //        }
        //        int i = rand.Next(0, 2);
        //        if (i == 0)
        //        {
        //            biome = bList[rand.Next(0, bList.Count)];
        //            DMUtils.DebugLog("Acceptable Biome Found: {0}", biome);
        //        }
        //    }

        //    //Make sure that our chosen science subject has science remaining to be gathered
        //    if ((sub = ResearchAndDevelopment.GetSubjectByID(string.Format("{0}@{1}{2}{3}", exp.id, body.name, targetSituation, biome.Replace(" ", "")))) != null)
        //    {
        //        if (sub.scientificValue < 0.4f)
        //            return null;
        //    }

        //    return new DMCollectScience(body, targetSituation, biome, name, 0);
        //}

        ////Generate random experiment for a given celestial body
        //internal static DMCollectScience fetchScienceContract(CelestialBody body, ScienceExperiment exp)
        //{
        //    DMScienceContainer scienceContainer;
        //    ExperimentSituations targetSituation;
        //    List<ExperimentSituations> situations;
        //    ScienceSubject sub;
        //    AvailablePart aPart;
        //    string name;
        //    string biome = "";

        //    //Choose science container based on a given science experiment
        //    scienceContainer = DMUtils.availableScience["All"].FirstOrDefault(e => e.Value.exp == exp).Value;
        //    name = DMUtils.availableScience["All"].FirstOrDefault(n => n.Value == scienceContainer).Key;
        //    DMUtils.DebugLog("Checking Contract Requirements");

        //    //Determine if the science part is available if applicable
        //    if (scienceContainer.sciPart != "None")
        //    {
        //        DMUtils.DebugLog("Checking For Part {0} Now", scienceContainer.sciPart);
        //        aPart = PartLoader.getPartInfoByName(scienceContainer.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
        //    exp = scienceContainer.exp;
        //    if (exp == null)
        //        return null;

        //    //Choose an acceptable experimental situation for a given science experiment
        //    if ((situations = DMUtils.availableSituations(exp, scienceContainer.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);
        //    }

        //    //Build a list of acceptable biomes if applicable, choose one with remaining science
        //    if (DMUtils.biomeRelevant(targetSituation, scienceContainer.bioMask) && targetSituation != ExperimentSituations.SrfSplashed)
        //    {
        //        DMUtils.DebugLog("Checking For Biome Usage");
        //        List<string> bList = DMUtils.fetchBiome(body, exp, targetSituation);
        //        if (bList.Count == 0)
        //        {
        //            DMUtils.DebugLog("Planet All Tapped Out; No Remaining Science Here");
        //            return null;
        //        }
        //        int i = rand.Next(0, 2);
        //        if (i == 0)
        //        {
        //            biome = bList[rand.Next(0, bList.Count)];
        //            DMUtils.DebugLog("Acceptable Biome Found: {0}", biome);
        //        }
        //    }

        //    //Make sure that our chosen science subject has science remaining to be gathered
        //    if ((sub = ResearchAndDevelopment.GetSubjectByID(string.Format("{0}@{1}{2}{3}", exp.id, body.name, targetSituation, biome.Replace(" ", "")))) != null)
        //    {
        //        if (sub.scientificValue < 0.4f)
        //            return null;
        //    }

        //    return new DMCollectScience(body, targetSituation, biome, name, 0);
        //}

        //Use for magnetic field survey
        internal static DMCollectScience fetchScienceContract(CelestialBody Body, ExperimentSituations Situation, DMScienceContainer DMScience)
        {
            AvailablePart aPart;
            string        name;

            //Choose science container based on a given science experiment
            name = DMUtils.availableScience["All"].FirstOrDefault(n => n.Value == DMScience).Key;
            DMUtils.DebugLog("Checking Contract Requirements");

            if (DMScience.exp == null)
            {
                return(null);
            }

            //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);
            }

            return(new DMCollectScience(Body, Situation, "", name, 1));
        }
Exemple #5
0
 private void RecoveryWatcher(float sci, ScienceSubject sub)
 {
     if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION)
     {
         float DMScience = sci;
         DMUtils.DebugLog("Science Data Recovered For {0} Science", sci);
         foreach (DMScienceScenario.DMScienceData DMData in DMScienceScenario.SciScenario.recoveredScienceList)
         {
             if (DMData.title == sub.title)
             {
                 float oldSciVal = 0f;
                 if (sub.scienceCap != 0)
                 {
                     oldSciVal = Math.Max(0f, 1f - ((sub.science - sci) / sub.scienceCap));
                 }
                 DMScience = sub.subjectValue * DMData.basevalue * DMData.scival * oldSciVal;
                 DMScienceScenario.SciScenario.submitDMScience(DMData, DMScience);
                 break;
             }
         }
         if (DMScience != sci)
         {
             float extraScience = sci - DMScience;
             Debug.LogWarning(string.Format("[DMagic Orbital Science] [Asteroid Science Retrieval] Remove {0} Science From R&D Center After Asteroid Calculations", extraScience));
             DMUtils.DebugLog("Remove {0} Science From R&D Center: From {1} To {2}", extraScience, ResearchAndDevelopment.Instance.Science, ResearchAndDevelopment.Instance.Science - extraScience);
             ResearchAndDevelopment.Instance.AddScience(-1f * extraScience, TransactionReasons.ScienceTransmission);
         }
     }
 }
Exemple #6
0
 //Track our vessel's orbit
 protected override void OnUpdate()
 {
     if (this.Root.ContractState == Contract.State.Active && !HighLogic.LoadedSceneIsEditor)
     {
         if (AllChildParametersComplete())
         {
             if (orbitTime == 0)
             {
                 DMUtils.DebugLog("Setting time to {0:N2}", Planetarium.GetUniversalTime());
                 orbitTime = Planetarium.GetUniversalTime();
             }
             else
             {
                 if ((Planetarium.GetUniversalTime() - orbitTime) >= timeNeeded)
                 {
                     DMUtils.DebugLog("Survey Complete Ater {0:N2} Amount of Time", Planetarium.GetUniversalTime() - orbitTime);
                     this.DisableOnStateChange = true;
                     foreach (ContractParameter cP in this.AllParameters)
                     {
                         cP.DisableOnStateChange = true;
                     }
                     this.SetComplete();
                 }
             }
         }
         //if the vessel falls out of the specified orbit reset the timer
         else
         {
             orbitTime = 0;
         }
     }
 }
Exemple #7
0
        //Return a list of valid experiment situations based on the experiment parameters
        internal static List <ExperimentSituations> availableSituations(ScienceExperiment exp, int i, CelestialBody b)
        {
            DMUtils.DebugLog("Finding Situations");
            List <ExperimentSituations> expSitList = new List <ExperimentSituations>();

            if (((ExperimentSituations)i & ExperimentSituations.FlyingHigh) == ExperimentSituations.FlyingHigh && b.atmosphere)
            {
                expSitList.Add(ExperimentSituations.FlyingHigh);
            }
            if (((ExperimentSituations)i & ExperimentSituations.FlyingLow) == ExperimentSituations.FlyingLow && b.atmosphere)
            {
                expSitList.Add(ExperimentSituations.FlyingLow);
            }
            if (((ExperimentSituations)i & ExperimentSituations.InSpaceHigh) == ExperimentSituations.InSpaceHigh)
            {
                if (!exp.requireAtmosphere)
                {
                    expSitList.Add(ExperimentSituations.InSpaceHigh);
                }
                else if (b.atmosphere)
                {
                    expSitList.Add(ExperimentSituations.InSpaceHigh);
                }
            }
            if (((ExperimentSituations)i & ExperimentSituations.InSpaceLow) == ExperimentSituations.InSpaceLow)
            {
                if (!exp.requireAtmosphere)
                {
                    expSitList.Add(ExperimentSituations.InSpaceLow);
                }
                else if (b.atmosphere)
                {
                    expSitList.Add(ExperimentSituations.InSpaceLow);
                }
            }
            if (((ExperimentSituations)i & ExperimentSituations.SrfLanded) == ExperimentSituations.SrfLanded && b.pqsController != null)
            {
                if (!exp.requireAtmosphere && exp.id != "dmbiodrillscan")
                {
                    expSitList.Add(ExperimentSituations.SrfLanded);
                }
                else if (b.atmosphere)
                {
                    expSitList.Add(ExperimentSituations.SrfLanded);
                }
            }
            if (((ExperimentSituations)i & ExperimentSituations.SrfSplashed) == ExperimentSituations.SrfSplashed && b.ocean && b.pqsController != null)
            {
                if (!exp.requireAtmosphere)
                {
                    expSitList.Add(ExperimentSituations.SrfSplashed);
                }
                else if (b.atmosphere)
                {
                    expSitList.Add(ExperimentSituations.SrfSplashed);
                }
            }
            DMUtils.DebugLog("Found {0} Valid Experimental Situations", expSitList.Count);
            return(expSitList);
        }
        internal void RecordNewScience(string title, float baseval, float scv, float sci, float cap)
        {
            DMScienceData DMData = new DMScienceData(title, baseval, scv, sci, cap);

            recoveredScienceList.Add(DMData);
            DMUtils.DebugLog("Adding new DMData to list");
        }
Exemple #9
0
        internal static DMAsteroidParameter fetchAsteroidParameter(int Size, DMScienceContainer DMScience)
        {
            ExperimentSituations targetSituation;
            AvailablePart        aPart;
            string name;

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

            //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);
            }

            if (DMScience.exp == null)
            {
                return(null);
            }

            if (((ExperimentSituations)DMScience.sitMask & ExperimentSituations.InSpaceLow) == ExperimentSituations.InSpaceLow)
            {
                if (((ExperimentSituations)DMScience.sitMask & ExperimentSituations.SrfLanded) == ExperimentSituations.SrfLanded)
                {
                    if (rand.Next(0, 2) == 0)
                    {
                        targetSituation = ExperimentSituations.SrfLanded;
                    }
                    else
                    {
                        targetSituation = ExperimentSituations.InSpaceLow;
                    }
                }
                else
                {
                    targetSituation = ExperimentSituations.InSpaceLow;
                }
            }
            else if (((ExperimentSituations)DMScience.sitMask & ExperimentSituations.SrfLanded) == ExperimentSituations.SrfLanded)
            {
                targetSituation = ExperimentSituations.SrfLanded;
            }
            else
            {
                return(null);
            }

            DMUtils.DebugLog("Successfully Generated Asteroid Survey Parameter");
            return(new DMAsteroidParameter(Size, targetSituation, name));
        }
Exemple #10
0
 private void scienceReceived(float sci, ScienceSubject sub)
 {
     DMUtils.DebugLog("Science Data Transmitted For {0} Science", sci);
     foreach (DMScienceScenario.DMScienceData DMData in DMScienceScenario.SciScenario.recoveredScienceList)
     {
         if (DMData.title == sub.title)
         {
             DMScienceScenario.SciScenario.submitDMScience(DMData, sci);
             break;
         }
     }
 }
Exemple #11
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));
        }
Exemple #12
0
 private void dockCheck(GameEvents.FromToAction <Part, Part> Parts)
 {
     DMUtils.DebugLog("Dock Event");
     if (suitableV.Count > 0)
     {
         DMUtils.DebugLog("Docking To Mag Surveyor");
         if (Parts.from.vessel.mainBody == body)
         {
             DMUtils.DebugLog("Mainbody Matches");
             modifiedByDocking = true;
             timer             = 0;
         }
     }
 }
Exemple #13
0
 //Select target celestial body based on contract prestige
 internal static CelestialBody nextTargetBody(Contract.ContractPrestige c, List <CelestialBody> cR, List <CelestialBody> cUR)
 {
     DMUtils.DebugLog("Searching For Acceptable Body");
     //Select Kerbin system for trivial
     if (c == Contract.ContractPrestige.Trivial)
     {
         return(FlightGlobals.Bodies[rand.Next(1, 4)]);
     }
     //Select already visited planets for significant, add Mun and Minmus if they aren't already present
     else if (c == Contract.ContractPrestige.Significant)
     {
         if (!cR.Contains(FlightGlobals.Bodies[2]))
         {
             cR.Add(FlightGlobals.Bodies[2]);
         }
         if (!cR.Contains(FlightGlobals.Bodies[3]))
         {
             cR.Add(FlightGlobals.Bodies[3]);
         }
         if (cR.Count == 0)
         {
             return(null);
         }
         return(cR[rand.Next(0, cR.Count)]);
     }
     //Select unreached body for; remove Kerbin system, return already reached bodies if all have been visited
     else if (c == Contract.ContractPrestige.Exceptional)
     {
         if (cUR.Count == 0)
         {
             cUR = cR;
         }
         if (cUR.Contains(FlightGlobals.Bodies[1]))
         {
             cUR.Remove(FlightGlobals.Bodies[1]);
         }
         if (cUR.Contains(FlightGlobals.Bodies[2]))
         {
             cUR.Remove(FlightGlobals.Bodies[2]);
         }
         if (cUR.Contains(FlightGlobals.Bodies[3]))
         {
             cUR.Remove(FlightGlobals.Bodies[3]);
         }
         return(cUR[rand.Next(0, cUR.Count)]);
     }
     return(null);
 }
Exemple #14
0
        internal static DMCollectScience fetchAnomalyParameter(CelestialBody Body, DMAnomalyObject City)
        {
            ExperimentSituations targetSituation;
            ScienceSubject       sub;
            string subject, anomName;

            if (Body == null)
            {
                return(null);
            }

            if (City == null)
            {
                return(null);
            }

            if (ResearchAndDevelopment.GetExperiment("AnomalyScan") == null)
            {
                return(null);
            }

            if (rand.Next(0, 2) == 0)
            {
                targetSituation = ExperimentSituations.SrfLanded;
            }
            else
            {
                targetSituation = ExperimentSituations.FlyingLow;
            }

            anomName = DMagic.Part_Modules.DMAnomalyScanner.anomalyCleanup(City.name);

            subject = string.Format("AnomalyScan@{0}{1}{2}", Body.name, targetSituation, anomName);

            //Make sure that our chosen science subject has science remaining to be gathered
            if ((sub = ResearchAndDevelopment.GetSubjectByID(subject)) != null)
            {
                if (sub.scientificValue < 0.4f)
                {
                    return(null);
                }
            }

            DMUtils.DebugLog("Primary Anomaly Parameter Assigned");
            return(new DMCollectScience(Body, targetSituation, anomName, "Anomaly Scan", 2));
        }
        public override void OnSave(ConfigNode node)
        {
            DMUtils.DebugLog("Saving Science Scenario");
            ConfigNode results_node = new ConfigNode("Asteroid_Science");

            foreach (DMScienceData data in recoveredScienceList)
            {
                ConfigNode scienceResults_node = new ConfigNode("DM_Science");
                scienceResults_node.AddValue("title", data.title);
                scienceResults_node.AddValue("bsv", data.basevalue);
                scienceResults_node.AddValue("scv", data.scival);
                scienceResults_node.AddValue("sci", data.science);
                scienceResults_node.AddValue("cap", data.cap);
                results_node.AddNode(scienceResults_node);
            }
            node.AddNode(results_node);
        }
Exemple #16
0
        internal static DMAnomalyParameter fetchAnomalyParameter(CelestialBody Body, DMAnomalyObject City, DMScienceContainer DMScience)
        {
            AvailablePart               aPart;
            ExperimentSituations        targetSituation;
            List <ExperimentSituations> situations;
            string name;

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

            if (DMScience.exp == null)
            {
                return(null);
            }

            //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);
            }

            if ((situations = DMUtils.availableSituationsLimited(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);
            }

            return(new DMAnomalyParameter(Body, City, targetSituation, name));
        }
Exemple #17
0
 private void newVesselCheck(Vessel v)
 {
     if (suitableV.Count > 0)
     {
         DMUtils.DebugLog("New Vessel Created");
         Vessel V = v;
         if (V.Parts.Count <= 1)
         {
             return;
         }
         if (V.mainBody == body)
         {
             DMUtils.DebugLog("Mainbody Matches");
             newV = V;
             modifiedByUnDocking = true;
             timer = 0;
         }
     }
 }
Exemple #18
0
        public DMSeismometerValues(Vessel v, ProtoPartSnapshot pp, ProtoPartModuleSnapshot pm, bool h)
        {
            vesselRef      = v;
            protoPartRef   = pp;
            protoModuleRef = pm;
            id             = pp.flightID;

            if (pm.moduleValues.HasValue("IsDeployed"))
            {
                bool.TryParse(pm.moduleValues.GetValue("IsDeployed"), out armed);
            }
            if (pm.moduleValues.HasValue("baseExperimentValue"))
            {
                float.TryParse(pm.moduleValues.GetValue("baseExperimentValue"), out baseScore);
            }

            hammer = h;

            DMUtils.DebugLog("Seismometer Values Loaded\nID: {0}\nArmed: {1}\nBase Value: {2:P1}\nHammer: {3}", id, armed, baseScore, hammer);
        }
Exemple #19
0
        internal static List <string> fetchBiome(CelestialBody b)
        {
            DMUtils.DebugLog("Searching For Biomes: Value InSensitive");
            List <string> s = new List <string>();

            if (b.BiomeMap == null)
            {
                DMUtils.DebugLog("No Biomes Present For Target Planet");
                s.Add("");
                return(s);
            }
            else
            {
                for (int j = 0; j < b.BiomeMap.Attributes.Length; j++)
                {
                    string bName = b.BiomeMap.Attributes[j].name;
                    s.Add(bName);
                }
            }
            return(s);
        }
        public override void OnLoad(ConfigNode node)
        {
            if (DMagicVersion != DMUtils.version)
            {
                DMUtils.DebugLog("[DM] New DMagic Version Detected; Resetting Contracts");
                DMagicVersion   = DMUtils.version;
                contractsReload = true;
            }
            else
            {
                contractsReload = false;
            }

            DMUtils.DebugLog("Loading Science Scenario");
            recoveredScienceList.Clear();
            ConfigNode results_node = node.GetNode("Asteroid_Science");

            if (results_node != null)
            {
                foreach (ConfigNode scienceResults_node in results_node.GetNodes("DM_Science"))
                {
                    string title = scienceResults_node.GetValue("title");
                    float  bsv   = float.Parse(scienceResults_node.GetValue("bsv"));
                    float  scv   = float.Parse(scienceResults_node.GetValue("scv"));
                    float  sci   = float.Parse(scienceResults_node.GetValue("sci"));
                    float  cap   = float.Parse(scienceResults_node.GetValue("cap"));
                    RecordNewScience(title, bsv, scv, sci, cap);
                }
            }
            if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                recoveryWatcher = gameObject.AddComponent <DMRecoveryWatcher>();
            }
            if (HighLogic.LoadedSceneIsFlight)
            {
                tranWatcher = gameObject.AddComponent <DMTransmissionWatcher>();
                anomalyList = gameObject.AddComponent <DMAnomalyList>();
                updateRemainingData();
            }
        }
Exemple #21
0
 private void vesselOrbit(Vessel v, CelestialBody b)
 {
     if (v == FlightGlobals.ActiveVessel)
     {
         //If the vessels enters orbit around the correct body and has the right parts set to inOrbit
         if (b == body && v.situation == Vessel.Situations.ORBITING)
         {
             DMUtils.DebugLog("Vessel Mainbody {0} Matches {1}, Checking For Instruments On: ", v.mainBody.name, body.name, v.vesselName);
             if (VesselEquipped(v))
             {
                 DMUtils.DebugLog("OP Successfully Entered Orbit");
                 if (!suitableV.Contains(v))
                 {
                     suitableV.Add(v);
                 }
             }
         }
         else
         {
             DMUtils.DebugLog("Vessel Mainbody {0} Does Not Match: {1}", v.mainBody.name, body.name);
         }
     }
 }
Exemple #22
0
        protected override bool Generate()
        {
            int total = ContractSystem.Instance.GetCurrentContracts <DMAnomalyContract>().Count();

            if (total >= DMUtils.maxAnomaly)
            {
                return(false);
            }

            //Make sure that the anomaly scanner is available
            AvailablePart aPart = PartLoader.getPartInfoByName("dmAnomScanner");

            if (aPart == null)
            {
                return(false);
            }
            if (!ResearchAndDevelopment.PartModelPurchased(aPart))
            {
                return(false);
            }

            //Kerbin or Mun Anomalies for trivial contracts
            if (this.Prestige == ContractPrestige.Trivial)
            {
                if (rand.Next(0, 3) == 0)
                {
                    body = FlightGlobals.Bodies[1];
                }
                else
                {
                    body = FlightGlobals.Bodies[2];
                }
            }
            //Minmus and Duna are next
            else if (this.Prestige == ContractPrestige.Significant)
            {
                if (!ProgressTracking.Instance.NodeComplete(new string[] { "Kerbin", "Escape" }))
                {
                    return(false);
                }
                if (rand.Next(0, 2) == 0)
                {
                    body = FlightGlobals.Bodies[3];
                }
                else
                {
                    body = FlightGlobals.Bodies[6];
                }
            }
            //Vall, Tylo, and Bop are last; only if we've been to Jool first
            else if (this.Prestige == ContractPrestige.Exceptional)
            {
                if (!ProgressTracking.Instance.NodeComplete(new string[] { "Jool", "Flyby" }))
                {
                    return(false);
                }
                int i = rand.Next(0, 3);
                if (i == 0)
                {
                    body = FlightGlobals.Bodies[10];
                }
                else if (i == 1)
                {
                    body = FlightGlobals.Bodies[11];
                }
                else if (i == 2)
                {
                    body = FlightGlobals.Bodies[12];
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            PQSCity[] Cities = UnityEngine.Object.FindObjectsOfType(typeof(PQSCity)) as PQSCity[];
            foreach (PQSCity city in Cities)
            {
                if (city.transform.parent.name == body.name)
                {
                    cities.Add(city);
                }
            }

            //Select random anomaly
            targetAnomaly = new DMAnomalyObject(cities[rand.Next(0, cities.Count)]);
            hash          = targetAnomaly.name;
            lon           = targetAnomaly.lon;
            lat           = targetAnomaly.lat;
            fudgedLat     = fudgeLat(lat);
            fudgedLon     = fudgeLon(lon);
            cardNS        = NSDirection(lat);
            cardEW        = EWDirection(lon);
            DMUtils.DebugLog("Anomaly [{0}] Selected On {1} at Latitude: {2:N1} and Longitude: {3:N1}", targetAnomaly.name, body.theName, lat, lon);

            //Assign primary anomaly contract parameter
            if ((newParam = DMAnomalyGenerator.fetchAnomalyParameter(body, targetAnomaly)) == null)
            {
                return(false);
            }

            sciList.AddRange(DMUtils.availableScience[DMScienceType.Anomaly.ToString()].Values);

            for (i = 0; i < 3; i++)
            {
                if (sciList.Count > 0)
                {
                    DMScience     = sciList[rand.Next(0, sciList.Count)];
                    anomParams[i] = (DMAnomalyGenerator.fetchAnomalyParameter(body, targetAnomaly, DMScience));
                    sciList.Remove(DMScience);
                }
                else
                {
                    anomParams[i] = null;
                }
            }

            this.AddParameter(newParam);
            DMUtils.DebugLog("Added Primary Anomaly Parameter");
            float primaryLocationMod = GameVariables.Instance.ScoreSituation(DMUtils.convertSit(newParam.Situation), newParam.Body) * ((float)rand.Next(85, 116) / 100f);

            newParam.SetFunds(20000f * DMUtils.reward * primaryLocationMod, 10000f * DMUtils.penalty * primaryLocationMod, body);
            newParam.SetReputation(80f * DMUtils.reward * primaryLocationMod, 10f * DMUtils.penalty * primaryLocationMod, body);
            newParam.SetScience(35f * DMUtils.science * DMUtils.fixSubjectVal(newParam.Situation, 1f, body), null);

            foreach (DMAnomalyParameter aP in anomParams)
            {
                if (aP != null)
                {
                    this.AddParameter(aP, "collectDMAnomaly");
                    DMUtils.DebugLog("Added Secondary Anomaly Parameter");
                    float locationMod = GameVariables.Instance.ScoreSituation(DMUtils.convertSit(aP.Situation), aP.Body) * ((float)rand.Next(85, 116) / 100f);
                    aP.SetFunds(9000f * DMUtils.reward * locationMod, 6000f * DMUtils.penalty * locationMod, body);
                    aP.SetReputation(20f * DMUtils.reward * locationMod, 5f * DMUtils.penalty * locationMod, body);
                    aP.SetScience(aP.Container.exp.baseValue * 2f * DMUtils.science * DMUtils.fixSubjectVal(aP.Situation, 1f, body), null);
                }
            }

            if (this.ParameterCount == 0)
            {
                return(false);
            }

            this.agent = AgentList.Instance.GetAgent("DMagic");
            base.SetExpiry(10 * DMUtils.deadline, 20 * DMUtils.deadline);
            base.SetDeadlineYears(1.8f * ((float)rand.Next(80, 121)) / 100f * DMUtils.deadline, body);
            base.SetReputation(20f * DMUtils.reward * primaryLocationMod, 10f * DMUtils.penalty * primaryLocationMod, body);
            base.SetFunds(25000f * DMUtils.forward * primaryLocationMod, 22000f * DMUtils.reward * primaryLocationMod, 16000f * DMUtils.penalty * primaryLocationMod, body);
            return(true);
        }
Exemple #23
0
        private void configLoad()
        {
            //Load in global multipliers
            foreach (ConfigNode setNode in GameDatabase.Instance.GetConfigNodes("DM_CONTRACT_SETTINGS"))
            {
                if (setNode.GetValue("name") == "Contract Settings")
                {
                    DMUtils.science     = float.Parse(setNode.GetValue("Global_Science_Return"));
                    DMUtils.reward      = float.Parse(setNode.GetValue("Global_Fund_Reward"));
                    DMUtils.forward     = float.Parse(setNode.GetValue("Global_Fund_Forward"));
                    DMUtils.penalty     = float.Parse(setNode.GetValue("Global_Fund_Penalty"));
                    DMUtils.deadline    = float.Parse(setNode.GetValue("Global_Deadline"));
                    DMUtils.maxSurvey   = int.Parse(setNode.GetValue("Max_Survey"));
                    DMUtils.maxAsteroid = int.Parse(setNode.GetValue("Max_Asteroid"));
                    DMUtils.maxAnomaly  = int.Parse(setNode.GetValue("Max_Anomaly"));
                    DMUtils.maxMagnetic = int.Parse(setNode.GetValue("Max_Magnetic"));

                    DMUtils.Logging("Contract Variables Set; Science Reward: {0} ; Completion Reward: {1} ; Forward Amount: {2} ; Penalty Amount: {3} ; Deadline Length: {4}",
                                    DMUtils.science, DMUtils.reward, DMUtils.forward, DMUtils.penalty, DMUtils.deadline);
                    DMUtils.Logging("Max Contract Variables Set: Survey: {0} ; Asteroid: {1} ; Anomaly: {2} ; Magnetic: {3}",
                                    DMUtils.maxSurvey, DMUtils.maxAsteroid, DMUtils.maxAnomaly, DMUtils.maxMagnetic);
                    break;
                }
            }
            //Load in experiment definitions
            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("DM_CONTRACT_EXPERIMENT"))
            {
                string             name, part, agent = "";
                int                sitMask, bioMask, type = 0;
                float              transmit  = 0;
                DMScienceContainer DMscience = null;
                ScienceExperiment  exp       = null;

                //Some apparently not impossible errors can cause deplicate experiments to be added to the R&D science experiment dictionary
                try
                {
                    exp = ResearchAndDevelopment.GetExperiment(node.GetValue("experimentID"));
                }
                catch (Exception e)
                {
                    Debug.LogError("[DM] Whoops. Something really wrong happened here; stopping this contract experiment from loading..." + e);
                    continue;
                }
                if (exp != null)
                {
                    name = node.GetValue("name");
                    if (!int.TryParse(node.GetValue("sitMask"), out sitMask))
                    {
                        continue;
                    }
                    if (!int.TryParse(node.GetValue("bioMask"), out bioMask))
                    {
                        continue;
                    }
                    if (!int.TryParse(node.GetValue("type"), out type))
                    {
                        continue;
                    }
                    if (!float.TryParse(node.GetValue("xmitDataScalar"), out transmit))
                    {
                        continue;
                    }
                    if (node.HasValue("part"))
                    {
                        part = node.GetValue("part");
                    }
                    else
                    {
                        part = "None";
                    }
                    if (node.HasValue("agent"))
                    {
                        agent = node.GetValue("agent");
                    }
                    else
                    {
                        agent = "Any";
                    }
                    if (DMUtils.whiteListed)
                    {
                        exp.situationMask = (uint)sitMask;
                    }
                    exp.biomeMask = (uint)bioMask;
                    DMscience     = new DMScienceContainer(exp, sitMask, bioMask, (DMScienceType)type, part, agent, transmit);
                    if (((DMScienceType)type & DMScienceType.Surface) == DMScienceType.Surface && !DMUtils.availableScience[DMScienceType.Surface.ToString()].ContainsKey(name))
                    {
                        DMUtils.availableScience[DMScienceType.Surface.ToString()].Add(name, DMscience);
                    }
                    if (((DMScienceType)type & DMScienceType.Aerial) == DMScienceType.Aerial && !DMUtils.availableScience[DMScienceType.Aerial.ToString()].ContainsKey(name))
                    {
                        DMUtils.availableScience[DMScienceType.Aerial.ToString()].Add(name, DMscience);
                    }
                    if (((DMScienceType)type & DMScienceType.Space) == DMScienceType.Space && !DMUtils.availableScience[DMScienceType.Space.ToString()].ContainsKey(name))
                    {
                        DMUtils.availableScience[DMScienceType.Space.ToString()].Add(name, DMscience);
                    }
                    if (((DMScienceType)type & DMScienceType.Biological) == DMScienceType.Biological && !DMUtils.availableScience[DMScienceType.Biological.ToString()].ContainsKey(name))
                    {
                        DMUtils.availableScience[DMScienceType.Biological.ToString()].Add(name, DMscience);
                    }
                    if (((DMScienceType)type & DMScienceType.Asteroid) == DMScienceType.Asteroid && !DMUtils.availableScience[DMScienceType.Asteroid.ToString()].ContainsKey(name))
                    {
                        DMUtils.availableScience[DMScienceType.Asteroid.ToString()].Add(name, DMscience);
                    }
                    if (((DMScienceType)type & DMScienceType.Anomaly) == DMScienceType.Anomaly && !DMUtils.availableScience[DMScienceType.Anomaly.ToString()].ContainsKey(name))
                    {
                        DMUtils.availableScience[DMScienceType.Anomaly.ToString()].Add(name, DMscience);
                    }
                    if (!DMUtils.availableScience["All"].ContainsKey(name))
                    {
                        DMUtils.availableScience["All"].Add(name, DMscience);
                    }
                    DMUtils.DebugLog("New Experiment: [{0}] Available For Contracts", name);
                }
            }
            DMUtils.Logging("Successfully Added {0} New Experiments To Contract List", DMUtils.availableScience["All"].Count);
            DMUtils.DebugLog("Successfully Added {0} New Surface Experiments To Contract List", DMUtils.availableScience[DMScienceType.Surface.ToString()].Count);
            DMUtils.DebugLog("Successfully Added {0} New Aerial Experiments To Contract List", DMUtils.availableScience[DMScienceType.Aerial.ToString()].Count);
            DMUtils.DebugLog("Successfully Added {0} New Orbital Experiments To Contract List", DMUtils.availableScience[DMScienceType.Space.ToString()].Count);
            DMUtils.DebugLog("Successfully Added {0} New Biological Experiments To Contract List", DMUtils.availableScience[DMScienceType.Biological.ToString()].Count);
            DMUtils.DebugLog("Successfully Added {0} New Asteroid Experiments To Contract List", DMUtils.availableScience[DMScienceType.Asteroid.ToString()].Count);
            DMUtils.DebugLog("Successfully Added {0} New Anomaly Experiments To Contract List", DMUtils.availableScience[DMScienceType.Anomaly.ToString()].Count);
            //Load in custom contract descriptions
            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("DM_SCIENCE_STORY_DEF"))
            {
                foreach (ConfigNode storyNode in node.GetNodes("DM_SCIENCE_BACKSTORY"))
                {
                    foreach (string st in storyNode.GetValues("generic"))
                    {
                        if (!string.IsNullOrEmpty(st))
                        {
                            string story = st.Replace("[", "{");
                            story = story.Replace("]", "}");
                            DMUtils.backStory["generic"].Add(story);
                        }
                    }
                    foreach (string so in storyNode.GetValues("survey"))
                    {
                        if (!string.IsNullOrEmpty(so))
                        {
                            string story_o = so.Replace("[", "{");
                            story_o = story_o.Replace("]", "}");
                            DMUtils.backStory["survey"].Add(story_o);
                        }
                    }
                    foreach (string sb in storyNode.GetValues("biological"))
                    {
                        if (!string.IsNullOrEmpty(sb))
                        {
                            string story_b = sb.Replace("[", "{");
                            story_b = story_b.Replace("]", "}");
                            DMUtils.backStory["biological"].Add(story_b);
                        }
                    }
                    foreach (string sb in storyNode.GetValues("asteroid"))
                    {
                        if (!string.IsNullOrEmpty(sb))
                        {
                            string story_b = sb.Replace("[", "{");
                            story_b = story_b.Replace("]", "}");
                            DMUtils.backStory["asteroid"].Add(story_b);
                        }
                    }
                    foreach (string sb in storyNode.GetValues("anomaly"))
                    {
                        if (!string.IsNullOrEmpty(sb))
                        {
                            string story_b = sb.Replace("[", "{");
                            story_b = story_b.Replace("]", "}");
                            DMUtils.backStory["anomaly"].Add(story_b);
                        }
                    }
                    foreach (string sb in storyNode.GetValues("magnetic"))
                    {
                        if (!string.IsNullOrEmpty(sb))
                        {
                            string story_b = sb.Replace("[", "{");
                            story_b = story_b.Replace("]", "}");
                            DMUtils.backStory["magnetic"].Add(story_b);
                        }
                    }
                }
            }
            DMUtils.Logging("Added {0} New Generic Backstories; {1} New Survey Backstories; {2} New Biological Backstories; {3} New Asteroid Backstories; {4} New Anomaly Backstories; {5} New Magnetic Backstories To The List", DMUtils.backStory["generic"].Count, DMUtils.backStory["survey"].Count, DMUtils.backStory["biological"].Count, DMUtils.backStory["asteroid"].Count, DMUtils.backStory["anomaly"].Count, DMUtils.backStory["magnetic"].Count);
        }
Exemple #24
0
 private void Start()
 {
     DMUtils.DebugLog("Starting Recovery Watcher");
     GameEvents.OnScienceRecieved.Add(RecoveryWatcher);
 }
Exemple #25
0
 private void OnDestroy()
 {
     DMUtils.DebugLog("Destroying Recovery Watcher");
     GameEvents.OnScienceRecieved.Remove(RecoveryWatcher);
 }
Exemple #26
0
        //Used for orbital survey
        internal static DMCollectScience fetchSurveyScience(CelestialBody Body, DMScienceContainer DMScience)
        {
            ExperimentSituations targetSituation;
            ScienceSubject       sub;
            AvailablePart        aPart;
            string name;

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

            //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);
            }

            if (!Body.atmosphere && DMScience.exp.requireAtmosphere)
            {
                return(null);
            }
            if (((ExperimentSituations)DMScience.sitMask & ExperimentSituations.InSpaceHigh) == ExperimentSituations.InSpaceHigh)
            {
                if (rand.Next(0, 2) == 0)
                {
                    targetSituation = ExperimentSituations.InSpaceHigh;
                }
                else
                {
                    targetSituation = ExperimentSituations.InSpaceLow;
                }
            }
            else
            {
                targetSituation = ExperimentSituations.InSpaceLow;
            }

            if (DMUtils.biomeRelevant(targetSituation, DMScience.bioMask))
            {
                DMUtils.DebugLog("Checking For Biome Usage");
                List <string> bList = DMUtils.fetchBiome(Body, DMScience.exp, targetSituation);
                if (bList.Count == 0)
                {
                    DMUtils.DebugLog("Planet All Tapped Out; No Remaining Science Here");
                    return(null);
                }
            }

            if ((sub = ResearchAndDevelopment.GetSubjectByID(string.Format("{0}@{1}{2}", DMScience.exp.id, Body.name, targetSituation))) != null)
            {
                if (sub.scientificValue < 0.5f)
                {
                    return(null);
                }
            }

            return(new DMCollectScience(Body, targetSituation, "", name, 0));
        }
Exemple #27
0
        //Used for initial orbital and surface survey parameter
        internal static DMCollectScience fetchSurveyScience(Contract.ContractPrestige c, List <CelestialBody> cR, List <CelestialBody> cUR, DMScienceContainer DMScience, int sT)
        {
            CelestialBody        body;
            ExperimentSituations targetSituation;
            ScienceSubject       sub;
            AvailablePart        aPart;
            string name;
            string biome      = "";
            int    surveyType = sT;

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

            //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);
            }

            body = DMUtils.nextTargetBody(c, cR, cUR);
            DMUtils.DebugLog("Body: {0} Selected", body.name);
            if (body == null)
            {
                return(null);
            }

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

            if (surveyType == 0)
            {
                if (!body.atmosphere && DMScience.exp.requireAtmosphere)
                {
                    return(null);
                }
                if (((ExperimentSituations)DMScience.sitMask & ExperimentSituations.InSpaceHigh) == ExperimentSituations.InSpaceHigh)
                {
                    if (rand.Next(0, 2) == 0)
                    {
                        targetSituation = ExperimentSituations.InSpaceHigh;
                    }
                    else
                    {
                        targetSituation = ExperimentSituations.InSpaceLow;
                    }
                }
                else
                {
                    targetSituation = ExperimentSituations.InSpaceLow;
                }
            }
            else if (surveyType == 1)
            {
                if (body.pqsController == null)
                {
                    return(null);
                }
                if (!body.atmosphere && DMScience.exp.requireAtmosphere)
                {
                    return(null);
                }
                if (((ExperimentSituations)DMScience.sitMask & ExperimentSituations.SrfLanded) == ExperimentSituations.SrfLanded)
                {
                    if (DMScience.exp.id != "dmbiodrillscan")
                    {
                        targetSituation = ExperimentSituations.SrfLanded;
                    }
                    else if (body.atmosphere)
                    {
                        targetSituation = ExperimentSituations.SrfLanded;
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            else if (surveyType == 2)
            {
                if (!body.atmosphere)
                {
                    return(null);
                }
                if (rand.Next(0, 2) == 0)
                {
                    targetSituation = ExperimentSituations.FlyingHigh;
                }
                else
                {
                    targetSituation = ExperimentSituations.FlyingLow;
                }
            }
            else
            {
                return(null);
            }

            DMUtils.DebugLog("Experimental Situation: {0} Selected", targetSituation.ToString());

            if (DMUtils.biomeRelevant(targetSituation, DMScience.bioMask) && targetSituation != ExperimentSituations.SrfSplashed)
            {
                DMUtils.DebugLog("Checking For Biome Usage");
                List <string> bList = DMUtils.fetchBiome(body, DMScience.exp, targetSituation);
                if (bList.Count == 0)
                {
                    DMUtils.DebugLog("Planet All Tapped Out; No Remaining Science Here");
                    return(null);
                }
                else
                {
                    biome = bList[rand.Next(0, bList.Count)];
                    DMUtils.DebugLog("Acceptable Biome Found: {0}", biome);
                }
            }

            DMUtils.DebugLog("Checking For Remaining Science");
            //Make sure that our chosen science subject has science remaining to be gathered
            if ((sub = ResearchAndDevelopment.GetSubjectByID(string.Format("{0}@{1}{2}{3}", DMScience.exp.id, body.name, targetSituation, biome.Replace(" ", "")))) != null)
            {
                if (sub.scientificValue < 0.5f)
                {
                    return(null);
                }
            }

            if (surveyType == 0)
            {
                return(new DMCollectScience(body, targetSituation, "", name, 0));
            }
            else if (surveyType == 1)
            {
                return(new DMCollectScience(body, targetSituation, biome, name, 0));
            }
            else if (surveyType == 2)
            {
                return(new DMCollectScience(body, targetSituation, biome, name, 1));
            }
            else
            {
                return(null);
            }
        }
Exemple #28
0
 private void Start()
 {
     DMUtils.DebugLog("Starting Transmission Watcher");
     GameEvents.OnScienceRecieved.Add(scienceReceived);
 }
Exemple #29
0
 private void OnDestroy()
 {
     DMUtils.DebugLog("Stopping Transmission Watcher");
     GameEvents.OnScienceRecieved.Remove(scienceReceived);
 }
Exemple #30
0
        //Used for surface surveys
        internal static DMCollectScience fetchSurveyScience(CelestialBody Body, DMScienceContainer DMScience, string Biome)
        {
            AvailablePart  aPart;
            ScienceSubject sub;
            string         name;

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

            //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);
            }

            if (!DMUtils.biomeRelevant(ExperimentSituations.SrfLanded, DMScience.bioMask))
            {
                Biome = "";
            }

            if (Body.pqsController == null)
            {
                return(null);
            }
            if (!Body.atmosphere && DMScience.exp.requireAtmosphere)
            {
                return(null);
            }
            if (((ExperimentSituations)DMScience.sitMask & ExperimentSituations.SrfLanded) != ExperimentSituations.SrfLanded)
            {
                return(null);
            }
            if (DMScience.exp.id == "dmbiodrillscan" && !Body.atmosphere)
            {
                return(null);
            }
            if ((sub = ResearchAndDevelopment.GetSubjectByID(string.Format("{0}@{1}{2}{3}", DMScience.exp.id, Body.name, ExperimentSituations.SrfLanded, Biome.Replace(" ", "")))) != null)
            {
                if (sub.scientificValue < 0.5f)
                {
                    return(null);
                }
            }

            return(new DMCollectScience(Body, ExperimentSituations.SrfLanded, Biome, name, 0));
        }