Example #1
0
        // specifics support
        public Specifics Specs()
        {
            Specifics specs = new Specifics();

            specs.add("Havest size", Lib.HumanReadableAmount(crop_size, " " + crop_resource));
            specs.add("Harvest time", Lib.HumanReadableDuration(1.0 / crop_rate));
            specs.add("Lighting tolerance", Lib.HumanReadableFlux(light_tolerance));
            if (pressure_tolerance > double.Epsilon)
            {
                specs.add("Pressure tolerance", Lib.HumanReadablePressure(Sim.PressureAtSeaLevel() * pressure_tolerance));
            }
            if (radiation_tolerance > double.Epsilon)
            {
                specs.add("Radiation tolerance", Lib.HumanReadableRadiation(radiation_tolerance));
            }
            specs.add("Lamps EC rate", Lib.HumanReadableRate(ec_rate));
            specs.add(string.Empty);
            specs.add("<color=#00ffff>Required resources</color>");
            foreach (ModuleResource input in resHandler.inputResources)
            {
                specs.add(input.name, Lib.BuildString("<color=#ff0000>", Lib.HumanReadableRate(input.rate), "</color>"));
            }
            specs.add(string.Empty);
            specs.add("<color=#00ffff>By-products</color>");
            foreach (ModuleResource output in resHandler.outputResources)
            {
                specs.add(output.name, Lib.BuildString("<color=#00ff00>", Lib.HumanReadableRate(output.rate), "</color>"));
            }
            return(specs);
        }
Example #2
0
  void render_environment(Vessel v, vessel_info vi)
  {
    // determine atmosphere
    string atmo_desc = "none";
    if (Sim.Underwater(v)) atmo_desc = "ocean";
    else if (vi.atmo_factor < 1.0) //< inside an atmosphere
    {
      atmo_desc = vi.breathable ? "breathable" : "not breathable";
    }

    render_title("ENVIRONMENT");
    render_content("temperature", Lib.HumanReadableTemp(vi.temperature));
    render_content("radiation", Lib.HumanReadableRadiationRate(vi.radiation));
    render_content("atmosphere", atmo_desc);
    if (Settings.ShowFlux)
    {
      render_content("solar flux", Lib.HumanReadableFlux(vi.solar_flux));
      render_content("albedo flux", Lib.HumanReadableFlux(vi.albedo_flux));
      render_content("body flux", Lib.HumanReadableFlux(vi.body_flux));
    }
    if (Settings.RelativisticTime)
    {
      render_content("time dilation", Lib.HumanReadablePerc(1.0 / vi.time_dilation));
    }
    render_space();
  }
Example #3
0
  // called every frame
  public void Update()
  {
    if (HighLogic.LoadedSceneIsEditor) return;

    // get info from cache
    vessel_info vi = Cache.VesselInfo(this.vessel);

    // do nothing if vessel is invalid
    if (!vi.is_valid) return;

    // set reading
    switch(type)
    {
      case "temperature": Status = Lib.HumanReadableTemp(vi.temperature); break;
      case "radiation": Status = vi.radiation > double.Epsilon ? Lib.HumanReadableRadiationRate(vi.radiation) : "nominal"; break;
      case "solar_flux": Status = Lib.HumanReadableFlux(vi.solar_flux); break;
      case "albedo_flux": Status = Lib.HumanReadableFlux(vi.albedo_flux); break;
      case "body_flux": Status = Lib.HumanReadableFlux(vi.body_flux); break;
    }

    // manage pin animation on geiger counter
    if (pinanim != null && type == "radiation")
    {
      pinanim["pinanim"].normalizedTime = Lib.Clamp(pinfc.Evaluate((float)(vi.radiation * 3600.0)), 0.0f, 1.0f);
      pinanim.Play();
    }
  }
