예제 #1
0
        public static double DiuralSMAChange(Vessel vessel)
        {
            double RateOfChangeOfSMA = 0;
            double InitialSMA        = VesselData.FetchSMA(vessel);
            double Albedo            = 0.12; // Work on something better for this! Currently using Worn Asphalt as a guide...
            double MeanMotion        = (360.0) / vessel.orbitDriver.orbit.period;
            double Area     = VesselData.FetchArea(vessel);
            double Mass     = VesselData.FetchMass(vessel);
            double Radius   = Math.Sqrt(Area / Math.PI);
            double Volume   = (4.0 / 3.0) * Math.PI * Math.Pow(Radius, 3.0);
            double Density  = Mass / Volume;
            double c        = Math.Pow(8.0 * 10, 8);
            double Altitude = 0;

            if (vessel.orbitDriver.orbit.referenceBody == Sun.Instance.sun) // Checks for the sun
            {
                Altitude = vessel.orbitDriver.orbit.altitude;
            }
            else
            {
                Altitude = vessel.orbitDriver.orbit.referenceBody.orbit.altitude;
            }

            double SolarEnergy   = (double)Math.Pow(((double)3.86 * (double)10.0), (double)26.0);
            double SolarConstant = 0.0;

            SolarConstant = SolarEnergy / ((double)4.0 * (double)Math.PI * (double)Math.Pow(Altitude, (double)2.0)); // W/m^2

            double BoltzmannConstant = Math.Pow(6.68 * 10.0, -11.0);
            double SolarTemperature  = vessel.externalTemperature; // try this!
            double Epsilon           = UnityEngine.Random.Range(0.75f, 0.9f);
            double LocalForce        = 0;

            LocalForce = (Epsilon * BoltzmannConstant * Math.Pow(SolarTemperature, 4.0)) / Albedo;

            double   Iota         = (3.0 * LocalForce) / (4.0 * Radius * Density * c);
            Vector3d RotationAxis = vessel.upAxis;

            float  ObliquityOfSpinAxis = 0;
            double AmplitudeOfRotation = 0;
            double RotationPhase       = 0;

            if (LoadingCheck.PersistentRotationInstalled)
            {
                // Add Persistent Rotation Compatibility here! //1.6.0
            }

            else
            {
                if (vessel.isActiveVessel)
                {
                    Quaternion VesselRotation = vessel.srfRelRotation;
                    Vector3    TemporaryAxis;
                    VesselRotation.ToAngleAxis(out ObliquityOfSpinAxis, out TemporaryAxis);
                    Vector3 AngularSpeed = (TemporaryAxis * ObliquityOfSpinAxis); // Rotation Per Second?
                    AmplitudeOfRotation = AngularSpeed.magnitude;
                    RotationPhase       = Vector3.Angle(RotationAxis, TemporaryAxis);
                }

                else
                {
                    Quaternion VesselRotation = new Quaternion();//.Inverse(); // Issues here work out a background rotational calculation?
                    Vector3    TemporaryAxis;
                    VesselRotation.ToAngleAxis(out ObliquityOfSpinAxis, out TemporaryAxis);
                    Vector3 AngularSpeed = (TemporaryAxis * ObliquityOfSpinAxis); // Rotation Per Second?
                    AmplitudeOfRotation = AngularSpeed.magnitude;
                    RotationPhase       = Vector3.Angle(RotationAxis, TemporaryAxis);
                }
            }

            double RotationFrequency      = AmplitudeOfRotation;
            double DiuralThermalParameter = 0;
            double Gamma = 0;
            double SpecificHeatCapacity = 670; // Lets not model this too far yet... maybe for 1.6.0 using c of Regolith for now
            double ThermalConductivity  = (Math.Pow(100.0, 2.0) / (Density * SpecificHeatCapacity));
            double PenetrationDepth     = 0;
            double X = 0;

            DiuralThermalParameter = (Math.Sqrt(ThermalConductivity * Density * SpecificHeatCapacity * RotationFrequency) / (Epsilon * BoltzmannConstant * Math.Pow(SolarTemperature, 3.0) * Altitude));
            PenetrationDepth       = Math.Sqrt(ThermalConductivity / (Density * SpecificHeatCapacity * RotationFrequency));
            X     = (Radius * Math.Sqrt(2)) / PenetrationDepth;
            Gamma = DiuralThermalParameter / X;

            double BigOFunctionOfEccentricity = Math.Pow(vessel.orbitDriver.orbit.eccentricity, 0.0);

            RateOfChangeOfSMA = ((-8.0 * Albedo) / (9.0 * MeanMotion)) * Iota * ((AmplitudeOfRotation * Math.Sin(RotationPhase)) / 1.0 + Gamma) * Math.Cos(ObliquityOfSpinAxis) + 0;

            if (double.IsNaN(RateOfChangeOfSMA))
            {
                RateOfChangeOfSMA = 0;
            }

            return(RateOfChangeOfSMA);
        }
