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


C# CelestialBody.CBUpdate方法代码示例

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


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

示例1: WarpPlanet

 static void WarpPlanet(CelestialBody body, Orbit newOrbit)
 {
     var oldBody = body.referenceBody;
     HardsetOrbit (body.orbit, newOrbit);
     if (oldBody != newOrbit.referenceBody) {
         oldBody.orbitingBodies.Remove (body);
         newOrbit.referenceBody.orbitingBodies.Add (body);
     }
     body.CBUpdate ();
 }
开发者ID:602p,项目名称:krpc,代码行数:10,代码来源:OrbitTools.cs

示例2: OnPSystemReady

        public void OnPSystemReady(RootDefinition Root, CelestialBody OriginalSun, Transform ScaledSun)
        {
            Debug.Log("Altering sun...");

            //Set Original Sun Parameters
            double SolarMasses;

            SolarMasses = Root.SolarMasses;

            OriginalSun.Mass = SolarMasses * OriginalSun.Mass;
            OriginalSun.Radius = (2 * (6.74E-11) * OriginalSun.Mass) / (Math.Pow(299792458, 2.0));
            OriginalSun.GeeASL = OriginalSun.Mass * (6.674E-11 / 9.81) / Math.Pow(OriginalSun.Radius, 2.0);
            OriginalSun.gMagnitudeAtCenter = OriginalSun.GeeASL * 9.81 * Math.Pow(OriginalSun.Radius, 2.0);
            OriginalSun.gravParameter = OriginalSun.gMagnitudeAtCenter;

            OriginalSun.scienceValues.InSpaceLowDataValue = OriginalSun.scienceValues.InSpaceLowDataValue * 10f;
            OriginalSun.scienceValues.RecoveryValue = OriginalSun.scienceValues.RecoveryValue * 5f;

            OriginalSun.bodyName = "Blacky Karman";

            OriginalSun.bodyDescription =
                "This recently discovered black hole, named after its discoverer Billy-Hadrick Kerman, is the central point where multiple star systems revolve around.";

            OriginalSun.CBUpdate();

            //Make Sun Black
            ScaledSun.renderer.material.SetColor("_EmitColor0", new Color(0.0f, 0.0f, 0.0f, 1));
            ScaledSun.renderer.material.SetColor("_EmitColor1", new Color(0.0f, 0.0f, 0.0f, 1));
            ScaledSun.renderer.material.SetColor("_SunspotColor", new Color(0.0f, 0.0f, 0.0f, 1));
            ScaledSun.renderer.material.SetColor("_RimColor", new Color(0.0f, 0.0f, 0.0f, 1.0f));

            //Update Sun Scale
            var ScaledSunMeshFilter = (MeshFilter)ScaledSun.GetComponent(typeof(MeshFilter));
            var SunRatio = (float)OriginalSun.Radius / 261600000f;

            MeshScaler.ScaleMesh(ScaledSunMeshFilter.mesh, SunRatio);

            //Change Sun Corona
            foreach (var SunCorona in ScaledSun.GetComponentsInChildren<SunCoronas>())
            {
                SunCorona.renderer.material.mainTexture =
                    GameDatabase.Instance.GetTexture("StarSystems/Resources/BlackHoleCorona", false);
                var SunCoronaMeshFilter = (MeshFilter)SunCorona.GetComponent(typeof(MeshFilter));
                MeshScaler.ScaleMesh(SunCoronaMeshFilter.mesh, SunRatio);
            }

            Debug.Log("Sun altered");
        }
开发者ID:kevin-ye,项目名称:StarSystems,代码行数:48,代码来源:CenterRoot.cs