Example #4
0
        // specifics support
        public Specifics Specs()
        {
            Specifics specs = new Specifics();

            specs.Add("Harvest size", Lib.HumanReadableAmount(crop_size, " " + crop_resource));
            specs.Add("Harvest time", Lib.HumanReadableDuration(1.0 / crop_rate));
            specs.Add("Lighting tolerance", Lib.HumanReadableFlux(light_tolerance));
            if (pressure_tolerance > double.Epsilon)
            {
                specs.Add("Pressure tolerance", Lib.HumanReadablePressure(Sim.PressureAtSeaLevel() * pressure_tolerance));
            }
            if (radiation_tolerance > double.Epsilon)
            {
                specs.Add("Radiation tolerance", Lib.HumanReadableRadiation(radiation_tolerance));
            }
            specs.Add("Lamps EC rate", Lib.HumanReadableRate(ec_rate));
            specs.Add(string.Empty);
            specs.Add("<color=#00ffff>Required resources</color>");

            // do we have combined WasteAtmosphere and CO2
            Set_WACO2();
            bool dis_WACO2 = false;

            foreach (ModuleResource input in resHandler.inputResources)
            {
                // combine WasteAtmosphere and CO2 if both exist
                if (WACO2 && (input.name == "WasteAtmosphere" || input.name == "CarbonDioxide"))
                {
                    if (dis_WACO2)
                    {
                        continue;
                    }
                    ModuleResource sec;
                    if (input.name == "WasteAtmosphere")
                    {
                        sec = resHandler.inputResources.Find(x => x.name.Contains("CarbonDioxide"));
                    }
                    else
                    {
                        sec = resHandler.inputResources.Find(x => x.name.Contains("WasteAtmosphere"));
                    }
                    specs.Add("CarbonDioxide", Lib.BuildString("<color=#ffaa00>", Lib.HumanReadableRate(input.rate + sec.rate), "</color>"));
                    specs.Add("Crops can also use the CO2 in the atmosphere without a scrubber.");
                    dis_WACO2 = true;
                }
                else
                {
                    specs.Add(input.name, Lib.BuildString("<color=#ffaa00>", Lib.HumanReadableRate(input.rate), "</color>"));
                }
            }
            specs.Add(string.Empty);
            specs.Add("<color=#00ffff>By-products</color>");
            foreach (ModuleResource output in resHandler.outputResources)
            {
                specs.Add(output.name, Lib.BuildString("<color=#00ff00>", Lib.HumanReadableRate(output.rate), "</color>"));
            }
            return(specs);
        }
Example #5
0
        // 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);
        }
Example #6
0
        public void Update()
        {
            // set lamps emissive object
            if (lamps_rdr != null)
            {
                float intensity = Lib.IsFlight() ? (active ? (float)(artificial / light_tolerance) : 0.0f) : (active ? 1.0f : 0.0f);
                lamps_rdr.material.SetColor("_EmissiveColor", new Color(intensity, intensity, intensity, 1.0f));
            }

            // in flight
            if (Lib.IsFlight())
            {
                // still-play plants animation
                if (plants_anim != null)
                {
                    plants_anim.Still(growth);
                }

                // update ui
                string status = issue.Length > 0 ? Lib.BuildString("<color=yellow>", issue, "</color>") : growth > 0.99 ? "ready to harvest" : "growing";
                Events["Toggle"].guiName              = Lib.StatusToggle("Greenhouse", active ? status : "disabled");
                Fields["status_natural"].guiActive    = active && growth < 0.99;
                Fields["status_artificial"].guiActive = active && growth < 0.99;
                Fields["status_tta"].guiActive        = active && growth < 0.99;
                status_natural    = Lib.HumanReadableFlux(natural);
                status_artificial = Lib.HumanReadableFlux(artificial);
                status_tta        = Lib.HumanReadableDuration(tta);

                // show/hide harvest buttons
                bool manned = FlightGlobals.ActiveVessel.isEVA || Lib.CrewCount(vessel) > 0;
                Events["Harvest"].active          = manned && growth >= 0.99;
                Events["EmergencyHarvest"].active = manned && growth >= 0.5 && growth < 0.99;
            }
            // in editor
            else
            {
                // update ui
                Events["Toggle"].guiName = Lib.StatusToggle("Greenhouse", active ? "enabled" : "disabled");
            }
        }