예제 #2
0
 public void ToggleSK()
 {
     VesselData.UpdateStationKeeping(this.vessel, VesselData.FetchStationKeeping(vessel));
     stationKeepData.IsStationKeeping = !stationKeepData.IsStationKeeping;
     updatedisplayedData();
 }
예제 #3
0
        public static void FuelManager(Vessel vessel)
        {
            string ResourceName = "";

            ResourceName = ResourceManager.GetResourceNames(vessel);
            double CurrentFuel = 0;

            CurrentFuel = ResourceManager.GetResources(vessel);
            double ResourceEfficiency = VesselData.FetchEfficiency(vessel);// effi calculation based on vessel engine ISP stored in stationKeepData.ISP NEED ballance
            double LostFuel           = 0.0;

            LostFuel = Math.Abs((DecayManager.DecayRateAtmosphericDrag(vessel) + DecayManager.DecayRateRadiationPressure(vessel) + DecayManager.DecayRateYarkovskyEffect(vessel))) * Settings.ReadResourceRateDifficulty() * ResourceEfficiency; // * Fuel Multiplier

            double FuelNew = CurrentFuel - LostFuel;

            /// Remote tech compatibility - 1.6.0 ///
            bool RemoteTechInstalled = LoadingCheck.RemoteTechInstalled;
            bool SignalCheck         = false;
            bool ConnectionToVessel  = true;

            if (RemoteTechInstalled)
            {
                // Add Part Module Checks Here // Maybe 1.6.0


                if (ConnectionToVessel == false)
                {
                    SignalCheck = false;
                    ScreenMessages.PostScreenMessage("Warning: " + vessel.vesselName + " has no connection to send Station Keeping command!");
                    VesselData.UpdateStationKeeping(vessel, false);
                }
            }
            else
            {
                SignalCheck = true;
            }

            if (SignalCheck == true)
            {
                if (EngineCheck(vessel) == false) // 1.3.0
                {
                    ScreenMessages.PostScreenMessage("Warning: " + vessel.vesselName + " has no operational Engines or RCS modules, Station Keeping disabled.");
                    VesselData.UpdateStationKeeping(vessel, false);
                }

                else if (EngineCheck(vessel) == true)
                {
                    if (FuelNew <= 0)
                    {
                        ScreenMessages.PostScreenMessage("Warning: " + vessel.vesselName + " has run out of " + ResourceName + ", Station Keeping disabled.");
                        VesselData.UpdateStationKeeping(vessel, false);
                        VesselData.UpdateVesselFuel(vessel, 0);
                    }
                    else
                    {
                        VesselData.UpdateVesselFuel(vessel, FuelNew);
                        ResourceManager.RemoveResources(vessel, LostFuel);
                    }
                }
            }
        }