示例3: FinalizeOrbit

            // Finalize an Orbit
            public static void FinalizeOrbit(CelestialBody body)
            {
                if (body.orbitDriver != null)
                {
                    if (body.referenceBody != null)
                    {
                        // Only recalculate the SOI, if it's not forced
                        if (!Templates.hillSphere.ContainsKey(body.transform.name))
                            body.hillSphere = body.orbit.semiMajorAxis * (1.0 - body.orbit.eccentricity) * Math.Pow(body.Mass / body.orbit.referenceBody.Mass, 1.0 / 3.0);

                        if (!Templates.sphereOfInfluence.ContainsKey(body.transform.name))
                            body.sphereOfInfluence = Math.Max(
                                body.orbit.semiMajorAxis * Math.Pow(body.Mass / body.orbit.referenceBody.Mass, 0.4),
                                Math.Max(body.Radius * Templates.SOIMinRadiusMult, body.Radius + Templates.SOIMinAltitude));

                        // this is unlike stock KSP, where only the reference body's mass is used.
                        body.orbit.period = 2 * Math.PI * Math.Sqrt(Math.Pow(body.orbit.semiMajorAxis, 2) / 6.674E-11 * body.orbit.semiMajorAxis / (body.referenceBody.Mass + body.Mass));
                        body.orbit.meanMotion = 2 * Math.PI / body.orbit.period;    // in theory this should work but I haven't tested it

                        if (body.orbit.eccentricity <= 1.0)
                        {
                            body.orbit.meanAnomaly = body.orbit.meanAnomalyAtEpoch;
                            body.orbit.orbitPercent = body.orbit.meanAnomalyAtEpoch / (Math.PI * 2);
                            body.orbit.ObTAtEpoch = body.orbit.orbitPercent * body.orbit.period;
                        }
                        else
                        {
                            // ignores this body's own mass for this one...
                            body.orbit.meanAnomaly = body.orbit.meanAnomalyAtEpoch;
                            body.orbit.ObT = Math.Pow(Math.Pow(Math.Abs(body.orbit.semiMajorAxis), 3.0) / body.orbit.referenceBody.gravParameter, 0.5) * body.orbit.meanAnomaly;
                            body.orbit.ObTAtEpoch = body.orbit.ObT;
                        }
                    }
                    else
                    {
                        body.sphereOfInfluence = Double.PositiveInfinity;
                        body.hillSphere = Double.PositiveInfinity;
                    }
                }
                try
                {
                    body.CBUpdate();
                }
                catch (Exception e)
                {
                    UnityEngine.Debug.Log("CBUpdate for " + body.name + " failed: " + e.Message);
                }
            }
开发者ID:Kerbas-ad-astra,项目名称:Kopernicus,代码行数:49,代码来源:OrbitLoader.cs

示例4: UpdateBody

 private void UpdateBody(CelestialBody body, double universal_time)
 {
     plugin_.UpdateCelestialHierarchy(
     body.flightGlobalsIndex,
     body.orbit.referenceBody.flightGlobalsIndex);
     QP from_parent = plugin_.CelestialFromParent(body.flightGlobalsIndex);
     // TODO(egg): Some of this might be be superfluous and redundant.
     Orbit original = body.orbit;
     Orbit copy = new Orbit(original.inclination, original.eccentricity,
                original.semiMajorAxis, original.LAN,
                original.argumentOfPeriapsis,
                original.meanAnomalyAtEpoch, original.epoch,
                original.referenceBody);
     copy.UpdateFromStateVectors((Vector3d)from_parent.q,
                     (Vector3d)from_parent.p,
                     copy.referenceBody,
                     universal_time);
     body.orbit.inclination = copy.inclination;
     body.orbit.eccentricity = copy.eccentricity;
     body.orbit.semiMajorAxis = copy.semiMajorAxis;
     body.orbit.LAN = copy.LAN;
     body.orbit.argumentOfPeriapsis = copy.argumentOfPeriapsis;
     body.orbit.meanAnomalyAtEpoch = copy.meanAnomalyAtEpoch;
     body.orbit.epoch = copy.epoch;
     body.orbit.referenceBody = copy.referenceBody;
     body.orbit.Init();
     body.orbit.UpdateFromUT(universal_time);
     body.CBUpdate();
     body.orbit.UpdateFromStateVectors((Vector3d)from_parent.q,
                           (Vector3d)from_parent.p,
                           copy.referenceBody,
                           universal_time);
 }
