Beispiel #1
0
 protected override void OnUpdate()
 {
     foreach (Vessel v in FlightGlobals.Vessels)
     {
         VesselData vd = v.KerbalismData();
         if (!vd.IsSimulated)
         {
             continue;
         }
         bool manned     = vd.CrewCount > 0;
         bool in_orbit   = Sim.Apoapsis(v) > v.mainBody.atmosphereDepth && Sim.Periapsis(v) > v.mainBody.atmosphereDepth;
         bool for_30days = v.missionTime > 60.0 * 60.0 * Lib.HoursInDay * 30.0;
         if (manned && in_orbit && for_30days)
         {
             SetComplete();
             DB.landmarks.manned_orbit = true;                     //< remember that contract was completed
             break;
         }
     }
 }
 protected override void OnUpdate()
 {
     foreach (Vessel v in FlightGlobals.Vessels)
     {
         Vessel_Info vi = Cache.VesselInfo(v);
         if (!vi.is_valid)
         {
             continue;
         }
         bool manned     = vi.crew_count > 0;
         bool in_orbit   = Sim.Apoapsis(v) > v.mainBody.atmosphereDepth && Sim.Periapsis(v) > v.mainBody.atmosphereDepth;
         bool for_30days = v.missionTime > 60.0 * 60.0 * Lib.HoursInDay() * 30.0;
         if (manned && in_orbit && for_30days)
         {
             SetComplete();
             DB.landmarks.manned_orbit = true; //< remember that contract was completed
             break;
         }
     }
 }
Beispiel #3
0
        public void Analyze(CelestialBody body, double altitude_mult, bool sunlight)
        {
            // shortcuts
            CelestialBody sun = FlightGlobals.Bodies[0];

            this.body   = body;
            altitude    = body.Radius * altitude_mult;
            landed      = altitude <= double.Epsilon;
            breathable  = Sim.Breathable(body) && landed;
            atmo_factor = Sim.AtmosphereFactor(body, 0.7071);
            sun_dist    = Sim.Apoapsis(Lib.PlanetarySystem(body)) - sun.Radius - body.Radius;
            Vector3d sun_dir = (sun.position - body.position).normalized;

            solar_flux     = sunlight ? Sim.SolarFlux(sun_dist) * (landed ? atmo_factor : 1.0) : 0.0;
            albedo_flux    = sunlight ? Sim.AlbedoFlux(body, body.position + sun_dir * (body.Radius + altitude)) : 0.0;
            body_flux      = Sim.BodyFlux(body, altitude);
            total_flux     = solar_flux + albedo_flux + body_flux + Sim.BackgroundFlux();
            temperature    = !landed || !body.atmosphere ? Sim.BlackBodyTemperature(total_flux) : body.GetTemperature(0.0);
            temp_diff      = Sim.TempDiff(temperature, body, landed);
            orbital_period = Sim.OrbitalPeriod(body, altitude);
            shadow_period  = Sim.ShadowPeriod(body, altitude);
            shadow_time    = shadow_period / orbital_period;
            zerog          = !landed && (!body.atmosphere || body.atmosphereDepth < altitude);

            RadiationBody rb     = Radiation.Info(body);
            RadiationBody sun_rb = Radiation.Info(sun);

            gamma_transparency = Sim.GammaTransparency(body, 0.0);
            extern_rad         = PreferencesStorm.Instance.ExternRadiation;
            heliopause_rad     = extern_rad + sun_rb.radiation_pause;
            magnetopause_rad   = heliopause_rad + rb.radiation_pause;
            inner_rad          = magnetopause_rad + rb.radiation_inner;
            outer_rad          = magnetopause_rad + rb.radiation_outer;
            surface_rad        = magnetopause_rad * gamma_transparency;
            storm_rad          = heliopause_rad + PreferencesStorm.Instance.StormRadiation * (solar_flux > double.Epsilon ? 1.0 : 0.0);
        }
Beispiel #4
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.SetSection("SURFACE");
                p.SetContent("temperature", temperature_str);
                p.SetContent("solar flux", Lib.HumanReadableFlux(solar_flux));
                if (Features.Radiation)
                {
                    p.SetContent("radiation", Lib.HumanReadableRadiation(radiation));
                }

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

            // rendering panel
            if (Features.Radiation)
            {
                p.SetSection("RENDERING");
                p.SetContent("inner belt", Radiation.show_inner ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.Toggle(ref Radiation.show_inner));
                p.SetContent("outer belt", Radiation.show_outer ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.Toggle(ref Radiation.show_outer));
                p.SetContent("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.SetContent(string.Empty);
            p.SetContent("<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>"));
        }