예제 #4
0
        public void InformationTab()
        {
            GUILayout.BeginHorizontal();
            GUI.skin.label.fontSize  = 16;
            GUI.skin.label.alignment = TextAnchor.MiddleCenter;
            GUILayout.Label("Vessel Information", GUILayout.Width(290));
            GUI.skin.label.alignment = TextAnchor.MiddleLeft;
            GUI.skin.label.fontSize  = 12;
            GUILayout.EndHorizontal();

            GUILayout.BeginVertical();

            // 1.5.2 Filtering //

            GUILayout.Space(3);
            GUILayout.BeginHorizontal();

            if (GUILayout.Button(GameDatabase.Instance.GetTexture("Squad/PartList/SimpleIcons/R&D_node_icon_unmannedtech", false)))
            {
                if (FilterTypes.Contains(VesselType.Probe))
                {
                    FilterTypes.Remove(VesselType.Probe);
                }

                else
                {
                    FilterTypes.Add(VesselType.Probe);
                }
            }

            GUILayout.Space(3);
            if (GUILayout.Button(GameDatabase.Instance.GetTexture("Squad/PartList/SimpleIcons/R&D_node_icon_advunmanned", false)))
            {
                if (FilterTypes.Contains(VesselType.Relay))
                {
                    FilterTypes.Remove(VesselType.Relay);
                }

                else
                {
                    FilterTypes.Add(VesselType.Relay);
                }
            }

            GUILayout.Space(3);

            if (GUILayout.Button(GameDatabase.Instance.GetTexture("Squad/PartList/SimpleIcons/RDicon_commandmodules", false)))
            {
                if (FilterTypes.Contains(VesselType.Ship))
                {
                    FilterTypes.Remove(VesselType.Ship);
                }

                else
                {
                    FilterTypes.Add(VesselType.Ship);
                }
            }

            GUILayout.Space(3);

            if (GUILayout.Button(GameDatabase.Instance.GetTexture("Squad/PartList/SimpleIcons/R&D_node_icon_specializedconstruction", false)))
            {
                if (FilterTypes.Contains(VesselType.Station))
                {
                    FilterTypes.Remove(VesselType.Station);
                }

                else
                {
                    FilterTypes.Add(VesselType.Station);
                }
            }

            GUILayout.Space(3);

            if (GUILayout.Button(GameDatabase.Instance.GetTexture("Squad/PartList/SimpleIcons/RDicon_telescope", false)))
            {
                if (FilterTypes.Contains(VesselType.SpaceObject))
                {
                    FilterTypes.Remove(VesselType.SpaceObject);
                }

                else
                {
                    FilterTypes.Add(VesselType.SpaceObject);
                }

                if (FilterTypes.Contains(VesselType.Unknown))
                {
                    FilterTypes.Remove(VesselType.Unknown);
                }

                else
                {
                    FilterTypes.Add(VesselType.Unknown);
                }
            }

            GUILayout.Space(3);

            if (GUILayout.Button(GameDatabase.Instance.GetTexture("Squad/PartList/SimpleIcons/R&D_node_icon_composites", false)))
            {
                if (FilterTypes.Contains(VesselType.Debris))
                {
                    FilterTypes.Remove(VesselType.Debris);
                }

                else
                {
                    FilterTypes.Add(VesselType.Debris);
                }
            }

            GUILayout.Space(3);


            GUILayout.EndHorizontal();
            GUILayout.Space(3);
            GUILayout.Label("_______________________________________");
            GUILayout.EndVertical();

            scrollPosition1 = GUILayout.BeginScrollView(scrollPosition1, GUILayout.Width(290), GUILayout.Height(350));
            bool Realistic = Settings.ReadRD();
            var  ClockType = Settings.Read24Hr();

            //151var Resource = Settings.ReadStationKeepingResource();

            foreach (Vessel vessel in FlightGlobals.Vessels)
            {
                if (FilterTypes.Contains(vessel.vesselType))
                {
                    if (vessel.situation == Vessel.Situations.ORBITING)
                    {
                        var StationKeeping = VesselData.FetchStationKeeping(vessel).ToString();
                        var StationKeepingFuelRemaining = ResourceManager.GetResources(vessel).ToString("F3");
                        var Resource   = ResourceManager.GetResourceNames(vessel);
                        var ButtonText = "";
                        var HoursInDay = 6.0;

                        double DaysInYear = 0;
                        bool   KerbinTime = GameSettings.KERBIN_TIME;

                        if (KerbinTime == true)
                        {
                            DaysInYear = 9203545 / (60 * 60 * HoursInDay);
                        }
                        else
                        {
                            DaysInYear = 31557600 / (60 * 60 * HoursInDay);
                        }


                        if (StationKeeping == "True")
                        {
                            ButtonText = "Disable Station Keeping";
                        }
                        else
                        {
                            ButtonText = "Enable Station Keeping";
                        }

                        if (ClockType == true)
                        {
                            HoursInDay = 24.0;
                        }
                        else
                        {
                            HoursInDay = 6.0;
                        }

                        GUILayout.BeginVertical();
                        //   GUILayout.Label("Vessels count" + VesselData.VesselInformation.CountNodes.ToString());
                        GUILayout.Label("Vessel Name: " + vessel.vesselName);
                        //    GUILayout.Label("Vessel Area: " + VesselData.FetchArea(vessel).ToString());
                        //    GUILayout.Label("Vessel Mass: " + VesselData.FetchMass(vessel).ToString());
                        GUILayout.Space(2);
                        GUILayout.Label("Orbiting Body: " + vessel.orbitDriver.orbit.referenceBody.GetName());
                        GUILayout.Space(2);

                        if (StationKeeping == "True")
                        {
                            GUILayout.Label("Current Total Decay Rate: Vessel is Station Keeping");
                            GUILayout.Space(2);
                        }
                        else
                        {
                            double TotalDecayRatePerSecond = Math.Abs(DecayManager.DecayRateAtmosphericDrag(vessel)) + Math.Abs(DecayManager.DecayRateRadiationPressure(vessel)) + Math.Abs(DecayManager.DecayRateYarkovskyEffect(vessel)); //+ Math.Abs(DecayManager.DecayRateGravitationalPertubation(vessel));
                            double ADDR = DecayManager.DecayRateAtmosphericDrag(vessel);
                            double GPDR = DecayManager.DecayRateGravitationalPertubation(vessel);
                            double PRDR = DecayManager.DecayRateRadiationPressure(vessel);
                            double YEDR = DecayManager.DecayRateYarkovskyEffect(vessel);

                            GUILayout.Label("Current Total Decay Rate: " + FormatDecayRateToString(TotalDecayRatePerSecond));
                            GUILayout.Space(2);

                            if (GUILayout.Button("Toggle Decay Rate Breakdown")) // Display a new window here?
                            {
                                subwindowVessel       = vessel;
                                DecayBreakdownVisible = !DecayBreakdownVisible;
                            }

                            // 1.7.0 maybe?
                            if (Settings.ReadNB())
                            {
                                GUILayout.Space(2);
                                if (GUILayout.Button("Toggle NBody Breakdown")) // New Window for NBody
                                {
                                    subwindowVessel = vessel;
                                    NBodyVesselAccelTimes.Clear();
                                    NBodyBreakdownVisible = !NBodyBreakdownVisible;
                                }
                            }


                            GUILayout.Space(2);

                            double TimeUntilDecayInUnits = 0.0;
                            string TimeUntilDecayInDays  = "";

                            if (ADDR != 0)
                            {
                                TimeUntilDecayInUnits = DecayManager.DecayTimePredictionExponentialsVariables(vessel);
                                TimeUntilDecayInDays  = FormatTimeUntilDecayInDaysToString(TimeUntilDecayInUnits);
                            }
                            else
                            {
                                TimeUntilDecayInUnits = DecayManager.DecayTimePredictionLinearVariables(vessel);
                                TimeUntilDecayInDays  = FormatTimeUntilDecayInSecondsToString(TimeUntilDecayInUnits);
                            }

                            GUILayout.Label("Approximate Time Until Decay: " + TimeUntilDecayInDays);
                            GUILayout.Space(2);
                        }

                        GUILayout.Label("Station Keeping: " + StationKeeping);
                        GUILayout.Space(2);
                        GUILayout.Label("Station Keeping Fuel Remaining: " + StationKeepingFuelRemaining);
                        GUILayout.Space(2);
                        GUILayout.Label("Using Fuel Type: " + Resource); //151
                        GUILayout.Space(2);                              //151

                        if (StationKeeping == "True")
                        {
                            double DecayRateSKL = 0;

                            DecayRateSKL = DecayManager.DecayRateAtmosphericDrag(vessel) + DecayManager.DecayRateRadiationPressure(vessel) + DecayManager.DecayRateYarkovskyEffect(vessel);


                            double StationKeepingLifetime = (double.Parse(StationKeepingFuelRemaining) / ((DecayRateSKL / TimeWarp.CurrentRate) * VesselData.FetchEfficiency(vessel) /*ResourceManager.GetEfficiency(Resource)*/ * Settings.ReadResourceRateDifficulty())) / (60 * 60 * HoursInDay);

                            if (StationKeepingLifetime < -5) // SRP Fixes
                            {
                                GUILayout.Label("Station Keeping Fuel Lifetime: > 1000 years.");
                            }

                            else
                            {
                                if (StationKeepingLifetime > 365000 && HoursInDay == 24)
                                {
                                    GUILayout.Label("Station Keeping Fuel Lifetime: > 1000 years.");
                                }

                                else if (StationKeepingLifetime > 425000 && HoursInDay == 6)
                                {
                                    GUILayout.Label("Station Keeping Fuel Lifetime: > 1000 years.");
                                }

                                else
                                {
                                    if (StationKeepingLifetime > 425 && HoursInDay == 6)
                                    {
                                        GUILayout.Label("Station Keeping Fuel Lifetime: " + (StationKeepingLifetime / 425).ToString("F1") + " years.");
                                    }

                                    else if (StationKeepingLifetime > 365 && HoursInDay == 24)
                                    {
                                        GUILayout.Label("Station Keeping Fuel Lifetime: " + (StationKeepingLifetime / 365).ToString("F1") + " years.");
                                    }

                                    else
                                    {
                                        GUILayout.Label("Station Keeping Fuel Lifetime: " + StationKeepingLifetime.ToString("F1") + " days.");
                                    }
                                }
                            }
                            GUILayout.Space(3);
                        }

                        if (GUILayout.Button(ButtonText))
                        {
                            if (StationKeeping == "True")
                            {
                                VesselData.UpdateStationKeeping(vessel, false);
                                ScreenMessages.PostScreenMessage("Vessel: " + vessel.vesselName + (": Station Keeping Disabled"));
                            }

                            if (StationKeeping == "False")
                            {
                                if (StationKeepingManager.EngineCheck(vessel) == true)
                                {
                                    if ((double.Parse(StationKeepingFuelRemaining) > 0.01)) // Good enough...
                                    {
                                        VesselData.UpdateStationKeeping(vessel, true);
                                        ScreenMessages.PostScreenMessage("Vessel: " + vessel.vesselName + (": Station Keeping Enabled"));
                                    }
                                    else
                                    {
                                        ScreenMessages.PostScreenMessage("Vessel: " + vessel.vesselName + (" has no fuel to Station Keep!"));
                                    }
                                }
                                else
                                {
                                    ScreenMessages.PostScreenMessage("Vessel: " + vessel.vesselName + (" has no Engines or RCS modules on board!"));
                                }
                            }
                        }
                        GUILayout.Space(2);
                        GUILayout.Label("_____________________________________");
                        GUILayout.Space(3);
                        GUILayout.EndVertical();
                    }
                }
            }
            GUILayout.EndScrollView();
        }