Example #7
0
        static void Render_greenhouse(Panel p, VesselData vd)
        {
            // do nothing without greenhouses
            if (vd.Greenhouses.Count == 0)
            {
                return;
            }

            // panel section
            p.AddSection(Local.TELEMETRY_GREENHOUSE);            //"GREENHOUSE"

            // for each greenhouse
            for (int i = 0; i < vd.Greenhouses.Count; ++i)
            {
                var greenhouse = vd.Greenhouses[i];

                // state string
                string state = greenhouse.issue.Length > 0
                                  ? Lib.Color(greenhouse.issue, Lib.Kolor.Yellow)
                                  : greenhouse.growth >= 0.99
                                  ? Lib.Color(Local.TELEMETRY_readytoharvest, Lib.Kolor.Green) //"ready to harvest"
                                  : Local.TELEMETRY_growing;                                   //"growing"

                // tooltip with summary
                string tooltip = greenhouse.growth < 0.99 ? Lib.BuildString
                                 (
                    "<align=left />",
                    Local.TELEMETRY_timetoharvest, "\t<b>", Lib.HumanReadableDuration(greenhouse.tta), "</b>\n",        //"time to harvest"
                    Local.TELEMETRY_growth, "\t\t<b>", Lib.HumanReadablePerc(greenhouse.growth), "</b>\n",              //"growth"
                    Local.TELEMETRY_naturallighting, "\t<b>", Lib.HumanReadableFlux(greenhouse.natural), "</b>\n",      //"natural lighting"
                    Local.TELEMETRY_artificiallighting, "\t<b>", Lib.HumanReadableFlux(greenhouse.artificial), "</b>"   //"artificial lighting"
                                 ) : string.Empty;

                // render it
                p.AddContent(Lib.BuildString(Local.TELEMETRY_crop, " #", (i + 1).ToString()), state, tooltip);                //"crop"

                // issues too, why not
                p.AddRightIcon(greenhouse.issue.Length == 0 ? Textures.plant_white : Textures.plant_yellow, tooltip);
            }
        }
Example #8
0
        static void Render_greenhouse(Panel p, Vessel_info vi)
        {
            // do nothing without greenhouses
            if (vi.greenhouses.Count == 0)
            {
                return;
            }

            // panel section
            p.AddSection("GREENHOUSE");

            // for each greenhouse
            for (int i = 0; i < vi.greenhouses.Count; ++i)
            {
                var greenhouse = vi.greenhouses[i];

                // state string
                string state = greenhouse.issue.Length > 0
                                  ? Lib.BuildString("<color=yellow>", greenhouse.issue, "</color>")
                                  : greenhouse.growth >= 0.99
                                  ? "<color=green>ready to harvest</color>"
                                  : "growing";

                // tooltip with summary
                string tooltip = greenhouse.growth < 0.99 ? Lib.BuildString
                                 (
                    "<align=left />",
                    "time to harvest\t<b>", Lib.HumanReadableDuration(greenhouse.tta), "</b>\n",
                    "growth\t\t<b>", Lib.HumanReadablePerc(greenhouse.growth), "</b>\n",
                    "natural lighting\t<b>", Lib.HumanReadableFlux(greenhouse.natural), "</b>\n",
                    "artificial lighting\t<b>", Lib.HumanReadableFlux(greenhouse.artificial), "</b>"
                                 ) : string.Empty;

                // render it
                p.AddContent(Lib.BuildString("crop #", (i + 1).ToString()), state, tooltip);

                // issues too, why not
                p.AddIcon(greenhouse.issue.Length == 0 ? Icons.plant_white : Icons.plant_yellow, tooltip);
            }
        }
Example #9
0
        // 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);
        }
