Beispiel #1
0
 public virtual string ValueUnitString(int digits)
 {
     return(string.Format("{0}{1}", SIFormatProvider.ToSI(this, digits), Units));
 }
Beispiel #2
0
        public void ehudWindowFunc(int id)
        {
            using (PooledStringBuilder hudString = PooledStringBuilder.Get())
            {
                if (this.core.LastStage == null)
                {
                    return;
                }

                VOID_Styles.labelHud.alignment = TextAnchor.UpperLeft;

                hudString.Append("Total Mass: ");
                hudString.Append(this.core.LastStage.totalMass.ToString("F3"));
                hudString.Append('t');

                hudString.Append(' ');

                hudString.Append("Part Count: ");
                hudString.Append(EditorLogic.SortedShipList.Count);

                hudString.Append('\n');

                hudString.Append("Total Delta-V: ");
                hudString.Append(SIFormatProvider.ToSI(this.core.LastStage.totalDeltaV));
                hudString.Append("m/s");

                hudString.Append('\n');

                hudString.Append("Bottom Stage Delta-V: ");
                hudString.Append(SIFormatProvider.ToSI(this.core.LastStage.deltaV));
                hudString.Append("m/s");

                hudString.Append('\n');

                hudString.Append("Bottom Stage T/W Ratio: ");
                hudString.Append(this.core.LastStage.thrustToWeight.ToString("F3"));

                Logging.PostDebugMessage(this,
                                         "CoMmarker.gameObject.activeInHierarchy: {0};" +
                                         "CoTmarker.gameObject.activeInHierarchy: {1}",
                                         this.CoMmarker.gameObject.activeInHierarchy,
                                         this.CoTmarker.gameObject.activeInHierarchy
                                         );

                if (this.CoMmarker.gameObject.activeInHierarchy && this.CoTmarker.gameObject.activeInHierarchy)
                {
                    Logging.PostDebugMessage(this, "CoM and CoT markers are active, doing thrust offset.");
                    hudString.Append('\n');

                    hudString.Append("Thrust Offset: ");
                    hudString.Append(
                        Vector3.Cross(
                            this.CoTmarker.dirMarkerObject.transform.forward,
                            this.CoMmarker.posMarkerObject.transform.position - this.CoTmarker.posMarkerObject.transform.position
                            ).ToString("F3"));
                }
                                #if DEBUG
                else
                {
                    Logging.PostDebugMessage(this, "CoM and CoT markers are not active, thrust offset skipped.");
                }
                                #endif

                GUILayout.Label(
                    hudString.ToString(),
                    VOID_Styles.labelHud,
                    GUILayout.ExpandWidth(true),
                    GUILayout.ExpandHeight(true)
                    );

                if (!this.positionsLocked)
                {
                    GUI.DragWindow();
                }

                GUI.BringWindowToBack(id);
            }
        }