开发者ID:pleroy,项目名称:Principia,代码行数:33,代码来源:ksp_plugin_adapter.cs

示例5: LoadCB


//.........这里部分代码省略.........
                    {
                        Vector4 col = KSPUtil.ParseVector4(onode.GetValue("orbitColor"));
                        Color c = new Color(col.x, col.y, col.z, col.w);
                        body.GetOrbitDriver().orbitColor = c;
                    }
                    catch (Exception e)
                    {
                        print("*RSS* Error parsing as color4: original text: " + onode.GetValue("orbitColor") + " --- exception " + e.Message);
                    }
                }
                string bodyname = "";
                if (onode.TryGetValue("referenceBody", ref bodyname))
                {
                    if (body.orbit.referenceBody == null || !body.orbit.referenceBody.Equals(bodyname))
                    {
                        foreach (CelestialBody b in FlightGlobals.Bodies)
                        {
                            if (b.name.Equals(bodyname))
                            {
                                if (body.orbit.referenceBody)
                                {
                                    body.orbit.referenceBody.orbitingBodies.Remove(body);
                                }
                                b.orbitingBodies.Add(body);
                                body.orbit.referenceBody = b;
                                break;
                            }
                        }
                    }
                }
            }
            yield return null;
            // SOI and HillSphere done at end
            body.CBUpdate();
            #endregion
            #endregion

            #region SSPQSFade
            // Scaled space fader
            float SSFMult = 1.0f;
            float SSFStart = -1, SSFEnd = -1;
            node.TryGetValue("SSFStart", ref SSFStart);
            node.TryGetValue("SSFEnd", ref SSFEnd);
            node.TryGetValue("SSFMult", ref SSFMult);

            foreach (ScaledSpaceFader ssf in Resources.FindObjectsOfTypeAll(typeof(ScaledSpaceFader)))
            {
                if (ssf.celestialBody != null)
                {
                    if (ssf.celestialBody.name.Equals(node.name))
                    {
                        if (SSFStart >= 0)
                            ssf.fadeStart = SSFStart;
                        else
                            ssf.fadeStart *= SSFMult;

                        if (SSFEnd >= 0)
                            ssf.fadeEnd = SSFEnd;
                        else
                            ssf.fadeEnd *= SSFMult;
                    }
                }
            }
            // The CBT that fades out the PQS
            // Should probably do this as just another PQSMod, actually.
            foreach (PQSMod_CelestialBodyTransform c in Resources.FindObjectsOfTypeAll(typeof(PQSMod_CelestialBodyTransform)))
开发者ID:tudela,项目名称:RealSolarSystem,代码行数:67,代码来源:RealSolarSystem.cs

示例6: PatchBody


