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


C# ConfigNode.AddData方法代码示例

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


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

示例1: OrbitPatcher

        public string OrbitPatcher(Body body)
        {
            // This if is here to make sure stars don't give us trouble
            if (body.generatedBody.orbitDriver.orbit.referenceBody == null)
                body.generatedBody.orbitDriver.orbit.referenceBody = ListOfBodies.Find(rb => rb.name == body.orbit.referenceBody).generatedBody.celestialBody;

            if (!body.generatedBody.celestialBody.Has("sbPatched") && body.generatedBody.celestialBody.Has("orbitPatches"))
            {
                ConfigNode patch = new ConfigNode();
                if (body.generatedBody.celestialBody.orbit != null)
                {
                    OrbitLoader loader = new OrbitLoader();
                    patch.AddData(body.generatedBody.celestialBody.Get<ConfigNode>("orbitPatches"));

                    Parser.LoadObjectFromConfigurationNode(loader, patch);
                    body.generatedBody.orbitDriver.orbit = new Orbit(loader.orbit);
                }
                // This "else" is here to make sure stars don't give us trouble
                else
                {
                    OrbitLoader loader = new OrbitLoader();
                    loader.orbit = new Orbit();
                    loader.orbit.referenceBody = body.generatedBody.orbitDriver.orbit.referenceBody;
                    patch.AddData(body.generatedBody.celestialBody.Get<ConfigNode>("orbitPatches"));

                    Parser.LoadObjectFromConfigurationNode(loader, patch);
                    if (!patch.HasValue("inclination")) loader.orbit.inclination = 0;
                    if (!patch.HasValue("eccentricity")) loader.orbit.eccentricity = 0;
                    if (!patch.HasValue("semiMajorAxis")) loader.orbit.semiMajorAxis = 0;
                    if (!patch.HasValue("longitudeOfAscendingNode")) loader.orbit.LAN = 0;
                    if (!patch.HasValue("argumentOfPeriapsis")) loader.orbit.argumentOfPeriapsis = 0;
                    if (!patch.HasValue("meanAnomalyAtEpoch") && !patch.HasValue("meanAnomalyAtEpochD")) loader.orbit.meanAnomalyAtEpoch = 0;
                    if (!patch.HasValue("epoch")) loader.orbit.epoch = 0;

                    body.generatedBody.orbitDriver.orbit = new Orbit(loader.orbit);
                }

                body.generatedBody.celestialBody.Set("orbitPatches", new ConfigNode());

                if (patch.GetValue("referenceBody") != null)
                    body.orbit.referenceBody = patch.GetValue("referenceBody");

                if (patch.GetValue("referenceBody") != null && body.name == "Kerbin")
                {
                    // Keep the ConfigNode for Kerbin's referenceBody in case Kerbin is the sbSecondary
                    ConfigNode temp = body.generatedBody.celestialBody.Get<ConfigNode>("orbitPatches");
                    temp.AddValue("referenceBody", patch.GetValue("referenceBody"));
                    body.generatedBody.celestialBody.Set("orbitPatches", temp);
                    body.generatedBody.celestialBody.Set("sbPatched", true);
                }
                else
                {
                    body.generatedBody.celestialBody.Set("orbitPatches", new ConfigNode());
                }

                // Fix sphereOfInfluence
                if (!body.generatedBody.celestialBody.Has("sphereOfInfluence"))
                    body.generatedBody.celestialBody.sphereOfInfluence = body.generatedBody.orbitDriver.orbit.semiMajorAxis * Math.Pow(body.generatedBody.celestialBody.Mass / ListOfBodies.Find(rb => rb.name == body.orbit.referenceBody).generatedBody.celestialBody.Mass, 0.4);

            }
            return body.orbit.referenceBody;
        }
开发者ID:Sigma88,项目名称:Sigma-Binary,代码行数:62,代码来源:SigmaBinary.cs


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