当前位置: 首页>>代码示例>>C#>>正文


C# CelestialBody.RealMaxAtmosphereAltitude方法代码示例

本文整理汇总了C#中CelestialBody.RealMaxAtmosphereAltitude方法的典型用法代码示例。如果您正苦于以下问题:C# CelestialBody.RealMaxAtmosphereAltitude方法的具体用法?C# CelestialBody.RealMaxAtmosphereAltitude怎么用?C# CelestialBody.RealMaxAtmosphereAltitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CelestialBody的用法示例。


在下文中一共展示了CelestialBody.RealMaxAtmosphereAltitude方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateAtmoTexture

        //redraw the picture of the planned flight path
        public static void UpdateAtmoTexture(Texture2D texture, CelestialBody mainBody, double maxAltitude, bool realAtmo = false)
        {
            double scale = maxAltitude / texture.height; //meters per pixel

            double maxAtmosphereAltitude = mainBody.RealMaxAtmosphereAltitude();
            double pressureSeaLevel = mainBody.atmospherePressureSeaLevel;

            for (int y = 0; y < texture.height; y++)
            {
                double alt = scale * y;

                if (realAtmo)
                {
                    alt = mainBody.GetPressure(alt) / pressureSeaLevel;
                }
                else
                {
                    alt = 1.0 - alt / maxAtmosphereAltitude;
                }

                float v = (float)(mainBody.atmosphere ? alt : 0.0F);
                Color c = new Color(0.0F, 0.0F, v);

                for (int x = 0; x < texture.width; x++)
                {
                    texture.SetPixel(x, y, c);

                    if (mainBody.atmosphere && (int)(maxAtmosphereAltitude / scale) == y)
                        texture.SetPixel(x, y, XKCDColors.LightGreyBlue);
                }
            }

            texture.Apply();
        }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:35,代码来源:MechJebModuleAscentPathEditor.cs

示例2: OnFixedUpdate

        //        public override void OnStart(PartModule.StartState state)
        //        {
        //            base.OnStart(state);
        //            
        //            fiSelRes = Type.GetType("Kethane.KethaneController").GetField("SelectedResource");
        //        }
        public override void OnFixedUpdate()
        {
            //			base.OnFixedUpdate();
            if (HighLogic.LoadedScene != GameScenes.FLIGHT || KethaneData.Current == null) { return; }

            if (lastBody != vessel.orbit.referenceBody) { // thanks to The_Duck, Technogeeky and ian for helping me fix the orbit calculation
                lastBody = vessel.orbit.referenceBody;
            //				Debug.Log("GravParameter " + lastBody.gravParameter);
                Orbits = new List<float>();
                int y = 1;
                var u3 = Math.Pow(lastBody.gravParameter, 1.0 / 3.0);
                while (y > 0)
                {
                    var oP = lastBody.rotationPeriod * (y / 80f);
                    var alt = u3 * Math.Pow(oP / (2 * Math.PI), 2.0 / 3.0) - lastBody.Radius;
                    var msg = string.Format("Orbit {0} is at {1:F1} km", y, alt / 1000f);
                    if (y % 2 != 0 && y % 5 != 0 && alt > 0 && alt < lastBody.sphereOfInfluence && (lastBody.atmosphere ? alt > lastBody.RealMaxAtmosphereAltitude() : true))
                    {
                        msg += " added";
                        Orbits.Add((float)alt / 1000f);
            //						Debug.Log(msg);
                    }
                    y++;
                    if (alt >= lastBody.sphereOfInfluence) { break; }
                }
                Orbits.Sort();
                string str = "";
                foreach (var o in Orbits)
                {
                    str += o.ToString("#.0") + " km\n";
                }
                System.IO.File.WriteAllText(KSPUtil.ApplicationRootPath + "\\KethaneScanOrbits_" + lastBody.name + ".txt", str);
            }

            //			var scans = KethaneData.Current.Scans[(string)fiSelRes.GetValue(null)][vessel.mainBody.name];
            var scans = KethaneData.Current.Scans[MapOverlay.SelectedResource][vessel.mainBody.name];
            Coverage = (float)Math.Floor(ordered.Count(c => scans[c]) / (float)ordered.Length * 100f * 100f) / 100f;

            var cell = GetLowestUnscanned(scans);
            if (Coverage == 100 && Active) {
                print(vessel.mainBody.name + " completely scanned at " + vesselState.time);
                TimeWarp.SetRate(0, false);
                Active = false;
            }
            maxInc = CellToLonLat(cell).y;

            if (Active)
            {
                var curInc = Math.Abs(maxInc);
                var myInc = Math.Abs(vesselState.orbitInclination);
                var diff = Math.Abs(myInc - curInc);

                switch (Status)
                {
                    case ControllerState.Inactive:
                        Status = ControllerState.Idle;
                        break;

                    case ControllerState.Idle:
                        if (diff > IncChangeStep && curInc >= IncChangeLimit && vessel.patchedConicSolver.maneuverNodes.Count == 0) {
                            var planner = core.GetComputerModule<MechJebModuleManeuverPlanner>();

                            double newInc;
                            if (ChangeByStep) {
                                newInc = vesselState.orbitInclination - (IncChangeStep * (vesselState.orbitInclination < 0 ? -1 : 1));
                            }
                            else
                            {
                                newInc = (curInc * (vesselState.orbitInclination < 0 ? -1 : 1));
                            }
                            newInc = Math.Round(newInc, 2);

                            var result = planner.PlanNode(MechJebModuleManeuverPlanner.Operation.INCLINATION,
                                                          MechJebModuleManeuverPlanner.TimeReference.EQ_ASCENDING, 0, 0, 0, newInc, 0, 0, 0, false);

                            if (result.Success && core.node != null) {
                                core.node.ExecuteOneNode(this);
                            }
                            else {
                                Active = false;
                                Status = ControllerState.Inactive;
                                print("KSC node planning error: " + result.Error + "\ntime error: " + result.TimeError);
                            }

                            warp = TimeWarp.CurrentRateIndex;
                            TimeWarp.SetRate(0, true);
                            Status = ControllerState.Waiting;
                        }
                        break;

                    case ControllerState.Waiting:
                        if (vessel.patchedConicSolver.maneuverNodes.Count == 0 && vessel.ctrlState.mainThrottle == 0)
                        {
                            TimeWarp.SetRate(warp, false);
//.........这里部分代码省略.........
开发者ID:BloodyRain2k,项目名称:MechJebKethaneSatCon,代码行数:101,代码来源:MechJebModuleKethaneSatelliteController.cs


注:本文中的CelestialBody.RealMaxAtmosphereAltitude方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。