//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); } }
//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)); }
//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)); }
//Used for orbital survey internal static DMCollectScience fetchSurveyScience(CelestialBody Body, DMScienceContainer DMScience) { ExperimentSituations targetSituation; ScienceSubject sub; string name; if (!DMUtils.availableScience.ContainsKey("All")) { return(null); } name = DMUtils.availableScience["All"].FirstOrDefault(n => n.Value == DMScience).Key; //Determine if the science part is available if applicable if (DMScience.SciPart != "None") { if (!DMUtils.partAvailable(new List <string>(1) { DMScience.SciPart })) { return(null); } } //Make sure our experiment is OK if (DMScience.Exp == null) { return(null); } if (!Body.atmosphere && DMScience.Exp.requireAtmosphere) { return(null); } if (((ExperimentSituations)DMScience.Exp.situationMask & ExperimentSituations.InSpaceHigh) == ExperimentSituations.InSpaceHigh && ((ExperimentSituations)DMScience.Exp.situationMask & ExperimentSituations.InSpaceLow) == ExperimentSituations.InSpaceLow) { if (rand.Next(0, 2) == 0) { targetSituation = ExperimentSituations.InSpaceHigh; } else { targetSituation = ExperimentSituations.InSpaceLow; } } else if (((ExperimentSituations)DMScience.Exp.situationMask & ExperimentSituations.InSpaceHigh) == ExperimentSituations.InSpaceHigh) { targetSituation = ExperimentSituations.InSpaceHigh; } else { targetSituation = ExperimentSituations.InSpaceLow; } if (DMUtils.biomeRelevant(targetSituation, (int)DMScience.Exp.biomeMask)) { List <string> bList = DMUtils.fetchBiome(Body, DMScience.Exp, targetSituation); if (bList.Count == 0) { return(null); } } else { string subId = string.Format("{0}@{1}{2}", DMScience.Exp.id, Body.bodyName, targetSituation); if (ResearchAndDevelopment.GetSubjects().Any(s => s.id == subId)) { sub = ResearchAndDevelopment.GetSubjectByID(subId); if (sub.scientificValue < 0.5f) { return(null); } } } return(new DMCollectScience(Body, targetSituation, "", name, 0)); }
//Used for initial orbital and surface survey parameter internal static DMCollectScience fetchSurveyScience(Contract.ContractPrestige c, List <CelestialBody> cR, List <CelestialBody> cUR, DMScienceContainer DMScience) { CelestialBody body; ExperimentSituations targetSituation; ScienceSubject sub; string name; string biome = ""; if (!DMUtils.availableScience.ContainsKey("All")) { return(null); } name = DMUtils.availableScience["All"].FirstOrDefault(n => n.Value == DMScience).Key; //Determine if the science part is available if applicable if (DMScience.SciPart != "None") { if (!DMUtils.partAvailable(new List <string>(1) { DMScience.SciPart })) { return(null); } } List <CelestialBody> bodies = new List <CelestialBody>(); Func <CelestialBody, bool> cb = null; switch (c) { case Contract.ContractPrestige.Trivial: cb = delegate(CelestialBody b) { if (b == Planetarium.fetch.Sun) { return(false); } if (b.scienceValues.RecoveryValue > 4) { return(false); } return(true); }; bodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.ORBIT, true, cb)); break; case Contract.ContractPrestige.Significant: cb = delegate(CelestialBody b) { if (b == Planetarium.fetch.Sun) { return(false); } if (b == Planetarium.fetch.Home) { return(false); } if (b.scienceValues.RecoveryValue > 8) { return(false); } return(true); }; bodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.FLYBY, true, cb)); bodies.AddRange(ProgressUtilities.GetNextUnreached(2, cb)); break; case Contract.ContractPrestige.Exceptional: cb = delegate(CelestialBody b) { if (b == Planetarium.fetch.Home) { return(false); } if (Planetarium.fetch.Home.orbitingBodies.Count > 0) { foreach (CelestialBody B in Planetarium.fetch.Home.orbitingBodies) { if (b == B) { return(false); } } } if (b.scienceValues.RecoveryValue < 4) { return(false); } return(true); }; bodies.AddRange(ProgressUtilities.GetBodiesProgress(ProgressType.FLYBY, true, cb)); bodies.AddRange(ProgressUtilities.GetNextUnreached(4, cb)); break; } if (bodies.Count <= 0) { return(null); } body = bodies[rand.Next(0, bodies.Count)]; if (body == null) { return(null); } //Make sure our experiment is OK if (DMScience.Exp == null) { return(null); } if (!body.atmosphere && DMScience.Exp.requireAtmosphere) { return(null); } if (((ExperimentSituations)DMScience.Exp.situationMask & ExperimentSituations.InSpaceHigh) == ExperimentSituations.InSpaceHigh && ((ExperimentSituations)DMScience.Exp.situationMask & ExperimentSituations.InSpaceLow) == ExperimentSituations.InSpaceLow) { if (rand.Next(0, 2) == 0) { targetSituation = ExperimentSituations.InSpaceHigh; } else { targetSituation = ExperimentSituations.InSpaceLow; } } else if (((ExperimentSituations)DMScience.Exp.situationMask & ExperimentSituations.InSpaceHigh) == ExperimentSituations.InSpaceHigh) { targetSituation = ExperimentSituations.InSpaceHigh; } else { targetSituation = ExperimentSituations.InSpaceLow; } if (DMUtils.biomeRelevant(targetSituation, (int)DMScience.Exp.biomeMask) && targetSituation != ExperimentSituations.SrfSplashed) { List <string> bList = DMUtils.fetchBiome(body, DMScience.Exp, targetSituation); if (bList.Count == 0) { return(null); } else { biome = bList[rand.Next(0, bList.Count)]; } } //Make sure that our chosen science subject has science remaining to be gathered string subId = string.Format("{0}@{1}{2}{3}", DMScience.Exp.id, body.bodyName, targetSituation, biome.Replace(" ", "")); if (ResearchAndDevelopment.GetSubjects().Any(s => s.id == subId)) { sub = ResearchAndDevelopment.GetSubjectByID(subId); if (sub.scientificValue < 0.5f) { return(null); } } return(new DMCollectScience(body, targetSituation, "", name, 0)); }
private void scienceReceive(float sci, ScienceSubject sub) { if (type == 0 || type == 2) { if (!string.IsNullOrEmpty(biomeName)) { if (sub.id == subject) { if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION) { base.SetComplete(); } else { returnedScience += sci; if (returnedScience >= scienceContainer.exp.baseValue * scienceContainer.transmit * sub.subjectValue * 0.3f) { ScreenMessages.PostScreenMessage("DMagic Orbital Science Survey Parameter Complete", 4f, ScreenMessageStyle.UPPER_CENTER); base.SetComplete(); } else { ScreenMessages.PostScreenMessage("This area has already been studied, try investigating another region to complete the contract", 6f, ScreenMessageStyle.UPPER_CENTER); } } } } else { if (sub.id.Contains(subject)) { if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION) { base.SetComplete(); } else { returnedScience += sci; if (returnedScience >= scienceContainer.exp.baseValue * scienceContainer.transmit * sub.subjectValue * 0.3f) { ScreenMessages.PostScreenMessage("DMagic Orbital Science Survey Parameter Complete", 4f, ScreenMessageStyle.UPPER_CENTER); base.SetComplete(); } else { if (DMUtils.biomeRelevant(this.Situation, this.Container.bioMask)) { ScreenMessages.PostScreenMessage("This area has already been studied, try investigating another region to complete the contract", 6f, ScreenMessageStyle.UPPER_CENTER); } else { ScreenMessages.PostScreenMessage("Not enough science remaining; this experiment may need to be returned to Kerbin for credit", 6f, ScreenMessageStyle.UPPER_CENTER); } } } } } } else if (type == 1) { if (sub.id.Contains(subject)) { base.SetComplete(); } } }
//Used for initial orbital and surface survey parameter internal static DMCollectScience fetchSurveyScience(Contract.ContractPrestige c, List <CelestialBody> cR, List <CelestialBody> cUR, DMScienceContainer DMScience) { CelestialBody body; ExperimentSituations targetSituation; ScienceSubject sub; AvailablePart aPart; string name; string biome = ""; name = DMUtils.availableScience["All"].FirstOrDefault(n => n.Value == DMScience).Key; //Determine if the science part is available if applicable if (DMScience.SciPart != "None") { aPart = PartLoader.getPartInfoByName(DMScience.SciPart); if (aPart == null) { return(null); } if (!ResearchAndDevelopment.PartModelPurchased(aPart)) { return(null); } } body = DMUtils.nextTargetBody(c, cR, cUR); if (body == null) { return(null); } //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 && ((ExperimentSituations)DMScience.SitMask & ExperimentSituations.InSpaceLow) == ExperimentSituations.InSpaceLow) { if (rand.Next(0, 2) == 0) { targetSituation = ExperimentSituations.InSpaceHigh; } else { targetSituation = ExperimentSituations.InSpaceLow; } } else if (((ExperimentSituations)DMScience.SitMask & ExperimentSituations.InSpaceHigh) == ExperimentSituations.InSpaceHigh) { targetSituation = ExperimentSituations.InSpaceHigh; } else { targetSituation = ExperimentSituations.InSpaceLow; } if (DMUtils.biomeRelevant(targetSituation, DMScience.BioMask) && targetSituation != ExperimentSituations.SrfSplashed) { List <string> bList = DMUtils.fetchBiome(body, DMScience.Exp, targetSituation); if (bList.Count == 0) { return(null); } else { biome = bList[rand.Next(0, bList.Count)]; } } //Make sure that our chosen science subject has science remaining to be gathered string subId = string.Format("{0}@{1}{2}{3}", DMScience.Exp.id, body.name, targetSituation, biome.Replace(" ", "")); if (ResearchAndDevelopment.GetSubjects().Any(s => s.id == subId)) { sub = ResearchAndDevelopment.GetSubjectByID(subId); if (sub.scientificValue < 0.5f) { return(null); } } return(new DMCollectScience(body, targetSituation, "", name, 0)); }