Example #10
0
        public static void Body_info(this Panel p)
        {
            // only show in mapview
            if (!MapView.MapIsEnabled)
            {
                return;
            }

            // only show if there is a selected body and that body is not the sun
            CelestialBody body = Lib.MapViewSelectedBody();

            if (body == null || (Lib.IsSun(body) && !Features.Radiation))
            {
                return;
            }

            // calculate radiation at body surface
            double surfaceRadiation = Radiation.ComputeSurface(body, Sim.GammaTransparency(body, 0.0));

            // for all bodies except sun(s)
            if (!Lib.IsSun(body))
            {
                CelestialBody mainSun;
                Vector3d      sun_dir;
                double        sun_dist;
                double        solar_flux = Sim.SolarFluxAtBody(body, false, out mainSun, out sun_dir, out sun_dist);
                solar_flux *= Sim.AtmosphereFactor(body, 0.7071);

                // calculate simulation values
                double albedo_flux = Sim.AlbedoFlux(body, body.position + sun_dir * body.Radius);
                double body_flux   = Sim.BodyFlux(body, 0.0);
                double total_flux  = solar_flux + albedo_flux + body_flux + Sim.BackgroundFlux();
                double temperature = body.atmosphere ? body.GetTemperature(0.0) : Sim.BlackBodyTemperature(total_flux);

                // calculate night-side temperature
                double total_flux_min  = Sim.AlbedoFlux(body, body.position - sun_dir * body.Radius) + body_flux + Sim.BackgroundFlux();
                double temperature_min = Sim.BlackBodyTemperature(total_flux_min);

                // surface panel
                string temperature_str = body.atmosphere
                                  ? Lib.HumanReadableTemp(temperature)
                                  : Lib.BuildString(Lib.HumanReadableTemp(temperature_min), " / ", Lib.HumanReadableTemp(temperature));
                p.AddSection(Local.BodyInfo_SURFACE);                                      //"SURFACE"
                p.AddContent(Local.BodyInfo_temperature, temperature_str);                 //"temperature"
                p.AddContent(Local.BodyInfo_solarflux, Lib.HumanReadableFlux(solar_flux)); //"solar flux"
                if (Features.Radiation)
                {
                    p.AddContent(Local.BodyInfo_radiation, Lib.HumanReadableRadiation(surfaceRadiation));                                    //"radiation"
                }
                // atmosphere panel
                if (body.atmosphere)
                {
                    p.AddSection(Local.BodyInfo_ATMOSPHERE);                                                                                      //"ATMOSPHERE"
                    p.AddContent(Local.BodyInfo_breathable, Sim.Breathable(body) ? Local.BodyInfo_breathable_yes : Local.BodyInfo_breathable_no); //"breathable""yes""no"
                    p.AddContent(Local.BodyInfo_lightabsorption, Lib.HumanReadablePerc(1.0 - Sim.AtmosphereFactor(body, 0.7071)));                //"light absorption"
                    if (Features.Radiation)
                    {
                        p.AddContent(Local.BodyInfo_gammaabsorption, Lib.HumanReadablePerc(1.0 - Sim.GammaTransparency(body, 0.0)));                                        //"gamma absorption"
                    }
                }
            }

            // radiation panel
            if (Features.Radiation)
            {
                p.AddSection(Local.BodyInfo_RADIATION);                //"RADIATION"

                string inner, outer, pause;
                double activity, cycle;
                RadiationLevels(body, out inner, out outer, out pause, out activity, out cycle);

                if (Storm.sun_observation_quality > 0.5 && activity > -1)
                {
                    string title = Local.BodyInfo_solaractivity;                    //"solar activity"

                    if (Storm.sun_observation_quality > 0.7)
                    {
                        title = Lib.BuildString(title, ": ", Lib.Color(Local.BodyInfo_stormcycle.Format(Lib.HumanReadableDuration(cycle)), Lib.Kolor.LightGrey));                        // <<1>> cycle
                    }

                    p.AddContent(title, Lib.HumanReadablePerc(activity));
                }

                if (Storm.sun_observation_quality > 0.8)
                {
                    p.AddContent(Local.BodyInfo_radiationonsurface, Lib.HumanReadableRadiation(surfaceRadiation));                    //"radiation on surface:"
                }

                p.AddContent(Lib.BuildString(Local.BodyInfo_innerbelt, " ", Lib.Color(inner, Lib.Kolor.LightGrey)),                                                                                           //"inner belt: "
                             Radiation.show_inner ? Lib.Color(Local.BodyInfo_show, Lib.Kolor.Green) : Lib.Color(Local.BodyInfo_hide, Lib.Kolor.Red), string.Empty, () => p.Toggle(ref Radiation.show_inner)); //"show""hide"
                p.AddContent(Lib.BuildString(Local.BodyInfo_outerbelt, " ", Lib.Color(outer, Lib.Kolor.LightGrey)),                                                                                           //"outer belt: "
                             Radiation.show_outer ? Lib.Color(Local.BodyInfo_show, Lib.Kolor.Green) : Lib.Color(Local.BodyInfo_hide, Lib.Kolor.Red), string.Empty, () => p.Toggle(ref Radiation.show_outer)); //"show""hide"
                p.AddContent(Lib.BuildString(Local.BodyInfo_magnetopause, " ", Lib.Color(pause, Lib.Kolor.LightGrey)),                                                                                        //"magnetopause: "
                             Radiation.show_pause ? Lib.Color(Local.BodyInfo_show, Lib.Kolor.Green) : Lib.Color(Local.BodyInfo_hide, Lib.Kolor.Red), string.Empty, () => p.Toggle(ref Radiation.show_pause)); //"show""hide"
            }

            // explain the user how to toggle the BodyInfo window
            p.AddContent(string.Empty);
            p.AddContent("<i>" + Local.BodyInfo_BodyInfoToggleHelp.Format("<b>B</b>") + "</i>");            //"Press <<1>> to open this window again"

            // set metadata
            p.Title(Lib.BuildString(Lib.Ellipsis(body.bodyName, Styles.ScaleStringLength(24)), " ", Lib.Color(Local.BodyInfo_title, Lib.Kolor.LightGrey)));            //"BODY INFO"
        }
