本文整理汇总了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;
}