Beispiel #3
0
        private void display_rendezvous_info(Vessel v, CelestialBody cb)
        {
            if (cb == null && v != null)
            {
                //Display vessel rendezvous info
                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                GUILayout.Label(v.vesselName, VOID_Styles.labelCenterBold, GUILayout.ExpandWidth(true));
                GUILayout.EndHorizontal();

                if (v.situation == Vessel.Situations.ESCAPING || v.situation == Vessel.Situations.FLYING || v.situation == Vessel.Situations.ORBITING || v.situation == Vessel.Situations.SUB_ORBITAL)
                {
                    // Toadicus edit: added local sidereal longitude.
                    // Toadicus edit: added local sidereal longitude.
                    double LSL = v.longitude + v.orbit.referenceBody.rotationAngle;
                    LSL = VOID_Tools.FixDegreeDomain(LSL);

                    //display orbital info for orbiting/flying/suborbital/escaping vessels only
                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    GUILayout.Label("Ap/Pe:");
                    GUILayout.Label(SIFormatProvider.ToSI(v.orbit.ApA, 3) + "m / " + SIFormatProvider.ToSI(v.orbit.PeA, 3) + "m", GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    GUILayout.Label("Altitude:");
                    GUILayout.Label(SIFormatProvider.ToSI(v.orbit.altitude, 3) + "m", GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    GUILayout.Label("Inclination:");
                    GUILayout.Label(v.orbit.inclination.ToString("F3") + "°", GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();

                    if (Vessel.mainBody == v.mainBody)
                    {
                        GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                        GUILayout.Label("Relative inclination:");
                        GUILayout.Label(Vector3.Angle(Vessel.orbit.GetOrbitNormal(), v.orbit.GetOrbitNormal()).ToString("F3") + "°", GUILayout.ExpandWidth(false));
                        GUILayout.EndHorizontal();
                    }
                    //if (debugging) Debug.Log("[CHATR] v -> v relative incl OK");

                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    GUILayout.Label("Velocity:");
                    GUILayout.Label(SIFormatProvider.ToSI(v.orbit.vel.magnitude, 3) + "m/s", GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    GUILayout.Label("Relative velocity:");
                    GUILayout.Label(SIFormatProvider.ToSI(v.orbit.vel.magnitude - Vessel.orbit.vel.magnitude, 3) + "m/s", GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    GUILayout.Label("Distance:");
                    GUILayout.Label(SIFormatProvider.ToSI((Vessel.CoM - v.CoM).magnitude, 3) + "m", GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();

                    // Toadicus edit: added local sidereal longitude.
                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    GUILayout.Label("Local Sidereal Longitude:");
                    GUILayout.Label(LSL.ToString("F3") + "°", VOID_Styles.labelRight);
                    GUILayout.EndHorizontal();

                    toggleExtendedOrbital.value = Layout.Toggle(toggleExtendedOrbital, "Extended info");

                    if (toggleExtendedOrbital)
                    {
                        GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                        GUILayout.Label("Period:");
                        GUILayout.Label(VOID_Tools.FormatInterval(v.orbit.period), GUILayout.ExpandWidth(false));
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                        GUILayout.Label("Semi-major axis:");
                        GUILayout.Label((v.orbit.semiMajorAxis / 1000).ToString("##,#") + "km", GUILayout.ExpandWidth(false));
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                        GUILayout.Label("Eccentricity:");
                        GUILayout.Label(v.orbit.eccentricity.ToString("F4"), GUILayout.ExpandWidth(false));
                        GUILayout.EndHorizontal();

                        // Toadicus edit: convert mean anomaly into degrees.
                        GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                        GUILayout.Label("Mean anomaly:");
                        GUILayout.Label((v.orbit.meanAnomaly * 180d / Math.PI).ToString("F3") + "°", GUILayout.ExpandWidth(false));
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                        GUILayout.Label("True anomaly:");
                        GUILayout.Label(v.orbit.trueAnomaly.ToString("F3") + "°", GUILayout.ExpandWidth(false));
                        GUILayout.EndHorizontal();

                        // Toadicus edit: convert eccentric anomaly into degrees.
                        GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                        GUILayout.Label("Eccentric anomaly:");
                        GUILayout.Label((v.orbit.eccentricAnomaly * 180d / Math.PI).ToString("F3") + "°", GUILayout.ExpandWidth(false));
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                        GUILayout.Label("Long. ascending node:");
                        GUILayout.Label(v.orbit.LAN.ToString("F3") + "°", GUILayout.ExpandWidth(false));
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                        GUILayout.Label("Arg. of periapsis:");
                        GUILayout.Label(v.orbit.argumentOfPeriapsis.ToString("F3") + "°", GUILayout.ExpandWidth(false));
                        GUILayout.EndHorizontal();
                    }
                }
                else
                {
                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    GUILayout.Label("Latitude:");
                    GUILayout.Label(VOID_Tools.GetLatitudeString(Vessel), GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    GUILayout.Label("Longitude:");
                    GUILayout.Label(VOID_Tools.GetLongitudeString(Vessel), GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    GUILayout.Label("Distance:");
                    GUILayout.Label(SIFormatProvider.ToSI((Vessel.CoM - v.CoM).magnitude, 3) + "m", GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();
                }
            }
            else if (cb != null && v == null)
            {
                //Display CelstialBody rendezvous info
                GUILayout.Label(cb.bodyName, VOID_Styles.labelCenterBold);

                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                GUILayout.Label("Ap/Pe:");
                GUILayout.Label(SIFormatProvider.ToSI(cb.orbit.ApA, 3) + "m / " + SIFormatProvider.ToSI(cb.orbit.PeA, 3) + "m", GUILayout.ExpandWidth(false));
                GUILayout.EndHorizontal();
                //if (debugging) Debug.Log("[VOID] Ap/Pe OK");

                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                GUILayout.Label("Inclination:");
                GUILayout.Label(cb.orbit.inclination.ToString("F3") + "°", GUILayout.ExpandWidth(false));
                GUILayout.EndHorizontal();
                //if (debugging) Debug.Log("[VOID] Inclination OK");

                if (cb.referenceBody == Vessel.mainBody)
                {
                    GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                    GUILayout.Label("Relative inclination:");
                    GUILayout.Label(Vector3.Angle(Vessel.orbit.GetOrbitNormal(), cb.orbit.GetOrbitNormal()).ToString("F3") + "°", GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();
                    //if (debugging) Debug.Log("[VOID] cb Relative inclination OK");
                }

                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                GUILayout.Label("Distance:");
                GUILayout.Label(SIFormatProvider.ToSI((Vessel.mainBody.position - cb.position).magnitude, 3) + "m", GUILayout.ExpandWidth(false));
                GUILayout.EndHorizontal();

                //if (debugging) Debug.Log("[VOID] Distance OK");

                //SUN2PLANET:
                if (Vessel.mainBody.bodyName == "Sun" && cb.referenceBody == Vessel.mainBody)
                {
                    VOID_Tools.display_transfer_angles_SUN2PLANET(cb, Vessel);
                    //if (debugging) Debug.Log("[VOID] SUN2PLANET OK");
                }

                //PLANET2PLANET
                else if (Vessel.mainBody.referenceBody.bodyName == "Sun" && cb.referenceBody == Vessel.mainBody.referenceBody)
                {
                    VOID_Tools.display_transfer_angles_PLANET2PLANET(cb, Vessel);
                    //if (debugging) Debug.Log("[VOID] PLANET2PLANET OK");
                }

                //PLANET2MOON
                else if (Vessel.mainBody.referenceBody.bodyName == "Sun" && cb.referenceBody == Vessel.mainBody)
                {
                    VOID_Tools.display_transfer_angles_PLANET2MOON(cb, Vessel);
                    //if (debugging) Debug.Log("[VOID] PLANET2MOON OK");
                }

                //MOON2MOON
                else if (Vessel.mainBody.referenceBody.referenceBody.bodyName == "Sun" && cb.referenceBody == Vessel.mainBody.referenceBody)
                {
                    VOID_Tools.display_transfer_angles_MOON2MOON(cb, Vessel);
                    //if (debugging) Debug.Log("[VOID] MOON2MOON OK");
                }

                //else GUILayout.Label("Transfer angle information\nunavailable for this target");
            }
        }
        private void body_OP_show_physical_info(CelestialBody body)
        {
            GUILayout.Label((body.Radius / 1000).ToString("##,#") + "km", VOID_Styles.labelRight, GUILayout.ExpandWidth(true));

            GUILayout.Label((((body.Radius * body.Radius) * 4 * Math.PI) / 1000).ToString("0.00e+00") + "km²", VOID_Styles.labelRight, GUILayout.ExpandWidth(true));

            // divide by 1000 to convert m to km
            GUILayout.Label((((4d / 3) * Math.PI * (body.Radius * body.Radius * body.Radius)) / 1000).ToString("0.00e+00") + "km³", VOID_Styles.labelRight, GUILayout.ExpandWidth(true));

            GUILayout.Label(body.Mass.ToString("0.00e+00") + "kg", VOID_Styles.labelRight, GUILayout.ExpandWidth(true));

            double p = body.Mass / ((body.Radius * body.Radius * body.Radius) * (4d / 3) * Math.PI);

            GUILayout.Label(p.ToString("##,#") + "kg/m³", VOID_Styles.labelRight, GUILayout.ExpandWidth(true));

            if (body.bodyName == "Sun")
            {
                GUILayout.Label(SIFormatProvider.ToSI(body.sphereOfInfluence, 3), VOID_Styles.labelRight, GUILayout.ExpandWidth(true));
            }
            else
            {
                GUILayout.Label(SIFormatProvider.ToSI(body.sphereOfInfluence, 3), VOID_Styles.labelRight, GUILayout.ExpandWidth(true));
            }

            GUILayout.Label(body.orbitingBodies.Count.ToString(), VOID_Styles.labelRight, GUILayout.ExpandWidth(true));

            //show # artificial satellites
            int num_art_sats = 0;

            Vessel v;

            for (int idx = 0; idx < FlightGlobals.Vessels.Count; idx++)
            {
                v = FlightGlobals.Vessels[idx];

                if (v.mainBody == body && v.situation.ToString() == "ORBITING")
                {
                    num_art_sats++;
                }
            }

            GUILayout.Label(num_art_sats.ToString(), VOID_Styles.labelRight, GUILayout.ExpandWidth(true));

            double g_ASL = (VOIDCore.Constant_G * body.Mass) / (body.Radius * body.Radius);

            GUILayout.Label(SIFormatProvider.ToSI(g_ASL, 3) + "m/s²", VOID_Styles.labelRight, GUILayout.ExpandWidth(true));

            if (body.atmosphere)
            {
                GUILayout.Label("≈ " + SIFormatProvider.ToSI(body.atmosphereDepth, 3) + "m",
                                VOID_Styles.labelRight,
                                GUILayout.ExpandWidth(true));

                string O2 = "No";
                if (body.atmosphereContainsOxygen == true)
                {
                    O2 = "Yes";
                }
                GUILayout.Label(O2, VOID_Styles.labelRight, GUILayout.ExpandWidth(true));
            }
            else
            {
                GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true));
                GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true));
            }

            string ocean = "No";

            if (body.ocean == true)
            {
                ocean = "Yes";
            }
            GUILayout.Label(ocean, VOID_Styles.labelRight, GUILayout.ExpandWidth(true));
        }