Example #11
0
        // 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);
        }
Example #12
0
  // draw the window
  void render(int _)
  {
    // shortcut
    CelestialBody sun = FlightGlobals.Bodies[0];

    // get selected body
    CelestialBody body = Lib.SelectedBody();

    // calculate simulation values
    double atmo_factor = Sim.AtmosphereFactor(body, 0.7071);
    double gamma_factor = Sim.GammaTransparency(body, 0.0);
    double sun_dist = Sim.Apoapsis(Lib.PlanetarySystem(body)) - sun.Radius - body.Radius;
    Vector3d sun_dir = (sun.position - body.position).normalized;
    double solar_flux = Sim.SolarFlux(sun_dist) * atmo_factor;
    double albedo_flux = Sim.AlbedoFlux(body, body.position + sun_dir * body.Radius);
    double body_flux = Sim.BodyFlux(body, 0.0);
    double total_flux = solar_flux + albedo_flux + body_flux + Sim.BackgroundFlux();
    double temperature = body.atmosphere ? body.GetTemperature(0.0) : Sim.BlackBodyTemperature(total_flux);

    // calculate night-side temperature
    double total_flux_min = Sim.AlbedoFlux(body, body.position - sun_dir * body.Radius) + body_flux + Sim.BackgroundFlux();
    double temperature_min = Sim.BlackBodyTemperature(total_flux_min);

    // calculate radiation at body surface
    double radiation = Radiation.ComputeSurface(body, gamma_factor);

    // draw pseudo-title
    GUILayout.BeginHorizontal();
    GUILayout.Label(body.bodyName.ToUpper(), top_style);
    GUILayout.EndHorizontal();

    // surface panel
    string temperature_str = body.atmosphere
      ? Lib.HumanReadableTemp(temperature)
      : Lib.BuildString(Lib.HumanReadableTemp(temperature_min), " / ", Lib.HumanReadableTemp(temperature));
    render_title("SURFACE");
    render_content("temperature", temperature_str);
    render_content("radiation", Lib.HumanReadableRadiationRate(radiation));
    render_content("solar flux", Lib.HumanReadableFlux(solar_flux));
    render_space();

    // atmosphere panel
    if (body.atmosphere)
    {
      render_title("ATMOSPHERE");
      render_content("breathable", body.atmosphereContainsOxygen ? "yes" : "no");
      render_content("light absorption", Lib.HumanReadablePerc(1.0 - Sim.AtmosphereFactor(body, 0.7071)));
      render_content("gamma absorption", Lib.HumanReadablePerc(1.0 - Sim.GammaTransparency(body, 0.0)));
      render_space();
    }

    // rendering panel
    render_title("RENDERING");
    render_content("inner belt", ref Radiation.show_inner);
    render_content("outer belt", ref Radiation.show_outer);
    render_content("magnetopause", ref Radiation.show_pause);
    render_space();


    // draw footer
    GUILayout.BeginHorizontal();
    GUILayout.Label("(ALT+N to open and close)", bot_style);
    if (Lib.IsClicked()) Close();
    GUILayout.EndHorizontal();

    // enable dragging
    GUI.DragWindow(drag_rect);
  }
