void DrawGUIPrediction() { ReentrySimulation.Result result = predictor.Result; if (result != null) { switch (result.outcome) { case ReentrySimulation.Outcome.LANDED: GUILayout.Label("Landing Predictions:"); GUILayout.Label(Coordinates.ToStringDMS(result.endPosition.latitude, result.endPosition.longitude) + "\nASL:" + MuUtils.ToSI(result.endASL, -1, 4) + "m"); GUILayout.Label(ScienceUtil.GetExperimentBiome(result.body, result.endPosition.latitude, result.endPosition.longitude)); double error = Vector3d.Distance(mainBody.GetRelSurfacePosition(result.endPosition.latitude, result.endPosition.longitude, 0), mainBody.GetRelSurfacePosition(core.target.targetLatitude, core.target.targetLongitude, 0)); GUILayout.Label("Target difference = " + MuUtils.ToSI(error, 0) + "m" + "\nMax drag: " + result.maxDragGees.ToString("F1") + "g" + "\nDelta-v needed: " + result.deltaVExpended.ToString("F1") + "m/s" + "\nTime to land: " + (vessel.Landed ? "0.0s" : GuiUtils.TimeToDHMS(result.endUT - Planetarium.GetUniversalTime(), 1))); break; case ReentrySimulation.Outcome.AEROBRAKED: GUILayout.Label("Predicted orbit after aerobraking:"); Orbit o = result.AeroBrakeOrbit(); if (o.eccentricity > 1) { GUILayout.Label("Hyperbolic, eccentricity = " + o.eccentricity.ToString("F2")); } else { GUILayout.Label(MuUtils.ToSI(o.PeA, 3) + "m x " + MuUtils.ToSI(o.ApA, 3) + "m"); } GUILayout.Label("Max drag: " + result.maxDragGees.ToString("F1") + "g" + "\nExit atmosphere in: " + GuiUtils.TimeToDHMS(result.aeroBrakeUT - Planetarium.GetUniversalTime(), 1)); break; case ReentrySimulation.Outcome.NO_REENTRY: GUILayout.Label("Orbit does not reenter:\n" + MuUtils.ToSI(orbit.PeA, 3) + "m Pe > " + MuUtils.ToSI(mainBody.RealMaxAtmosphereAltitude(), 3) + (mainBody.atmosphere ? "m atmosphere height" : "m ground")); break; case ReentrySimulation.Outcome.TIMED_OUT: GUILayout.Label("Reentry simulation timed out."); break; } } }
public static string Generate_subject(string experiment_id, Vessel v) { var subject_id = Generate_subject_id(experiment_id, v); // in sandbox, do nothing else if (ResearchAndDevelopment.Instance == null) { return(subject_id); } // if the subject id was never added to RnD if (ResearchAndDevelopment.GetSubjectByID(subject_id) == null) { // get subjects container using reflection // - we tried just changing the subject.id instead, and // it worked but the new id was obviously used only after // putting RnD through a serialization->deserialization cycle var subjects = Lib.ReflectionValue <Dictionary <string, ScienceSubject> > ( ResearchAndDevelopment.Instance, "scienceSubjects" ); var experiment = ResearchAndDevelopment.GetExperiment(experiment_id); var sit = GetExperimentSituation(v); var biome = ScienceUtil.GetExperimentBiome(v.mainBody, v.latitude, v.longitude); float multiplier = sit.Multiplier(Experiment(experiment_id)); var cap = multiplier * experiment.baseValue; // create new subject ScienceSubject subject = new ScienceSubject ( subject_id, Lib.BuildString(experiment.experimentTitle, " (", Lib.SpacesOnCaps(sit + biome), ")"), experiment.dataScale, multiplier, cap ); // add it to RnD subjects.Add(subject_id, subject); } return(subject_id); }
protected override void OnUpdate() { Vessel v = FlightGlobals.ActiveVessel; if (v == null) { return; } // Need to do frequent checks to catch biome changes base.OnUpdate(); if (UnityEngine.Time.fixedTime - lastUpdate > UPDATE_FREQUENCY) { lastUpdate = UnityEngine.Time.fixedTime; string biome; if (landedSituations.Contains(v.situation) && !string.IsNullOrEmpty(v.landedAt)) { biome = Vessel.GetLandedAtString(v.landedAt).Replace(" ", ""); } else { biome = ScienceUtil.GetExperimentBiome(v.mainBody, v.latitude, v.longitude); } // Run the OnVesselChange, this will pick up a kerbal that grabbed science, // or science that was dumped from a pod. if (updateTicks++ % 4 == 0) { OnVesselChange(v); } else { // Check if there was a biome change if (biome != lastBiome) { // Update the delegates, that will do the biome check UpdateDelegates(); } } lastVessel = v; lastBiome = biome; } }
private void UpdateKscBiomes() { //var StartTime = DateTime.Now; //if (LoadStatus.KSCBiomes) // return; if (_homeWorld == null) { _homeWorld = FlightGlobals.GetHomeBody(); } if (!LoadStatus.KSCBiomes && SpaceCenter.Instance != null) { _kscBiome = null; var lat = SpaceCenter.Instance.Latitude; var lng = SpaceCenter.Instance.Longitude; _kscBiome = ScienceUtil.GetExperimentBiome(_homeWorld, lat, lng); //_logger.Trace( "KSC is in the " + biome + " biome" ); LoadStatus.KSCBiomes = true; } // Find the KSC baby biomes // This is throwing exceptions. I think the callback is being thrown before the world is finished updating. if (_homeWorld != null) { _kscBiomes.Clear(); _kscBiomes = UnityEngine.Object.FindObjectsOfType <Collider>() .Where(x => x.gameObject.layer == 15) .Select(x => x.gameObject.tag) .Where(x => x != "Untagged") .Where(x => !x.Contains("KSC_Runway_Light")) .Where(x => !x.Contains("KSC_Pad_Flag_Pole")) .Where(x => !x.Contains("Ladder")) .Select(x => Vessel.GetLandedAtString(x)) .Select(x => x.Replace(" ", "")) .Distinct() .ToList(); } //LoadStatus.KSCBiomes = true; /*_logger.Trace( "_kscBiomes contains " + _kscBiomes.Count.ToString( ) + " items" ); * var Elapsed = DateTime.Now - StartTime; * _logger.Trace( "UpdateKscBiomes Done - " + Elapsed.ToString( ) + "ms" );*/ }
public void FixedUpdate() { foreach (Vessel v in FlightGlobals.Vessels) { ScienceAIVesselModule mod = v.GetComponent <ScienceAIVesselModule>(); if (mod.active) { String biome = ScienceUtil.GetExperimentBiome(v.mainBody, v.latitude, v.longitude); ExperimentSituations situation = ScienceUtil.GetExperimentSituation(v); foreach (ScienceAIExperiment experiment in mod.experiments) { if (ValidateExperiment(experiment, situation, mod, v)) { RunExperiment(experiment, situation, mod, v, biome); } } } } }
private void OnGUI() { if (HighLogic.LoadedSceneIsEditor) { return; } // if (MapView.MapIsEnabled) // { // if (wayPoints.Count > 0) // { // GLUtils.DrawCurve (wayPoints); // } // } if (mapLocationMode) { if (!MapView.MapIsEnabled) { mapLocationMode = false; return; } PlaceTargetAtCursor(); GUI.Label( new Rect(Input.mousePosition.x + 15, Screen.height - Input.mousePosition.y, 200, 50), "Latitude:" + this.targetLatitude.ToString("F") + "\n" + "Longitude:" + this.targetLongitude.ToString("F") + "\n" + "Biome:" + ScienceUtil.GetExperimentBiome(this.vessel.mainBody, targetLatitude, targetLongitude) ); // Lock the waypoint if user clicks if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { FindPath(); if (distanceToTarget > 0) { mapLocationMode = false; MapView.ExitMapView(); } } } }
public override void TransmitData() { ThrowIfNotCPUVessel(); // This logic is mostly copied to DMScienceExperimentFields, make sure that changes here are copied there ScienceData[] data = container.GetData(); ScienceData scienceData; for (int i = 0; i < data.Length; ++i) { scienceData = data[i]; // By using ExperimentResultDialogPage we ensure that the logic calculating the value is exactly the same // as that used KSP's dialog. The page type doesn't include any UI code itself, it just does the math to // confirm the values, and stores some callbacks for the UI to call when buttons are pressed. ExperimentResultDialogPage page = new ExperimentResultDialogPage( module.part, scienceData, scienceData.baseTransmitValue, scienceData.transmitBonus, // the parameters with data we care aboue false, "", false, // disable transmit warning and reset option, these are used for the UI only new ScienceLabSearch(module.part.vessel, scienceData), // this is used to calculate the transmit bonus, I think... null, null, null, null); // null callbacks, no sense in creating objects when we won't actually perform the callback. // The dialog page modifies the referenced object, so our reference has been updated. } // Logic pulled from ModuleScienceExperiment.sendDataToComms IScienceDataTransmitter bestTransmitter = ScienceUtil.GetBestTransmitter(module.vessel); if (bestTransmitter != null) { bestTransmitter.TransmitData(data.ToList()); for (int i = 0; i < data.Length; ++i) { container.DumpData(data[i]); // DumpData calls endExperiment, and handles setting as inoperable } if (module.useCooldown) { module.cooldownToGo = module.cooldownTimer; } } else { ScreenMessages.PostScreenMessage("No transmitters available on this vessel or no data to transmit.", 4f, ScreenMessageStyle.UPPER_LEFT); } }
public static string Generate_subject_id(string experiment_id, Vessel v) { var body = v.mainBody; ScienceExperiment experiment = ResearchAndDevelopment.GetExperiment(experiment_id); ExperimentSituation sit = GetExperimentSituation(v); var sitStr = sit.ToString(); if (!string.IsNullOrEmpty(sitStr)) { if (sit.BiomeIsRelevant(Experiment(experiment_id))) { sitStr += ScienceUtil.GetExperimentBiome(v.mainBody, v.latitude, v.longitude); } } // generate subject id return(Lib.BuildString(experiment_id, "@", body.name, sitStr)); }
public bool GetBiome(double lat, double lon, out string biome) { biome = string.Empty; var vessel = FlightGlobals.ActiveVessel; if (vessel == null || vessel.mainBody.BiomeMap == null || vessel.mainBody.BiomeMap.MapName == null || vessel.mainBody.BiomeMap.Attributes.Length == 0) { return(false); } if (!string.IsNullOrEmpty(vessel.landedAt)) { biome = Vessel.GetLandedAtString(vessel.landedAt); return(true); } biome = ScienceUtil.GetExperimentBiome(vessel.mainBody, lat, lon); return(true); }
public void TransmitData(List <ScienceData> dataQueue, Callback callback) { Log.Debug("ALERT:MagicTransmitter: received {0} ScienceData entries", dataQueue.Count); Log.Debug(callback == null ? "ALERT: with no callback" : "ALERT:With callback"); List <IScienceDataTransmitter> list = new List <IScienceDataTransmitter>(); foreach (KeyValuePair <IScienceDataTransmitter, KeyValuePair <List <ScienceData>, Callback> > current in realTransmitters) { list.Add(current.Key); } if (list.Any()) { list = (from potential in list orderby ScienceUtil.GetTransmitterScore(potential) select potential).ToList(); QueueTransmission(dataQueue, list.First(), callback); return; } Log.Debug("[ScienceAlert]:MagicDataTransmitter: Did not find any real transmitters"); }
///<summary> ///returns the name of the Biome at the vessels postition ///</summary> public StringValue GetCurrentBiome() { var vessel = shared.Vessel; var body = vessel.mainBody; var Biome = ""; // check if we have crew onboard, which can look outside of a window, to determinate where we are or have we kerbnet access if ((HasKerbNet("Biome")) || (vessel.GetCrewCount() > 0) || (SCANWrapper.IsCovered(vessel.longitude, vessel.latitude, body, "Biome"))) { Biome = string.IsNullOrEmpty(vessel.landedAt) ? ScienceUtil.GetExperimentBiome(body, vessel.latitude, vessel.longitude) : Vessel.GetLandedAtString(vessel.landedAt).Replace(" ", ""); } else { Biome = GetScannedBiomeName(body, vessel.longitude, vessel.latitude); } return(Biome); }
public void doScience(CelestialBody planet) { Utilities.Log_Debug("Doing Science for {0}", planet.name); ScienceExperiment experiment = ResearchAndDevelopment.GetExperiment(ExperimentID); Utilities.Log_Debug("Got experiment"); ExperimentSituations situation = ScienceUtil.GetExperimentSituation(vessel); if (experiment.IsAvailableWhile(ScienceUtil.GetExperimentSituation(vessel), planet)) { string biomeID = ""; string displaybiomeID = string.Empty; if (part.vessel.landedAt != string.Empty) { biomeID = Vessel.GetLandedAtString(part.vessel.landedAt); displaybiomeID = Localizer.Format(part.vessel.displaylandedAt); } else { biomeID = ScienceUtil.GetExperimentBiome(planet, FlightGlobals.ship_latitude, FlightGlobals.ship_longitude); displaybiomeID = ScienceUtil.GetBiomedisplayName(vessel.mainBody, biomeID); } ScienceSubject subject = ResearchAndDevelopment.GetExperimentSubject(experiment, situation, planet, biomeID, displaybiomeID); Utilities.Log_Debug("Got subject"); ScienceData data = new ScienceData(experiment.baseValue * subject.dataScale, xmitDataScalar, labBoostScalar, subject.id, subject.title, false, part.flightID); Utilities.Log_Debug("Got data"); _scienceData.Add(data); Utilities.Log_Debug("Added Data"); ScreenMessages.PostScreenMessage(Localizer.Format("#autoLOC_238419", part.partInfo.title, data.dataAmount.ToString(), subject.title), 8f, ScreenMessageStyle.UPPER_LEFT); ReviewDataItem(data); if (TSTProgressTracker.isActive) { TSTProgressTracker.OnChemCamFire(planet, biomeID); } } else { ScreenMessages.PostScreenMessage(Localizer.Format("#autoLOC_238424", experiment.experimentTitle), 5f, ScreenMessageStyle.UPPER_CENTER); } updateAvailableEvents(); }
public virtual bool CanRunExperiment(ModuleScienceExperimentWrapper <T> baseExperiment, float currentScienceValue) { Log(baseExperiment.experimentID, ": CanRunExperiment"); if (!baseExperiment.experiment.IsAvailableWhile(ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel), FlightGlobals.currentMainBody))// { Log(baseExperiment.experimentID, ": Experiment isn't available in the current situation: ", ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel), "_", FlightGlobals.currentMainBody + "_", baseExperiment.experiment.situationMask); return(false); } if (baseExperiment.Inoperable) { Log(baseExperiment.experimentID, ": Experiment is inoperable"); return(false); } if (baseExperiment.Deployed && !baseExperiment.rerunnable) { Log(baseExperiment.experimentID, ": Experiment is deployed"); return(false); } if (!baseExperiment.rerunnable && !_AutomatedScienceSamplerInstance.craftSettings.oneTimeOnly) { Log(baseExperiment.experimentID, ": Runing rerunable experiments is disabled"); return(false); } if (currentScienceValue < _AutomatedScienceSamplerInstance.craftSettings.threshold) { Log(baseExperiment.experimentID, ": Science value is less than cutoff threshold: ", currentScienceValue, "<", _AutomatedScienceSamplerInstance.craftSettings.threshold); return(false); } if (baseExperiment.GetData().Length > 0) { Log(baseExperiment.experimentID, ": Experiment already contains results!"); return(false); } if (!baseExperiment.experiment.IsUnlocked()) { Log(baseExperiment.experimentID, ": Experiment is locked"); return(false); } return(true); }
private bool CheckBiome(Vessel vessel) { if (vessel == null) { return(false); } string vesselBiome = null; if (landedSituations.Contains(vessel.situation) && !string.IsNullOrEmpty(vessel.landedAt)) { // Fixes problems with special biomes like KSC buildings (total different naming) vesselBiome = Vessel.GetLandedAtString(vessel.landedAt); } else { vesselBiome = ScienceUtil.GetExperimentBiome(vessel.mainBody, vessel.latitude, vessel.longitude); } return(vesselBiome.Replace(" ", "") == biome.Replace(" ", "")); }
protected override bool canConduct() { failMessage = ""; if (Inoperable) { failMessage = "Experiment is no longer functional; must be reset at a science lab or returned to Kerbin"; return(false); } else if (Deployed) { failMessage = experimentFullMessage; return(false); } else if (scienceReports.Count > 0) { failMessage = experimentFullMessage; return(false); } else if (vessel.situation != Vessel.Situations.LANDED && vessel.situation != Vessel.Situations.PRELAUNCH && !DMAsteroidScience.AsteroidGrappled) { failMessage = customFailMessage; return(false); } else if (FlightGlobals.ActiveVessel.isEVA) { if (!ScienceUtil.RequiredUsageExternalAvailable(part.vessel, FlightGlobals.ActiveVessel, (ExperimentUsageReqs)usageReqMaskExternal, exp, ref usageReqMessage)) { failMessage = usageReqMessage; return(false); } else { return(true); } } else { return(true); } }
protected void getResultsText() { List <string> results = new List <string>(); string situation = ScienceUtil.GetExperimentSituation(part.vessel).ToString(); ScienceExperiment experiment = ResearchAndDevelopment.GetExperiment(scienceLab.experimentID); string resultKey; this.WindowTitle = experiment.experimentTitle + " from " + this.part.vessel.mainBody.name + "'s " + Utils.GetCurrentBiome(this.part.vessel).name; foreach (string key in experiment.Results.Keys) { resultKey = key.Replace("*", ""); if (resultKey.Contains(situation)) { results.Add(experiment.Results[key]); } } if (results.Count == 0) { if (experiment.Results.ContainsKey("default")) { resultsText = experiment.Results["default"]; } else { resultsText = "You've done some basic research."; } return; } int resultIndex = UnityEngine.Random.Range(0, results.Count); if (resultIndex >= results.Count) { resultIndex = results.Count - 1; } resultsText = results[resultIndex]; }
/// <summary> /// Pick target in the map mode /// </summary> void OnGUI() { if (BonVoyage.Instance.GamePaused && !BonVoyage.Instance.ShowUI) { return; } // Pick target in the map mode if (BonVoyage.Instance.MapMode) { if (!MapView.MapIsEnabled) { BonVoyage.Instance.MapMode = false; return; } double[] latLon = Tools.PlaceTargetAtCursor(vessel.mainBody); if (latLon[0] != double.MinValue) { GUI.Label( new Rect(Input.mousePosition.x + 20, Screen.height - Input.mousePosition.y, 200, 55), Localizer.Format("#LOC_BV_Control_Lat") + ": " + latLon[0].ToString("F") + "\n" + Localizer.Format("#LOC_BV_Control_Lon") + ": " + latLon[1].ToString("F") + "\n" + Localizer.Format("#LOC_BV_Control_Biome") + ": " + ScienceUtil.GetExperimentBiome(vessel.mainBody, latLon[0], latLon[1]) ); // On left mouse click send coordinates and exit map mode if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { BonVoyage.Instance.MapMode = false; MapView.ExitMapView(); if (BonVoyage.Instance.ControlModel != null) { BonVoyage.Instance.ControlModel.Latitude = latLon[0].ToString(); BonVoyage.Instance.ControlModel.Longitude = latLon[1].ToString(); BonVoyage.Instance.ControlModel.SetButtonClicked(); } } } } }
private void onTransmitData(ScienceData data) { resultsDialog = null; IScienceDataTransmitter bestTransmitter = ScienceUtil.GetBestTransmitter(vessel); if (bestTransmitter != null) { bestTransmitter.TransmitData(new List <ScienceData> { data }); DumpData(data); } else if (CommNet.CommNetScenario.CommNetEnabled) { ScreenMessages.PostScreenMessage("No usable, in-range Comms Devices on this vessel. Cannot Transmit Data.", 3f, ScreenMessageStyle.UPPER_CENTER); } else { ScreenMessages.PostScreenMessage("No Comms Devices on this vessel. Cannot Transmit Data.", 3f, ScreenMessageStyle.UPPER_CENTER); } }
public ScienceSubject GetScienceSubject(ModuleScienceExperiment baseExperiment) { var currentExperiment = baseExperiment as DMModuleScienceAnimate; if (DMAPI.isAsteroidGrappled(baseExperiment)) { return(DMAPI.getAsteroidSubject(currentExperiment)); } else { ExperimentSituations situation = ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel); var biome = DMAPI.getBiome(baseExperiment, situation); if (biome == null) { Log("Biome is null."); return(null); } var scienceSubject = ResearchAndDevelopment.GetExperimentSubject(ResearchAndDevelopment.GetExperiment(currentExperiment.experimentID), situation, FlightGlobals.currentMainBody, biome, ScienceUtil.GetBiomedisplayName(FlightGlobals.currentMainBody, biome)); Log(biome, "_", situation, "_", scienceSubject == null); return(scienceSubject); } }
private void onTransmitData(ScienceData data) { resultsDialog = null; IScienceDataTransmitter bestTransmitter = ScienceUtil.GetBestTransmitter(vessel); if (bestTransmitter != null) { bestTransmitter.TransmitData(new List <ScienceData> { data }); DumpData(data); } else if (CommNet.CommNetScenario.CommNetEnabled) { ScreenMessages.PostScreenMessage(Localizer.Format("#autoLOC_237738"), 3f, ScreenMessageStyle.UPPER_CENTER); } else { ScreenMessages.PostScreenMessage(Localizer.Format("#autoLOC_237740"), 3f, ScreenMessageStyle.UPPER_CENTER); } }
public void gatherScienceData(bool silent = false) { if (FlightGlobals.ActiveVessel.isEVA) { if (!ScienceUtil.RequiredUsageExternalAvailable(part.vessel, FlightGlobals.ActiveVessel, (ExperimentUsageReqs)usageReqMaskExternal, exp, ref usageReqMessage)) { ScreenMessages.PostScreenMessage(usageReqMessage, 6f, ScreenMessageStyle.UPPER_LEFT); return; } } if (receiverInRange && asteroidInSight) { ModuleAsteroid modAst = null; float distance = asteroidScanLength(out modAst); runExperiment(distance, modAst, silent); } else { ScreenMessages.PostScreenMessage("No valid targets within scaning range", 5f, ScreenMessageStyle.UPPER_CENTER); } }
private void OnTransmitData(ScienceData data) { _expDialog = null; IScienceDataTransmitter transmitter = ScienceUtil.GetBestTransmitter(FlightGlobals.ActiveVessel); if (transmitter != null) { transmitter.TransmitData(new List <ScienceData> { data }); DumpData(data); } else if (CommNet.CommNetScenario.CommNetEnabled) { Utils.DisplayScreenMsg(Localizer.Format("#autoLOC_237738")); } else { Utils.DisplayScreenMsg(Localizer.Format("#autoLOC_237740")); } //UpdateUI(); }
public static float GetAbundance(string resourceName, CelestialBody body, double lat, double lon) { var biome = ScienceUtil.GetExperimentBiome(body, lat, lon); var key = new Key(resourceName, biome, lat, lon); if (!cache.ContainsKey(key)) { var req = new AbundanceRequest { Latitude = lat, Longitude = lon, BodyId = body.flightGlobalsIndex, ResourceName = resourceName, ResourceType = HarvestTypes.Planetary, Altitude = 0, CheckForLock = false, BiomeName = biome, ExcludeVariance = false, }; cache[key] = ResourceMap.Instance.GetAbundance(req); } return(cache[key]); }
/// <summary> /// Recalculates the current situation of the active vessel. /// </summary> public void RecalculateSituation() { var vessel = FlightGlobals.ActiveVessel; if (vessel == null) { if (_filter.CurrentSituation != null) { _filter.CurrentSituation = null; } return; } var body = vessel.mainBody; var situation = ScienceUtil.GetExperimentSituation(vessel); var biome = ScienceUtil.GetExperimentBiome(body, vessel.latitude, vessel.longitude); var subBiome = string.IsNullOrEmpty(vessel.landedAt) ? null : Vessel.GetLandedAtString(vessel.landedAt).Replace(" ", ""); var dataCount = vessel.FindPartModulesImplementing <IScienceDataContainer>().Sum(x => x.GetData().Length); if (_lastDataCount != dataCount) { _lastDataCount = dataCount; UpdateExperiments(); } if (_filter.CurrentSituation != null && _filter.CurrentSituation.Biome == biome && _filter.CurrentSituation.ExperimentSituation == situation && _filter.CurrentSituation.Body.CelestialBody == body && _filter.CurrentSituation.SubBiome == subBiome) { return; } var Body = new Body(body); _filter.CurrentSituation = new Situation(Body, situation, biome, subBiome); }
public static FishType GetFishType(CelestialBody body, double latitude, double longitude) { if (body.isHomeWorld && Util.adminArea.Contains(new Vector2((float)latitude, (float)longitude))) { return(FishType.Pond); } string biome = body.isHomeWorld ? ScienceUtil.GetExperimentBiome(body, latitude, longitude) : "Water"; if (biome != "Water" && biome != "Shores") { return(FishType.Freshwater); } else { // Calculate the terrain height double height = Util.TerrainHeight(body, latitude, longitude); if (height > -150) { return(FishType.Coastal); } else if (height > -1000) { return(FishType.Ocean); } else if (height > -2500) { return(FishType.DeepOcean); } else { return(FishType.Kraken); } } }
void OnCalculateBackgroundRadiationTemperature(ModularFlightIntegrator flightIntegrator) { Vessel vessel = flightIntegrator?.Vessel; CelestialBody _body = GetComponent <CelestialBody>(); if (_body != vessel.mainBody) { return; } if (!string.IsNullOrEmpty(biomeName)) { String biome = ScienceUtil.GetExperimentBiome(_body, vessel.latitude, vessel.longitude); if (biomeName != biome) { return; } } Double altitude = altitudeCurve.Evaluate((Single)Vector3d.Distance(vessel.transform.position, _body.transform.position)); Double latitude = latitudeCurve.Evaluate((Single)vessel.latitude); Double longitude = longitudeCurve.Evaluate((Single)vessel.longitude); Double newTemp = altitude * latitude * longitude * ambientTemp; if (heatMap) { Double x = ((450 - vessel.longitude) % 360) / 360.0; Double y = (vessel.latitude + 90) / 180.0; Double m = heatMap.GetPixelFloat(x, y); newTemp *= m; } KopernicusHeatManager.NewTemp(newTemp, sumTemp); }
private static string currentBiome(ScienceExperiment e, Vessel v) { if (e == null) { return(""); } if (v == null) { return(""); } if (!e.BiomeIsRelevantWhile(ExperimentSituations.SrfLanded)) { return(""); } if (string.IsNullOrEmpty(v.landedAt)) { return(ScienceUtil.GetExperimentBiome(v.mainBody, v.latitude, v.longitude)); } return(Vessel.GetLandedAtString(v.landedAt)); }
/// <summary> /// Locate a suitable transmitter and queue this data up for it /// </summary> /// <param name="data"></param> void IScienceDataTransmitter.TransmitData(ScienceDataList data) { Log.Debug("MagicTransmitter: received {0} ScienceData entries", data.Count); // locate the best actual transmitter to send this data through // lower scores seem to be better var potentials = new List <IScienceDataTransmitter>(); foreach (var kvp in realTransmitters) { potentials.Add(kvp.Key); } if (potentials.Count > 0) { potentials = potentials.OrderBy(potential => ScienceUtil.GetTransmitterScore(potential)).ToList(); QueueTransmission(data, potentials.First()); } else { Log.Error("MagicDataTransmitter: Did not find any real transmitters"); } }
private static string currentDisplayBiome(ScienceExperiment e, Vessel v) { if (e == null) { return(""); } if (v == null) { return(""); } if (!e.BiomeIsRelevantWhile(ExperimentSituations.SrfLanded)) { return(""); } if (string.IsNullOrEmpty(v.displaylandedAt)) { return(Localizer.Format(ScienceUtil.GetExperimentBiomeLocalized(v.mainBody, v.latitude, v.longitude))); } return(Localizer.Format(v.displaylandedAt)); }
public bool canConduct() { if (!receiverInRange) { failMessage = "No receivers detected within scanning range"; return(false); } else if (!asteroidInSight) { failMessage = "No valid targets within scanning range"; return(false); } if (FlightGlobals.ActiveVessel.isEVA) { if (!ScienceUtil.RequiredUsageExternalAvailable(part.vessel, FlightGlobals.ActiveVessel, (ExperimentUsageReqs)usageReqMaskExternal, exp, ref usageReqMessage)) { failMessage = usageReqMessage; return(false); } } return(true); }