Beispiel #1
0
        /// <summary>
        /// Create an XmlElement representation of the star report for saving.
        /// </summary>
        /// <param name="xmldoc">The parent XmlDocument.</param>
        /// <returns>An XmlElement representation of the report.</returns>
        public new XmlElement ToXml(XmlDocument xmldoc)
        {
            XmlElement xmlelStarIntel = xmldoc.CreateElement("StarIntel");

            // include inherited Item properties
            xmlelStarIntel.AppendChild(base.ToXml(xmldoc));

            Global.SaveData(xmldoc, xmlelStarIntel, "Year", Year.ToString(System.Globalization.CultureInfo.InvariantCulture));

            xmlelStarIntel.AppendChild(MineralConcentration.ToXml(xmldoc, "MineralConcentration"));

            Global.SaveData(xmldoc, xmlelStarIntel, "Gravity", Gravity.ToString(System.Globalization.CultureInfo.InvariantCulture));
            Global.SaveData(xmldoc, xmlelStarIntel, "Radiation", Radiation.ToString(System.Globalization.CultureInfo.InvariantCulture));
            Global.SaveData(xmldoc, xmlelStarIntel, "Temperature", Temperature.ToString(System.Globalization.CultureInfo.InvariantCulture));

            Global.SaveData(xmldoc, xmlelStarIntel, "Colonists", Colonists.ToString(System.Globalization.CultureInfo.InvariantCulture));

            Global.SaveData(xmldoc, xmlelStarIntel, "HasFleetsInOrbit", HasFleetsInOrbit.ToString());

            if (Starbase != null)
            {
                Global.SaveData(xmldoc, xmlelStarIntel, "Starbase", Starbase.Key.ToString("X"));
            }

            return(xmlelStarIntel);
        }
        public override bool MeetRequirements()
        {
            // stop checking when requirements are met
            if (!meet_requirements)
            {
                ProgressTracking progress = ProgressTracking.Instance;
                if (progress == null)
                {
                    return(false);
                }
                int known = 0;
                foreach (var body_progress in progress.celestialBodyNodes)
                {
                    known += body_progress.flyBy != null && body_progress.flyBy.IsComplete ? 1 : 0;
                }
                bool end_game = known > FlightGlobals.Bodies.Count / 2;

                meet_requirements =
                    Features.Radiation &&                                                     // radiation is enabled
                    end_game &&                                                               // entered SOI of half the bodies
                    Radiation.Info(FlightGlobals.Bodies[0]).model.has_pause &&                // there is an actual heliopause
                    !DB.landmarks.heliopause_crossing;                                        // heliopause never crossed before
            }
            return(meet_requirements);
        }
Beispiel #3
0
        void Analyze_radiation(List <Part> parts, ResourceSimulator sim)
        {
            // scan the parts
            emitted = 0.0;
            foreach (Part p in parts)
            {
                // for each module
                foreach (PartModule m in p.Modules)
                {
                    // skip disabled modules
                    if (!m.isEnabled)
                    {
                        continue;
                    }

                    // accumulate emitter radiation
                    if (m.moduleName == "Emitter")
                    {
                        Emitter emitter = m as Emitter;

                        emitted += emitter.running ? emitter.radiation : 0.0;
                    }
                }
            }

            // calculate shielding factor
            double amount   = sim.Resource("Shielding").amount;
            double capacity = sim.Resource("Shielding").capacity;

            shielding = capacity > double.Epsilon
                                ? Radiation.ShieldingEfficiency(amount / capacity)
                                : PreferencesStorm.Instance.shieldingEfficiency;
        }