Example #13
0
  public static void body_info(this Panel p)
  {
    // only show in mapview
    if (!MapView.MapIsEnabled) return;

    // only show if there is a selected body and that body is not the sun
    CelestialBody body = Lib.SelectedBody();
    if (body == null || (body.flightGlobalsIndex == 0 && !Features.Radiation)) return;

    // shortcut
    CelestialBody sun = FlightGlobals.Bodies[0];

    // for all bodies except the sun
    if (body != sun)
    {
      // calculate simulation values
      double atmo_factor = Sim.AtmosphereFactor(body, 0.7071);
      double gamma_factor = Sim.GammaTransparency(body, 0.0);
      double sun_dist = Sim.Apoapsis(Lib.PlanetarySystem(body)) - sun.Radius - body.Radius;
      Vector3d sun_dir = (sun.position - body.position).normalized;
      double solar_flux = Sim.SolarFlux(sun_dist) * atmo_factor;
      double albedo_flux = Sim.AlbedoFlux(body, body.position + sun_dir * body.Radius);
      double body_flux = Sim.BodyFlux(body, 0.0);
      double total_flux = solar_flux + albedo_flux + body_flux + Sim.BackgroundFlux();
      double temperature = body.atmosphere ? body.GetTemperature(0.0) : Sim.BlackBodyTemperature(total_flux);

      // calculate night-side temperature
      double total_flux_min = Sim.AlbedoFlux(body, body.position - sun_dir * body.Radius) + body_flux + Sim.BackgroundFlux();
      double temperature_min = Sim.BlackBodyTemperature(total_flux_min);

      // calculate radiation at body surface
      double radiation = Radiation.ComputeSurface(body, gamma_factor);

      // surface panel
      string temperature_str = body.atmosphere
        ? Lib.HumanReadableTemp(temperature)
        : Lib.BuildString(Lib.HumanReadableTemp(temperature_min), " / ", Lib.HumanReadableTemp(temperature));
      p.section("SURFACE");
      p.content("temperature", temperature_str);
      p.content("solar flux", Lib.HumanReadableFlux(solar_flux));
      if (Features.Radiation) p.content("radiation", Lib.HumanReadableRadiation(radiation));

      // atmosphere panel
      if (body.atmosphere)
      {
        p.section("ATMOSPHERE");
        p.content("breathable", Sim.Breathable(body) ? "yes" : "no");
        p.content("light absorption", Lib.HumanReadablePerc(1.0 - Sim.AtmosphereFactor(body, 0.7071)));
        if (Features.Radiation) p.content("gamma absorption", Lib.HumanReadablePerc(1.0 - Sim.GammaTransparency(body, 0.0)));
      }
    }

    // rendering panel
    if (Features.Radiation)
    {
      p.section("RENDERING");
      p.content("inner belt",   Radiation.show_inner ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.toggle(ref Radiation.show_inner));
      p.content("outer belt",   Radiation.show_outer ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.toggle(ref Radiation.show_outer));
      p.content("magnetopause", Radiation.show_pause ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.toggle(ref Radiation.show_pause));
    }

    // explain the user how to toggle the BodyInfo window
    p.content(string.Empty);
    p.content("<i>Press <b>B</b> to open this window again</i>");

    // set metadata
    p.title(Lib.BuildString(Lib.Ellipsis(body.bodyName, 24), " <color=#cccccc>BODY INFO</color>"));
  }