當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。