// get readings tooltip public static string Telemetry_tooltip(Vessel v, VesselData vd, string type) { switch (type) { case "temperature": return(Lib.BuildString ( "<align=left />", String.Format("{0,-14}\t<b>{1}</b>\n", Local.Sensor_solarflux, Lib.HumanReadableFlux(vd.EnvSolarFluxTotal)), //"solar flux" String.Format("{0,-14}\t<b>{1}</b>\n", Local.Sensor_albedoflux, Lib.HumanReadableFlux(vd.EnvAlbedoFlux)), //"albedo flux" String.Format("{0,-14}\t<b>{1}</b>", Local.Sensor_bodyflux, Lib.HumanReadableFlux(vd.EnvBodyFlux)) //"body flux" )); case "radiation": return(string.Empty); case "habitat_radiation": return(Lib.BuildString ( "<align=left />", String.Format("{0,-14}\t<b>{1}</b>\n", Local.Sensor_environment, Lib.HumanReadableRadiation(vd.EnvRadiation, false)), //"environment" String.Format("{0,-14}\t<b>{1}</b>", Local.Sensor_habitats, Lib.HumanReadableRadiation(HabitatRadiation(vd), false)) //"habitats" )); case "pressure": return(vd.EnvUnderwater ? Local.Sensor_insideocean //"inside <b>ocean</b>" : vd.EnvInAtmosphere ? Local.Sensor_insideatmosphere.Format(vd.EnvBreathable ? Local.Sensor_breathable : Local.Sensor_notbreathable) //"breathable""not breathable" //Lib.BuildString("inside <b>atmosphere</b> (", vd.EnvBreathable ? "breathable" : "not breathable", ")") : Sim.InsideThermosphere(v) ? Local.Sensor_insidethermosphere //"inside <b>thermosphere</b>"" : Sim.InsideExosphere(v) ? Local.Sensor_insideexosphere //"inside <b>exosphere</b>" : string.Empty); case "gravioli": return(Lib.BuildString ( Local.Sensor_Graviolidetection + " <b>" + vd.EnvGravioli.ToString("F2") + "</b>\n\n", //"Gravioli detection events per-year: "<i>", Local.Sensor_info1, "\n", //The elusive negative gravioli particle\nseems to be much harder to detect than expected. Local.Sensor_info2, "</i>" //" On the other\nhand there seems to be plenty\nof useless positive graviolis around." )); } return(string.Empty); }
// get readings tooltip public static string Telemetry_tooltip(Vessel v, VesselData vd, string type) { switch (type) { case "temperature": return(Lib.BuildString ( "<align=left />", String.Format("{0,-14}\t<b>{1}</b>\n", "solar flux", Lib.HumanReadableFlux(vd.EnvSolarFluxTotal)), String.Format("{0,-14}\t<b>{1}</b>\n", "albedo flux", Lib.HumanReadableFlux(vd.EnvAlbedoFlux)), String.Format("{0,-14}\t<b>{1}</b>", "body flux", Lib.HumanReadableFlux(vd.EnvBodyFlux)) )); case "radiation": return(string.Empty); case "habitat_radiation": return(Lib.BuildString ( "<align=left />", String.Format("{0,-14}\t<b>{1}</b>\n", "environment", Lib.HumanReadableRadiation(vd.EnvRadiation, false)), String.Format("{0,-14}\t<b>{1}</b>", "habitats", Lib.HumanReadableRadiation(HabitatRadiation(vd), false)) )); case "pressure": return(vd.EnvUnderwater ? "inside <b>ocean</b>" : vd.EnvInAtmosphere ? Lib.BuildString("inside <b>atmosphere</b> (", vd.EnvBreathable ? "breathable" : "not breathable", ")") : Sim.InsideThermosphere(v) ? "inside <b>thermosphere</b>" : Sim.InsideExosphere(v) ? "inside <b>exosphere</b>" : string.Empty); case "gravioli": return(Lib.BuildString ( "Gravioli detection events per-year: <b>", vd.EnvGravioli.ToString("F2"), "</b>\n\n", "<i>The elusive negative gravioli particle\nseems to be much harder to detect\n", "than expected. On the other\nhand there seems to be plenty\nof useless positive graviolis around.</i>" )); } return(string.Empty); }
// get readings tooltip public static string telemetry_tooltip(Vessel v, vessel_info vi, string type) { switch (type) { case "temperature": return(Lib.BuildString ( "<align=left />", "solar flux\t<b>", Lib.HumanReadableFlux(vi.solar_flux), "</b>\n", "albedo flux\t<b>", Lib.HumanReadableFlux(vi.albedo_flux), "</b>\n", "body flux\t<b>", Lib.HumanReadableFlux(vi.body_flux), "</b>" )); case "radiation": return(string.Empty); case "pressure": return(vi.underwater ? "inside <b>ocean</b>" : vi.atmo_factor < 1.0 ? Lib.BuildString("inside <b>atmosphere</b> (", vi.breathable ? "breathable" : "not breathable", ")") : Sim.InsideThermosphere(v) ? "inside <b>thermosphere</b>" : Sim.InsideExosphere(v) ? "inside <b>exosphere</b>" : string.Empty); case "gravioli": return(Lib.BuildString ( "Gravioli detection events per-year: <b>", vi.gravioli.ToString("F2"), "</b>\n\n", "<i>The elusive negative gravioli particle\nseem to be much harder to detect\n", "than expected. On the other\nside there seems to be plenty\nof useless positive graviolis around.</i>" )); } return(string.Empty); }
public Vessel_info(Vessel v, UInt64 vessel_id, UInt64 inc) { // NOTE: anything used here can't in turn use cache, unless you know what you are doing // NOTE: you can't cache vessel position // at any point in time all vessel/body positions are relative to a different frame of reference // so comparing the current position of a vessel, with the cached one of another make no sense // associate with an unique incremental id this.inc = inc; // determine if this is a valid vessel is_vessel = Lib.IsVessel(v); if (!is_vessel) { return; } // determine if this is a rescue mission vessel is_rescue = Misc.IsRescueMission(v); if (is_rescue) { return; } // dead EVA are not valid vessels if (EVA.IsDead(v)) { return; } // shortcut for common tests is_valid = true; // generate id once id = vessel_id; // calculate crew info for the vessel crew_count = Lib.CrewCount(v); crew_capacity = Lib.CrewCapacity(v); // get vessel position Vector3d position = Lib.VesselPosition(v); // this should never happen again if (Vector3d.Distance(position, v.mainBody.position) < 1.0) { throw new Exception("Shit hit the fan for vessel " + v.vesselName); } // determine if there is enough EC for a powered state powered = ResourceCache.Info(v, "ElectricCharge").amount > double.Epsilon; // determine if in sunlight, calculate sun direction and distance sunlight = Sim.RaytraceBody(v, position, FlightGlobals.Bodies[0], out sun_dir, out sun_dist) ? 1.0 : 0.0; // environment stuff atmo_factor = Sim.AtmosphereFactor(v.mainBody, position, sun_dir); gamma_transparency = Sim.GammaTransparency(v.mainBody, v.altitude); underwater = Sim.Underwater(v); breathable = Sim.Breathable(v, underwater); landed = Lib.Landed(v); zerog = !landed && (!v.mainBody.atmosphere || v.mainBody.atmosphereDepth < v.altitude); if (v.mainBody.flightGlobalsIndex != 0 && TimeWarp.CurrentRate > 1000.0f) { highspeedWarp(v); } // temperature at vessel position temperature = Sim.Temperature(v, position, sunlight, atmo_factor, out solar_flux, out albedo_flux, out body_flux, out total_flux); temp_diff = Sim.TempDiff(temperature, v.mainBody, landed); // radiation radiation = Radiation.Compute(v, position, gamma_transparency, sunlight, out blackout, out magnetosphere, out inner_belt, out outer_belt, out interstellar); // extended atmosphere thermosphere = Sim.InsideThermosphere(v); exosphere = Sim.InsideExosphere(v); // malfunction stuff malfunction = Reliability.HasMalfunction(v); critical = Reliability.HasCriticalFailure(v); // communications info connection = new ConnectionInfo(v, powered, blackout); transmitting = Science.Transmitting(v, connection.linked && connection.rate > double.Epsilon); // habitat data volume = Habitat.Tot_volume(v); surface = Habitat.Tot_surface(v); pressure = Habitat.Pressure(v); evas = (uint)(Math.Max(0, ResourceCache.Info(v, "Nitrogen").amount - 330) / PreferencesLifeSupport.Instance.evaAtmoLoss); poisoning = Habitat.Poisoning(v); humidity = Habitat.Humidity(v); shielding = Habitat.Shielding(v); living_space = Habitat.Living_space(v); volume_per_crew = Habitat.Volume_per_crew(v); comforts = new Comforts(v, landed, crew_count > 1, connection.linked && connection.rate > double.Epsilon); // data about greenhouses greenhouses = Greenhouse.Greenhouses(v); // other stuff gravioli = Sim.Graviolis(v); }
private void EvaluateEnvironment(double elapsedSeconds) { UnityEngine.Profiling.Profiler.BeginSample("Kerbalism.VesselData.EvaluateStatus"); // we use analytic mode if more than 2 minutes of game time has passed since last evaluation (~ x6000 timewarp speed) isAnalytic = elapsedSeconds > 120.0; // get vessel position Vector3d position = Lib.VesselPosition(Vessel); // this should never happen again if (Vector3d.Distance(position, Vessel.mainBody.position) < 1.0) { throw new Exception("Shit hit the fan for vessel " + Vessel.vesselName); } // situation underwater = Sim.Underwater(Vessel); breathable = Sim.Breathable(Vessel, EnvUnderwater); landed = Lib.Landed(Vessel); inAtmosphere = Vessel.mainBody.atmosphere && Vessel.altitude < Vessel.mainBody.atmosphereDepth; zeroG = !EnvLanded && !inAtmosphere; visibleBodies = Sim.GetLargeBodies(position); // get solar info (with multiple stars / Kopernicus support) // get the 'visibleBodies' and 'sunsInfo' lists, the 'mainSun', 'solarFluxTotal' variables. // require the situation variables to be evaluated first UnityEngine.Profiling.Profiler.BeginSample("Kerbalism.VesselData.Sunlight"); SunInfo.UpdateSunsInfo(this, position); UnityEngine.Profiling.Profiler.EndSample(); sunBodyAngle = Sim.SunBodyAngle(Vessel, position, mainSun.SunData.body); // temperature at vessel position UnityEngine.Profiling.Profiler.BeginSample("Kerbalism.VesselData.Temperature"); temperature = Sim.Temperature(Vessel, position, solarFluxTotal, out albedoFlux, out bodyFlux, out totalFlux); tempDiff = Sim.TempDiff(EnvTemperature, Vessel.mainBody, EnvLanded); UnityEngine.Profiling.Profiler.EndSample(); // radiation UnityEngine.Profiling.Profiler.BeginSample("Kerbalism.VesselData.Radiation"); gammaTransparency = Sim.GammaTransparency(Vessel.mainBody, Vessel.altitude); bool new_innerBelt, new_outerBelt, new_magnetosphere; radiation = Radiation.Compute(Vessel, position, EnvGammaTransparency, mainSun.SunlightFactor, out blackout, out new_magnetosphere, out new_innerBelt, out new_outerBelt, out interstellar, out shieldedRadiation); if (new_innerBelt != innerBelt || new_outerBelt != outerBelt || new_magnetosphere != magnetosphere) { innerBelt = new_innerBelt; outerBelt = new_outerBelt; magnetosphere = new_magnetosphere; if (Evaluated) { API.OnRadiationFieldChanged.Notify(Vessel, innerBelt, outerBelt, magnetosphere); } } UnityEngine.Profiling.Profiler.EndSample(); thermosphere = Sim.InsideThermosphere(Vessel); exosphere = Sim.InsideExosphere(Vessel); inStorm = Storm.InProgress(Vessel); vesselSituations.Update(); // other stuff gravioli = Sim.Graviolis(Vessel); UnityEngine.Profiling.Profiler.EndSample(); }
public vessel_info(Vessel v, uint vessel_id, UInt64 inc) { // NOTE: anything used here can't in turn use cache, unless you know what you are doing // NOTE: you can't cache vessel position // at any point in time all vessel/body positions are relative to a different frame of reference // so comparing the current position of a vessel, with the cached one of another make no sense // associate with an unique incremental id this.inc = inc; // determine if this is a valid vessel is_vessel = Lib.IsVessel(v); if (!is_vessel) return; // determine if this is a rescue mission vessel is_rescue = Misc.IsRescueMission(v); if (is_rescue) return; // dead EVA are not valid vessels if (EVA.IsDead(v)) return; // shortcut for common tests is_valid = true; // generate id once id = vessel_id; // calculate crew info for the vessel crew_count = Lib.CrewCount(v); crew_capacity = Lib.CrewCapacity(v); // get vessel position Vector3d position = Lib.VesselPosition(v); // this should never happen again if (Vector3d.Distance(position, v.mainBody.position) < 1.0) { throw new Exception("Shit hit the fan for vessel " + v.vesselName); } // determine if in sunlight, calculate sun direction and distance sunlight = Sim.RaytraceBody(v, position, FlightGlobals.Bodies[0], out sun_dir, out sun_dist) ? 1.0 : 0.0; // at the two highest timewarp speed, the number of sun visibility samples drop to the point that // the quantization error first became noticeable, and then exceed 100% // to solve this, we switch to an analytical estimation of the portion of orbit that was in sunlight // - we check against timewarp rate, instead of index, to avoid issues during timewarp blending if (v.mainBody.flightGlobalsIndex != 0 && TimeWarp.CurrentRate > 1000.0f) { sunlight = 1.0 - Sim.ShadowPeriod(v) / Sim.OrbitalPeriod(v); } // environment stuff atmo_factor = Sim.AtmosphereFactor(v.mainBody, position, sun_dir); gamma_transparency = Sim.GammaTransparency(v.mainBody, v.altitude); underwater = Sim.Underwater(v); breathable = Sim.Breathable(v, underwater); landed = Lib.Landed(v); // temperature at vessel position temperature = Sim.Temperature(v, position, sunlight, atmo_factor, out solar_flux, out albedo_flux, out body_flux, out total_flux); temp_diff = Sim.TempDiff(temperature, v.mainBody, landed); // radiation radiation = Radiation.Compute(v, position, gamma_transparency, sunlight, out blackout, out magnetosphere, out inner_belt, out outer_belt, out interstellar); // extended atmosphere thermosphere = Sim.InsideThermosphere(v); exosphere = Sim.InsideExosphere(v); // malfunction stuff malfunction = Reliability.HasMalfunction(v); critical = Reliability.HasCriticalFailure(v); // signal info antenna = new AntennaInfo(v); avoid_inf_recursion.Add(v.id); connection = Signal.connection(v, position, antenna, blackout, avoid_inf_recursion); transmitting = Science.transmitting(v, connection.linked); relaying = Signal.relaying(v, avoid_inf_recursion); avoid_inf_recursion.Remove(v.id); // habitat data volume = Habitat.tot_volume(v); surface = Habitat.tot_surface(v); pressure = Habitat.pressure(v); poisoning = Habitat.poisoning(v); shielding = Habitat.shielding(v); living_space = Habitat.living_space(v); comforts = new Comforts(v, landed, crew_count > 1, connection.linked); // data about greenhouses greenhouses = Greenhouse.Greenhouses(v); // other stuff gravioli = Sim.Graviolis(v); }