Beispiel #4
0
 internal bool CanAddToRadiation(Radiation radiation)
 {
     if (!this.shuttingDown)
     {
     }
     return((this.radiating == null) && (this.radiating = new HashSet <Radiation>()).Add(radiation));
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="stream"></param>
        private void LoadMetaData(Stream stream)
        {
            stream.Position = 0;
            using (var reader = new StreamReader(stream, Encoding.UTF8))
            {
                string line;
                bool   foundheader = false;
                while ((line = reader.ReadLine()) != null)
                {
                    List <String> items = new List <String>(line.Trim().Split(new string[] { " ", "\t", "," }, StringSplitOptions.RemoveEmptyEntries));
                    if (items[0] != "//")
                    {
                        if (foundheader == false)
                        {
                            //Parse the header

                            float lat;
                            float lon;
                            if (float.TryParse(items[0], out lat))
                            {
                                Latitude = lat;
                            }
                            if (float.TryParse(items[1], out lon))
                            {
                                Longitude = lon;
                            }

                            items.RemoveRange(0, 2);
                            Comments = String.Join(" ", items.ToArray());

                            foundheader = true;
                        }
                        else
                        {
                            if (items.Count() == 8)
                            {
                                var date = DateUtilities.TryParseDate(items[0]);
                                if (date != null)
                                {
                                    if (StartDate == null)
                                    {
                                        StartDate = date;
                                    }
                                    //Parse the met data
                                    EndDate = date;

                                    MaxT.Add(double.Parse(items[2]));
                                    MinT.Add(double.Parse(items[3]));
                                    Rain.Add(double.Parse(items[4]));
                                    PanEvap.Add(double.Parse(items[5]));
                                    Radiation.Add(double.Parse(items[6]));
                                    VP.Add(double.Parse(items[7]));
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Fonction qui retourne un Effet.
        /// </summary>
        /// <param name="query">Requête à effectuer sur la BD</param>
        /// <returns>Un Effet</returns>
        private static Effet Retrieve(string query)
        {
            Effet     resultat;
            DataSet   dsResultat;
            DataTable dtResultat;
            DataRow   drResultat;

            ConnectionBD = new MySqlConnexion();

            dsResultat = ConnectionBD.Query(query);
            dtResultat = dsResultat.Tables[0];
            drResultat = dtResultat.Rows[0];


            if ((int)drResultat["champEffetF"] != 99)
            {
                resultat = new Gain((string)drResultat["typeEffet"]
                                    , (int)drResultat["champEffetA"]
                                    , (int)drResultat["champEffetB"]
                                    , (int)drResultat["champEffetC"]
                                    , (int)drResultat["champEffetD"]
                                    , (int)drResultat["champEffetE"]
                                    , (int)drResultat["champEffetF"]
                                    );
            }
            else if ((int)drResultat["champEffetC"] != 99)
            {
                resultat = new Impact((string)drResultat["typeEffet"]
                                      , (int)drResultat["champEffetA"]
                                      , (int)drResultat["champEffetB"]
                                      , (int)drResultat["champEffetC"]
                                      );
            }
            else if ((int)drResultat["champEffetB"] != 99)
            {
                resultat = new Recyclage((string)drResultat["typeEffet"]
                                         , (int)drResultat["champEffetA"]
                                         , (int)drResultat["champEffetB"]
                                         );
            }
            else if ((int)drResultat["champEffetA"] != 99)
            {
                resultat = new Radiation((string)drResultat["typeEffet"]
                                         , (int)drResultat["champEffetA"]
                                         );
            }
            else
            {
                resultat = new Effet((string)drResultat["typeEffet"]);
            }

            return(resultat);
        }
Beispiel #7
0
    private void OnTriggerExit(Collider other)
    {
        Character fromCollider = this.GetFromCollider(other);

        if (fromCollider != null)
        {
            Radiation local = fromCollider.GetLocal <Radiation>();
            if (local != null)
            {
                local.RemoveRadiationZone(this);
            }
        }
    }
Beispiel #8
0
    internal bool RemoveFromRadiation(Radiation radiation)
    {
        bool flag;

        if (this.shuttingDown)
        {
            flag = true;
        }
        else
        {
            flag = (this.radiating == null ? false : this.radiating.Remove(radiation));
        }
        return(flag);
    }
Beispiel #9
0
    private void OnTriggerEnter(Collider other)
    {
        Character fromCollider = this.GetFromCollider(other);

        if (!fromCollider)
        {
            return;
        }
        Radiation local = fromCollider.GetLocal <Radiation>();

        if (local)
        {
            local.AddRadiationZone(this);
        }
    }
Beispiel #10
0
    private void OnTriggerExit(Collider other)
    {
        Character fromCollider = this.GetFromCollider(other);

        if (!fromCollider)
        {
            return;
        }
        Radiation local = fromCollider.GetLocal <Radiation>();

        if (!local)
        {
            return;
        }
        local.RemoveRadiationZone(this);
    }
Beispiel #11
0
        public override string ToString()
        {
            string str = "\n";

            str += string.Format("{0} \t{1} \t{2} \n",
                                 StringExtensions.SpaceUppercaseLetters(Classification.ToString()),
                                 StringExtensions.SpaceUppercaseLetters(Age.ToString()),
                                 StringExtensions.SpaceUppercaseLetters(Radiation.ToString()));

            foreach (var body in CelestialBodies)
            {
                str += string.Format("{0}\n", body);
            }

            return(str);
        }
Beispiel #12
0
        void Analyze_radiation(List <Part> parts, ResourceSimulator sim)
        {
            // scan the parts
            emitted = 0.0;
            foreach (Part p in parts)
            {
                // for each module
                foreach (PartModule m in p.Modules)
                {
                    // skip disabled modules
                    if (!m.isEnabled)
                    {
                        continue;
                    }

                    // accumulate emitter radiation
                    if (m.moduleName == "Emitter")
                    {
                        Emitter emitter = m as Emitter;
                        emitter.Recalculate();

                        if (emitter.running)
                        {
                            if (emitter.radiation > 0)
                            {
                                emitted += emitter.radiation * emitter.radiation_impact;
                            }
                            else
                            {
                                emitted += emitter.radiation;
                            }
                        }
                    }
                }
            }

            // calculate shielding factor
            double amount   = sim.Resource("Shielding").amount;
            double capacity = sim.Resource("Shielding").capacity;

            shielding = capacity > 0
                                ? Radiation.ShieldingEfficiency(amount / capacity)
                                : 0;
        }
Beispiel #13
0
        /// <summary>
        /// Attempt to initialise models based on the current time, and test if they are sensible
        /// </summary>
        private bool TryInitiliase(IntervalValues I)
        {
            Temperature.UpdateAirTemperature(I.Time);
            Radiation.UpdateRadiationValues(I.Time);
            var sunAngle = Solar.SunAngle(I.Time);

            Canopy.DoSolarAdjustment(sunAngle);

            if (IsSensible())
            {
                return(true);
            }
            else
            {
                I.Sunlit = new AreaValues();
                I.Shaded = new AreaValues();

                return(false);
            }
        }
Beispiel #14
0
 internal bool CanAddToRadiation(Radiation radiation)
 {
     bool flag;
     if (this.shuttingDown)
     {
         flag = false;
     }
     else
     {
         HashSet<Radiation> radiations = this.radiating;
         if (radiations == null)
         {
             HashSet<Radiation> radiations1 = new HashSet<Radiation>();
             HashSet<Radiation> radiations2 = radiations1;
             this.radiating = radiations1;
             radiations = radiations2;
         }
         flag = radiations.Add(radiation);
     }
     return flag;
 }
Beispiel #15
0
    internal bool CanAddToRadiation(Radiation radiation)
    {
        bool flag;

        if (this.shuttingDown)
        {
            flag = false;
        }
        else
        {
            HashSet <Radiation> radiations = this.radiating;
            if (radiations == null)
            {
                HashSet <Radiation> radiations1 = new HashSet <Radiation>();
                HashSet <Radiation> radiations2 = radiations1;
                this.radiating = radiations1;
                radiations     = radiations2;
            }
            flag = radiations.Add(radiation);
        }
        return(flag);
    }
Beispiel #16
0
        private void cb_Radiation_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (this.cb_Radiation.SelectedItem.ToString())
            {
            case "OFF":
                radiation         = Radiation.OFF;
                this.lb_help.Text = "帮助:\r\n" + HelpDescriptions.Radiation_OFF;
                break;

            case "Rosseland模型":
                radiation         = Radiation.Rosseland;
                this.lb_help.Text = "帮助:\r\n" + HelpDescriptions.Radiation_Rosseland;
                break;

            case "P1模型":
                radiation         = Radiation.P1;
                this.lb_help.Text = "帮助:\r\n" + HelpDescriptions.Radiation_P1;
                break;

            case "S2S模型":
                radiation         = Radiation.S2S;
                this.lb_help.Text = "帮助:\r\n" + HelpDescriptions.Radiation_S2S;
                break;

            case "DO模型":
                radiation         = Radiation.DO;
                this.lb_help.Text = "帮助:\r\n" + HelpDescriptions.Radiation_DO;
                break;

            default:
                break;
            }

            //辐射模型开启,则能力方程自动开启
            if (!this.cb_Radiation.SelectedItem.ToString().Equals("OFF"))
            {
                this.cb_Energy.SelectedIndex = 1;
            }
        }
Beispiel #17
0
        private void ModelsForm_Load(object sender, EventArgs e)
        {
            this.cb_Energy.Items.AddRange(new string[] { "OFF", "ON" });
            this.cb_Viscous.Items.AddRange(new string[] { "Inviscid", "Laminar", "Spalart-Allmaras模型",
                                                          "标准k-ε模型", "RNG k-ε模型", "Realizable k-ε模型", "标准k-ω模型", "BSL k-ω模型",
                                                          "SST k-ω模型" });
            this.cb_Radiation.Items.AddRange(new string[] { "OFF", "Rosseland模型", "P1模型", "S2S模型", "DO模型" });
            this.cb_Species.Items.AddRange(new string[] { "OFF", "ON" });

            this.cb_Energy.SelectedIndex    = 0;
            this.cb_Viscous.SelectedIndex   = 3;
            this.cb_Radiation.SelectedIndex = 0;
            this.cb_Species.SelectedIndex   = 1;

            energy    = Energy.OFF;
            viscous   = Viscous.k_eStandard;
            radiation = Radiation.OFF;
            species   = Species.ON;

            this.lb_help.Text = "帮助:\r\n";

            action = new Action(bindAction);
        }
Beispiel #18
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);
        }
 protected override bool CheckPrerequesits()
 {
     this.radiation = base.GetComponent <Radiation>();
     return(this.radiation);
 }
Beispiel #20
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>"));
        }
 protected override bool CheckPrerequesits()
 {
     this.radiation = base.GetComponent<Radiation>();
     return this.radiation;
 }
Beispiel #22
0
 internal bool RemoveFromRadiation(Radiation radiation)
 {
     return(this.shuttingDown || ((this.radiating != null) && this.radiating.Remove(radiation)));
 }
        public void Analyze(CelestialBody body, double altitude_mult, Planner.SunlightState sunlight)
        {
            this.body = body;
            CelestialBody mainSun;
            Vector3d      sun_dir;

            solar_flux     = Sim.SolarFluxAtBody(body, true, out mainSun, out sun_dir, out sun_dist);
            altitude       = body.Radius * altitude_mult;
            landed         = altitude <= double.Epsilon;
            atmo_factor    = Sim.AtmosphereFactor(body, 0.7071);
            solar_flux     = sunlight == Planner.SunlightState.Shadow ? 0.0 : solar_flux * (landed ? atmo_factor : 1.0);
            breathable     = Sim.Breathable(body) && landed;
            albedo_flux    = sunlight == Planner.SunlightState.Shadow ? 0.0 : Sim.AlbedoFlux(body, body.position + sun_dir * (body.Radius + altitude));
            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(mainSun); // TODO Kopernicus support: not sure if/how this work with multiple suns/stars

            gamma_transparency = Sim.GammaTransparency(body, 0.0);

            // add gamma radiation emitted by body and its sun
            var gamma_radiation = Radiation.DistanceRadiation(rb.radiation_r0, altitude) / 3600.0;

#if DEBUG_RADIATION
            Lib.Log("Planner/EA: " + body + " sun " + mainSun + " alt " + altitude + " sol flux " + solar_flux + " aalbedo flux " + albedo_flux + " body flux " + body_flux + " total flux " + total_flux);
            Lib.Log("Planner/EA: body surface radiation " + Lib.HumanReadableRadiation(gamma_radiation, false));
#endif

            var b = body;
            while (b != null && b.orbit != null && b != mainSun)
            {
                if (b == b.referenceBody)
                {
                    break;
                }
                var dist = b.orbit.semiMajorAxis;
                b = b.referenceBody;

                gamma_radiation += Radiation.DistanceRadiation(Radiation.Info(b).radiation_r0, dist) / 3600.0;
#if DEBUG_RADIATION
                Lib.Log("Planner/EA: with gamma radiation from " + b + " " + Lib.HumanReadableRadiation(gamma_radiation, false));
                Lib.Log("Planner/EA: semi major axis " + dist);
#endif
            }

            extern_rad       = Settings.ExternRadiation / 3600.0;
            heliopause_rad   = gamma_radiation + extern_rad + sun_rb.radiation_pause;
            magnetopause_rad = gamma_radiation + heliopause_rad + rb.radiation_pause;
            inner_rad        = gamma_radiation + magnetopause_rad + rb.radiation_inner;
            outer_rad        = gamma_radiation + magnetopause_rad + rb.radiation_outer;
            surface_rad      = magnetopause_rad * gamma_transparency + rb.radiation_surface / 3600.0;
            storm_rad        = heliopause_rad + PreferencesRadiation.Instance.StormRadiation * (solar_flux > double.Epsilon ? 1.0 : 0.0);

#if DEBUG_RADIATION
            Lib.Log("Planner/EA: extern_rad " + Lib.HumanReadableRadiation(extern_rad, false));
            Lib.Log("Planner/EA: heliopause_rad " + Lib.HumanReadableRadiation(heliopause_rad, false));
            Lib.Log("Planner/EA: magnetopause_rad " + Lib.HumanReadableRadiation(magnetopause_rad, false));
            Lib.Log("Planner/EA: inner_rad " + Lib.HumanReadableRadiation(inner_rad, false));
            Lib.Log("Planner/EA: outer_rad " + Lib.HumanReadableRadiation(outer_rad, false));
            Lib.Log("Planner/EA: surface_rad " + Lib.HumanReadableRadiation(surface_rad, false));
            Lib.Log("Planner/EA: storm_rad " + Lib.HumanReadableRadiation(storm_rad, false));
#endif
        }
Beispiel #24
0
        ///<summary> Add radiation sub-panel, including tooltips </summary>
        private static void AddSubPanelRadiation(Panel p)
        {
            // get first radiation rule
            // - guaranteed to exist, as this panel is not rendered if it doesn't
            // - even without crew, it is safe to evaluate the modifiers that use it
            Rule rule = Profile.rules.Find(k => k.modifiers.Contains("radiation"));

            // detect if it use shielding
            bool use_shielding = rule.modifiers.Contains("shielding");

            // calculate various radiation levels
            double[] levels = new[]
            {
                Math.Max(Radiation.Nominal, (env_analyzer.surface_rad + vessel_analyzer.emitted)),                        // surface
                Math.Max(Radiation.Nominal, (env_analyzer.magnetopause_rad + vessel_analyzer.emitted)),                   // inside magnetopause
                Math.Max(Radiation.Nominal, (env_analyzer.inner_rad + vessel_analyzer.emitted)),                          // inside inner belt
                Math.Max(Radiation.Nominal, (env_analyzer.outer_rad + vessel_analyzer.emitted)),                          // inside outer belt
                Math.Max(Radiation.Nominal, (env_analyzer.heliopause_rad + vessel_analyzer.emitted)),                     // interplanetary
                Math.Max(Radiation.Nominal, (env_analyzer.extern_rad + vessel_analyzer.emitted)),                         // interstellar
                Math.Max(Radiation.Nominal, (env_analyzer.storm_rad + vessel_analyzer.emitted))                           // storm
            };

            // evaluate modifiers (except radiation)
            List <string> modifiers_except_radiation = new List <string>();

            foreach (string s in rule.modifiers)
            {
                if (s != "radiation")
                {
                    modifiers_except_radiation.Add(s);
                }
            }
            double mod = Modifiers.Evaluate(env_analyzer, vessel_analyzer, resource_sim, modifiers_except_radiation);

            // calculate life expectancy at various radiation levels
            double[] estimates = new double[7];
            for (int i = 0; i < 7; ++i)
            {
                estimates[i] = rule.fatal_threshold / (rule.degeneration * mod * levels[i]);
            }

            // generate tooltip
            RadiationModel mf      = Radiation.Info(env_analyzer.body).model;
            string         tooltip = Lib.BuildString
                                     (
                "<align=left />",
                String.Format("{0,-20}\t<b>{1}</b>\n", Local.Planner_surface, Lib.HumanReadableDuration(estimates[0])),                          //"surface"
                mf.has_pause ? String.Format("{0,-20}\t<b>{1}</b>\n", Local.Planner_magnetopause, Lib.HumanReadableDuration(estimates[1])) : "", //"magnetopause"
                mf.has_inner ? String.Format("{0,-20}\t<b>{1}</b>\n", Local.Planner_innerbelt, Lib.HumanReadableDuration(estimates[2])) : "",    //"inner belt"
                mf.has_outer ? String.Format("{0,-20}\t<b>{1}</b>\n", Local.Planner_outerbelt, Lib.HumanReadableDuration(estimates[3])) : "",    //"outer belt"
                String.Format("{0,-20}\t<b>{1}</b>\n", Local.Planner_interplanetary, Lib.HumanReadableDuration(estimates[4])),                   //"interplanetary"
                String.Format("{0,-20}\t<b>{1}</b>\n", Local.Planner_interstellar, Lib.HumanReadableDuration(estimates[5])),                     //"interstellar"
                String.Format("{0,-20}\t<b>{1}</b>", Local.Planner_storm, Lib.HumanReadableDuration(estimates[6]))                               //"storm"
                                     );

            // render the panel
            p.AddSection(Local.Planner_RADIATION, string.Empty,            //"RADIATION"
                         () => { p.Prev(ref special_index, panel_special.Count); enforceUpdate = true; },
                         () => { p.Next(ref special_index, panel_special.Count); enforceUpdate = true; });
            p.AddContent(Local.Planner_surface, Lib.HumanReadableRadiation(env_analyzer.surface_rad + vessel_analyzer.emitted), tooltip); //"surface"
            p.AddContent(Local.Planner_orbit, Lib.HumanReadableRadiation(env_analyzer.magnetopause_rad), tooltip);                        //"orbit"
            if (vessel_analyzer.emitted >= 0.0)
            {
                p.AddContent(Local.Planner_emission, Lib.HumanReadableRadiation(vessel_analyzer.emitted), tooltip);                //"emission"
            }
            else
            {
                p.AddContent(Local.Planner_activeshielding, Lib.HumanReadableRadiation(-vessel_analyzer.emitted), tooltip);                                        //"active shielding"
            }
            p.AddContent(Local.Planner_shielding, rule.modifiers.Contains("shielding") ? Habitat.Shielding_to_string(vessel_analyzer.shielding) : "N/A", tooltip); //"shielding"
        }
Beispiel #25
0
 internal bool RemoveFromRadiation(Radiation radiation)
 {
     bool flag;
     if (this.shuttingDown)
     {
         flag = true;
     }
     else
     {
         flag = (this.radiating == null ? false : this.radiating.Remove(radiation));
     }
     return flag;
 }