//.........这里部分代码省略.........
                if (node.HasNode("latitudeTemperatureSunMultCurve"))
                {
                    body.latitudeTemperatureSunMultCurve.Load(node.GetNode("latitudeTemperatureSunMultCurve"));
                }
                if (node.HasNode("axialTemperatureSunMultCurve"))
                {
                    body.axialTemperatureSunMultCurve.Load(node.GetNode("axialTemperatureSunMultCurve"));
                }
                if (node.HasNode("atmosphereTemperatureSunMultCurve"))
                {
                    body.atmosphereTemperatureSunMultCurve.Load(node.GetNode("atmosphereTemperatureSunMultCurve"));
                }
                if (node.HasNode("axialTemperatureSunBiasCurve"))
                {
                    body.axialTemperatureSunBiasCurve.Load(node.GetNode("axialTemperatureSunBiasCurve"));
                }
                if (node.HasNode("axialTemperatureSunMultCurve"))
                {
                    body.axialTemperatureSunMultCurve.Load(node.GetNode("axialTemperatureSunMultCurve"));
                }
                if (node.HasNode("eccentricityTemperatureBiasCurve"))
                {
                    body.eccentricityTemperatureBiasCurve.Load(node.GetNode("eccentricityTemperatureBiasCurve"));
                }

                if (node.HasValue("Radius"))
                {
                    if (double.TryParse(node.GetValue("Radius"), out dtmp))
                    {
                        body.Radius = dtmp;
                        updateMass = true;
                    }
                }

                // Orbit
                ConfigNode onode = node.GetNode("Orbit");
                if (body.orbitDriver != null && body.orbit != null && onode != null)
                {
                    patchOrbits = true;

                    if (node.HasValue("semiMajorAxis"))
                        if (double.TryParse(node.GetValue("semiMajorAxis"), out dtmp))
                            body.orbit.semiMajorAxis = dtmp;
                    if (node.HasValue("eccentricity"))
                        if (double.TryParse(node.GetValue("eccentricity"), out dtmp))
                            body.orbit.eccentricity = dtmp;
                    if (node.HasValue("meanAnomalyAtEpoch"))
                        if (double.TryParse(node.GetValue("meanAnomalyAtEpoch"), out dtmp))
                            body.orbit.meanAnomalyAtEpoch = dtmp;

                    if (node.HasValue("meanAnomalyAtEpochD"))
                    {
                        if (double.TryParse(node.GetValue("meanAnomalyAtEpochD"), out dtmp))
                        {
                            body.orbit.meanAnomalyAtEpoch = dtmp;
                            body.orbit.meanAnomalyAtEpoch *= DEG2RAD;
                        }
                    }
                    if (node.HasValue("inclination"))
                        if (double.TryParse(node.GetValue("inclination"), out dtmp))
                            body.orbit.inclination = dtmp;
                    if (node.HasValue("LAN"))
                        if (double.TryParse(node.GetValue("LAN"), out dtmp))
                            body.orbit.LAN = dtmp;
                    if (node.HasValue("argumentOfPeriapsis"))
                        if (double.TryParse(node.GetValue("argumentOfPeriapsis"), out dtmp))
                            body.orbit.argumentOfPeriapsis = dtmp;

                }
            }
            else if (globalRotationRescale != 1d || globalRescale != 1d)
                print("Patching body " + body.bodyName + " from globals.");

            body.rotationPeriod *= globalRotationRescale;

            if(globalRescale != 1d)
            {
                body.Radius *= globalRescale;
                updateMass = true;
            }
            if (updateMass)
            {
                patchOrbits = true;
                GeeASLToOthers(body);
            }
            if (globalRescaleAtmo != 1d && body.atmosphere)
            {
                body.atmospherePressureCurve = RescaleCurve(body.atmospherePressureCurve, globalRescaleAtmo);
                body.atmosphereTemperatureCurve = RescaleCurve(body.atmosphereTemperatureCurve, globalRescaleAtmo);
                body.atmosphereTemperatureSunMultCurve = RescaleCurve(body.atmosphereTemperatureSunMultCurve, globalRescaleAtmo);
                body.atmosphereDepth *= globalRescaleAtmo;
            }

            body.SetupConstants();
            // Fix up PQS
            if(PatchPQS(body, node, origRadius) || origRadius != body.Radius)
                StartCoroutine(PatchScaledSpace(body, node, origRadius));
            body.CBUpdate();
            return true;
        }
开发者ID:NathanKell,项目名称:BodyLoader,代码行数:101,代码来源:BodyLoader.cs

示例7: LoadCB

 public static void LoadCB(CelestialBody body)
 {
     var root = ConfigNode.Load(DataPath + body.bodyName + ".cfg");
     if (root != null)
     {
         var cbConfig = root.nodes.GetNode("CelestialBody");
         if (cbConfig != null)
         {
             print("loading CB config:" + body.bodyName);
             LoadConfiguration(body, cbConfig);
             body.CBUpdate();
         }
     }
 }
开发者ID:jesusHERCULESchrist,项目名称:PlanetFactory,代码行数:14,代码来源:PlanetFactory.cs


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