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


C# ConfigNode.GetNode方法代码示例

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


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

示例1: LoadItems

 internal IEnumerator<YieldInstruction> LoadItems(ConfigNode settings, System.Random random)
 {
     foreach (string type in KRESUtils.types.Values)
     {
         if (KRESUtils.GetRelevantBodies(type).Any(b => b.bodyName == this.Name))
         {
             foreach (ConfigNode data in settings.GetNode(type).GetNode(this.Name).GetNodes("KRES_DATA"))
             {
                 string resourceName = string.Empty;
                 data.TryGetValue("name", ref resourceName);
                 if (!PartResourceLibrary.Instance.resourceDefinitions.Contains(resourceName)) { continue; }
                 if (type == "ore")
                 {
                     string path = Path.Combine(KRESUtils.GetSavePath(), "KRESTextures/" + name + "/" + resourceName + ".png");
                     if (File.Exists(path))
                     {
                         ResourceItem item = new ResourceItem(data, resourceName, this.Name, random);
                         resourceItems.Add(item);
                     }
                 }
                 else if (type == "gas" || type == "liquid")
                 {
                     ResourceItem item = new ResourceItem(data, resourceName, this.Name, type, random);
                     resourceItems.Add(item);
                 }
                 yield return null;
             }
         }
     }
 }
开发者ID:CYBUTEK,项目名称:KRES,代码行数:30,代码来源:ResourceBody.cs

示例2: Save

        public void Save(ConfigNode node)
        {
            if (node.HasNode("KOLONIZATION"))
            {
                SettingsNode = node.GetNode("KOLONIZATION");
            }
            else
            {
                SettingsNode = node.AddNode("KOLONIZATION");
            }

            foreach (KolonizationEntry r in _LogInfo)
            {
                var rNode = new ConfigNode("KOLONY_ENTRY");
                rNode.AddValue("BodyIndex", r.BodyIndex);
                rNode.AddValue("VesselId", r.VesselId);
                rNode.AddValue("LastUpdate", r.LastUpdate);
                rNode.AddValue("KolonyDate", r.KolonyDate);
                rNode.AddValue("GeologyResearch", r.GeologyResearch);
                rNode.AddValue("BotanyResearch", r.BotanyResearch);
                rNode.AddValue("KolonizationResearch", r.KolonizationResearch);
                rNode.AddValue("Science", r.Science);
                rNode.AddValue("Rep", r.Rep);
                rNode.AddValue("Funds", r.Funds);
                SettingsNode.AddNode(rNode);
            }

            //Reset cache
            KolonizationManager.Instance.ResetCache();
        }
开发者ID:nanathan,项目名称:Kolonization,代码行数:30,代码来源:KolonizationPersistance.cs

示例3: Preset

 /// <summary>
 /// Creates a new Preset from the given ConfigNode
 /// </summary>
 /// <param name="node">ConfigNode to create the object from</param>
 public Preset(ConfigNode node)
 {
     node.TryGetValue("name", ref _name);
     node.TryGetValue("description", ref _description);
     node.TryGetValue("textureLibrary", ref _textureLibrary);
     node.TryGetValue("sizeID", ref _sizeID);
     node.TryGetValue("cutSpeed", ref _cutSpeed);
     node.TryGetValue("timer", ref _timer);
     node.TryGetValue("mustGoDown", ref _mustGoDown);
     node.TryGetValue("deployOnGround", ref _deployOnGround);
     node.TryGetValue("spares", ref _spares);
     node.TryGetValue("caseName", ref _caseName);
     node.TryGetValue("bodyName", ref _bodyName);
     if (node.HasNode("MAIN")) { _main = new ChuteParameters(node.GetNode("MAIN")); }
     if (node.HasNode("SECONDARY")) { _secondary = new ChuteParameters(node.GetNode("SECONDARY")); }
 }
开发者ID:vosechu,项目名称:RealChute,代码行数:20,代码来源:Preset.cs

示例4: Load

        //Settings Functions Follow
        internal void Load(ConfigNode node)
        {
            if (node.HasNode(configNodeName))
            {
                ConfigNode DFsettingsNode = node.GetNode(configNodeName);

                fixtimecounts = Utilities.GetNodeValue(DFsettingsNode, "fixtimecounts", fixtimecounts);
            }
        }
开发者ID:khr15714n,项目名称:DeepFreeze,代码行数:10,代码来源:DFInstallFix.cs

示例5: ResourceDefinition

        public ResourceDefinition(ConfigNode node)
        {
            Resource = node.GetValue("Resource");
            var colorFull = node.GetValue("ColorFull");
            ColorFull = colorFull != null ? ConfigNode.ParseColor(colorFull) : Color.white;
            var colorEmpty = node.GetValue("ColorEmpty");
            ColorEmpty = colorEmpty != null ? ConfigNode.ParseColor(colorEmpty) : Color.white;

            Generator = node.GetNode("Generator") ?? new ConfigNode();
        }
开发者ID:SiriusSam,项目名称:Kethane,代码行数:10,代码来源:ResourceDefinition.cs

示例6: Load

 public void Load(ConfigNode node)
 {
     if (node.HasNode("PLANETARY_LOGISTICS"))
     {
         SettingsNode = node.GetNode("PLANETARY_LOGISTICS");
         _LogInfo = SetupLogInfo();
         //Reset cache
         PlanetaryLogisticsManager.Instance.ResetCache();
     }
     else
     {
         _LogInfo = new List<PlanetaryLogisticsEntry>();
     }
 }
开发者ID:nanathan,项目名称:Kolonization,代码行数:14,代码来源:PlanetaryLogisticsPersistance.cs

示例7: Load

 public void Load(ConfigNode node)
 {
     if (node.HasNode("KOLONIZATION"))
     {
         SettingsNode = node.GetNode("KOLONIZATION");
         _LogInfo = SetupLogInfo();
         //Reset cache
         KolonizationManager.Instance.ResetCache();
     }
     else
     {
         _LogInfo = new List<KolonizationEntry>();
     }
 }
开发者ID:nanathan,项目名称:Kolonization,代码行数:14,代码来源:KolonizationPersistance.cs

示例8: Save

        internal void Save(ConfigNode node)
        {
            ConfigNode settingsNode;
            if (node.HasNode(configNodeName))
            {
                settingsNode = node.GetNode(configNodeName);
                settingsNode.ClearData();
            }
            else
            {
                settingsNode = node.AddNode(configNodeName);
            }

            settingsNode.AddValue("fixtimecounts", false);
        }
开发者ID:khr15714n,项目名称:DeepFreeze,代码行数:15,代码来源:DFInstallFix.cs

示例9: ScaleType

        public ScaleType(ConfigNode config)
        {
            ScaleNodes = new int[] {};
            if ((object)config == null || Tools.ConfigValue(config, "name", "default") == "default")
            {
                return; // Default values.
            }

            var type = Tools.ConfigValue(config, "type", "default");
            var source = GetScaleConfig(type);

            IsFreeScale   = Tools.ConfigValue(config, "freeScale",    source.IsFreeScale);
            MinValue      = Tools.ConfigValue(config, "minScale",     source.MinValue);
            MaxValue      = Tools.ConfigValue(config, "maxScale",     source.MaxValue);
            Suffix        = Tools.ConfigValue(config, "suffix",       source.Suffix);
            _scaleFactors = Tools.ConfigValue(config, "scaleFactors", source._scaleFactors);
            ScaleNodes    = Tools.ConfigValue(config, "scaleNodes",   source.ScaleNodes);
            _scaleNames   = Tools.ConfigValue(config, "scaleNames",   source._scaleNames).Select(a => a.Trim()).ToArray();
            TechRequired  = Tools.ConfigValue(config, "techRequired", source.TechRequired).Select(a=>a.Trim()).ToArray();
            Name          = Tools.ConfigValue(config, "name",         "unnamed scaletype");
            Family        = Tools.ConfigValue(config, "family",       "default");
            AttachNodes   = GetNodeFactors(config.GetNode("ATTACHNODES"), source.AttachNodes);
            if (Name == "TweakScale")
            {
                Name = source.Name;
            }

            if (_scaleFactors.Length != _scaleNames.Length)
            {
                Tools.LogWf("Wrong number of scaleFactors compared to scaleNames: {0} scaleFactors vs {1} scaleNames", _scaleFactors.Length, _scaleNames.Length);
            }

            if (TechRequired.Length < _scaleFactors.Length)
            {
                TechRequired = TechRequired.Concat("".Repeat()).Take(_scaleFactors.Length).ToArray();
            }

            var tmpScale = Tools.ConfigValue(config, "defaultScale", source.DefaultScale);
            if (!IsFreeScale)
            {
                tmpScale = Tools.Closest(tmpScale, AllScaleFactors);
            }
            DefaultScale = Tools.Clamp(tmpScale, MinValue, MaxValue);

            Exponents = ScaleExponents.CreateExponentsForModule(config, source.Exponents);
        }
开发者ID:Biotronic,项目名称:TweakScale,代码行数:46,代码来源:ScaleType.cs

示例10: Save

        public void Save(ConfigNode node)
        {
            if (node.HasNode("PLANETARY_LOGISTICS"))
            {
                SettingsNode = node.GetNode("PLANETARY_LOGISTICS");
            }
            else
            {
                SettingsNode = node.AddNode("PLANETARY_LOGISTICS");
            }

            foreach (PlanetaryLogisticsEntry r in _LogInfo)
            {
                var rNode = new ConfigNode("LOGISTICS_ENTRY");
                rNode.AddValue("BodyIndex", r.BodyIndex);
                rNode.AddValue("ResourceName", r.ResourceName);
                rNode.AddValue("StoredQuantity", r.StoredQuantity);
                SettingsNode.AddNode(rNode);
            }

            //Reset cache
            PlanetaryLogisticsManager.Instance.ResetCache();
        }
开发者ID:nanathan,项目名称:Kolonization,代码行数:23,代码来源:PlanetaryLogisticsPersistance.cs

示例11: AtmosphereFromGroundParser

 // Parser post apply event
 void IParserEventSubscriber.PostApply(ConfigNode node)
 {
     // Manipulate AFG
     AtmosphereFromGround afg = scaledVersion.GetComponentsInChildren<AtmosphereFromGround>(true)[0] as AtmosphereFromGround;
     if (node.HasNode("AtmosphereFromGround") && afg != null)
     {
         AtmosphereFromGroundParser atmoFG = new AtmosphereFromGroundParser(afg, celestialBody);
         Parser.LoadObjectFromConfigurationNode(atmoFG, node.GetNode("AtmosphereFromGround"));
     }
 }
开发者ID:KillAshley,项目名称:Kopernicus,代码行数:11,代码来源:Atmosphere.cs

示例12: LandClassLoader

                void IParserEventSubscriber.PostApply(ConfigNode node)
                {
                    // Load the LandClasses manually, to support patching
                    if (node.HasNode("landClasses"))
                    {
                        // Already patched classes
                        List<PQSLandControl.LandClass> patchedClasses = new List<PQSLandControl.LandClass>();
                        if (_mod.landClasses != null)
                            _mod.landClasses.ToList().ForEach(c => landClasses.Add(new LandClassLoader(c)));

                        // Go through the nodes
                        foreach (ConfigNode lcNode in node.GetNode("landClasses").nodes)
                        {
                            // The Loader
                            LandClassLoader loader = null;

                            // Are there existing LandClasses?
                            if (landClasses.Count > 0)
                            {
                                // Attempt to find a LandClass we can edit that we have not edited before
                                loader = landClasses.Where(m => !patchedClasses.Contains(m.landClass) && (lcNode.HasValue("name") ? m.landClass.landClassName == lcNode.GetValue("name") : false))
                                                                 .FirstOrDefault();

                                // Load the Loader (lol)
                                if (loader != null)
                                {
                                    Parser.LoadObjectFromConfigurationNode(loader, lcNode);
                                    if (loader.delete.value)
                                        landClasses.Remove(loader);
                                    else
                                        patchedClasses.Add(loader.landClass);
                                }
                            }

                            // If we can't patch a LandClass, create a new one
                            if (loader == null)
                            {
                                loader = Parser.CreateObjectFromConfigNode(typeof(LandClassLoader), lcNode) as LandClassLoader;
                            }

                            // Add the Loader to the List
                            landClasses.Add(loader);
                        }
                    }

                    // Load the Scatters manually, to support patching
                    if (node.HasNode("scatters"))
                    {
                        // Already patched scatters
                        List<PQSLandControl.LandClassScatter> patchedScatters = new List<PQSLandControl.LandClassScatter>();
                        if (_mod.scatters != null)
                            _mod.scatters.ToList().ForEach(s => scatters.Add(new LandClassScatterLoader(s)));

                        // Go through the nodes
                        foreach (ConfigNode scatterNode in node.GetNode("scatters").nodes)
                        {
                            // The Loader
                            LandClassScatterLoader loader = null;

                            // Are there existing Scatters?
                            if (scatters.Count > 0)
                            {
                                // Attempt to find a Scatter we can edit that we have not edited before
                                loader = scatters.Where(m => !patchedScatters.Contains(m.scatter) && (scatterNode.HasValue("name") ? m.scatter.scatterName == scatterNode.GetValue("name") : false))
                                                                 .FirstOrDefault();

                                // Load the Loader (lol)
                                if (loader != null)
                                {
                                    Parser.LoadObjectFromConfigurationNode(loader, scatterNode);
                                    if (loader.delete.value)
                                        scatters.Remove(loader);
                                    else
                                        patchedScatters.Add(loader.scatter);
                                }
                            }

                            // If we can't patch a Scatter, create a new one
                            if (loader == null)
                            {
                                loader = Parser.CreateObjectFromConfigNode(typeof(LandClassScatterLoader), scatterNode) as LandClassScatterLoader;
                            }

                            // Add the Loader to the List
                            scatters.Add(loader);
                        }
                    }

                    if (scatters.Count > 0)
                        _mod.scatters = scatters.Select(s => s.scatter).ToArray();
                    if (landClasses.Count > 0)
                        _mod.landClasses = landClasses.Select(c => c.landClass).ToArray();

                    // Assign each scatter amount with their corresponding scatter
                    foreach (PQSLandControl.LandClass landClass in _mod.landClasses)
                    {
                        foreach (PQSLandControl.LandClassScatterAmount amount in landClass.scatter)
                        {
                            int i = 0;
                            while (i < _mod.scatters.Length)
//.........这里部分代码省略.........
开发者ID:KillAshley,项目名称:Kopernicus,代码行数:101,代码来源:LandControl.cs

示例13: Exception

            // Parser apply event
            void IParserEventSubscriber.Apply(ConfigNode node)
            {
                // Get any existing material we might have on this scaled version
                Material material = scaledVersion.renderer.sharedMaterial;
                ConfigNode data = node.GetNode (materialNodeName);

                // Check for bad condition (no material, no new material)
                if (material == null && data == null)
                {
                    throw new Exception("Scaled version has no material information");
                }

                // Are we a planet or moon?
                if (type.value != BodyType.Star)
                {
                    // If we are not a star, we need a scaled space fader and a sphere collider
                    if (scaledVersion.GetComponent<ScaledSpaceFader> () == null)
                    {
                        ScaledSpaceFader fader = scaledVersion.AddComponent<ScaledSpaceFader> ();
                        fader.floatName = "_Opacity";
                        fader.celestialBody = owner;
                    }

                    // Add a sphere collider if we need one
                    if (scaledVersion.GetComponent<SphereCollider> () == null)
                    {
                        SphereCollider collider = scaledVersion.AddComponent<SphereCollider>();
                        collider.center = Vector3.zero;
                        collider.radius = 1000.0f;
                    }

                    // Generate new atmospheric body material
                    if (type.value == BodyType.Atmospheric)
                    {
                        ScaledPlanetRimAerialLoader newMaterial = null;
                        if (material != null)
                        {
                            newMaterial = new ScaledPlanetRimAerialLoader (material);
                            if(data != null)
                                Parser.LoadObjectFromConfigurationNode (newMaterial, data);
                        }
                        else
                        {
                            newMaterial = Parser.CreateObjectFromConfigNode<ScaledPlanetRimAerialLoader> (data);
                        }
                        newMaterial.name = Guid.NewGuid().ToString();
                        newMaterial.rimColorRamp.wrapMode = TextureWrapMode.Clamp;
                        newMaterial.rimColorRamp.mipMapBias = 0.0f;
                        scaledVersion.renderer.sharedMaterial = newMaterial;
                    }

                    // Generate new vacuum body material
                    else
                    {
                        ScaledPlanetSimpleLoader newMaterial = null;
                        if (material != null)
                        {
                            newMaterial = new ScaledPlanetSimpleLoader (material);
                            if(data != null)
                                Parser.LoadObjectFromConfigurationNode (newMaterial, data);
                        }
                        else
                        {
                            newMaterial = Parser.CreateObjectFromConfigNode<ScaledPlanetSimpleLoader> (data);
                        }
                        newMaterial.name = Guid.NewGuid().ToString();
                        scaledVersion.renderer.sharedMaterial = newMaterial;
                    }
                }

                // Otherwise we are a star
                else
                {
                    // Add the SunShaderController behavior
                    if(scaledVersion.GetComponent<SunShaderController>() == null)
                        scaledVersion.AddComponent<SunShaderController>();

                    // Add the ScaledSun behavior
                    // TODO - apparently there can only be one of these (or it destroys itself)
                    if(scaledVersion.GetComponent<ScaledSun>() == null)
                        scaledVersion.AddComponent<ScaledSun>();

                    // Add the Kopernicus star componenet
                    component = scaledVersion.AddComponent<StarComponent> ();

                    // Generate a new material for the star
                    EmissiveMultiRampSunspotsLoader newMaterial = null;
                    if(material != null)
                    {
                        newMaterial = new EmissiveMultiRampSunspotsLoader (material);
                        if(data != null)
                            Parser.LoadObjectFromConfigurationNode (newMaterial, data);
                    }
                    else
                    {
                        newMaterial = Parser.CreateObjectFromConfigNode<EmissiveMultiRampSunspotsLoader> (data);
                    }

                    newMaterial.name = Guid.NewGuid().ToString();
//.........这里部分代码省略.........
开发者ID:Teknoman117,项目名称:Kopernicus,代码行数:101,代码来源:ScaledVersion.cs

示例14: LandClassLoaderNoise

                void IParserEventSubscriber.Apply(ConfigNode node)
                {
                    // Load the LandClasses manually, to support patching
                    if (node.HasNode("LandClasses"))
                    {
                        // Already patched classes
                        List<PQSMod_HeightColorMapNoise.LandClass> patchedClasses = new List<PQSMod_HeightColorMapNoise.LandClass>();
                        if (_mod.landClasses != null)
                            _mod.landClasses.ToList().ForEach(c => landClasses.Add(new LandClassLoaderNoise(c)));

                        // Go through the nodes
                        foreach (ConfigNode lcNode in node.GetNode("LandClasses").nodes)
                        {
                            // The Loader
                            LandClassLoaderNoise loader = null;

                            // Are there existing LandClasses?
                            if (landClasses.Count > 0)
                            {
                                // Attempt to find a LandClass we can edit that we have not edited before
                                loader = landClasses.Where(m => !patchedClasses.Contains(m.landClassNoise) && ((lcNode.HasValue("name") ? m.landClassNoise.name == lcNode.GetValue("name") : false) || (lcNode.HasValue("index") ? landClasses.IndexOf(m).ToString() == lcNode.GetValue("index") : false)))
                                                                 .FirstOrDefault();

                                // Load the Loader (lol)
                                if (loader != null)
                                {
                                    Parser.LoadObjectFromConfigurationNode(loader, lcNode);
                                    if (loader.delete.value)
                                        landClasses.Remove(loader);
                                    else
                                        patchedClasses.Add(loader.landClassNoise);
                                }
                            }

                            // If we can't patch a LandClass, create a new one
                            if (loader == null)
                            {
                                loader = Parser.CreateObjectFromConfigNode(typeof(LandClassLoaderNoise), lcNode) as LandClassLoaderNoise;
                            }

                            // Add the Loader to the List
                            landClasses.Add(loader);
                        }
                    }
                }
开发者ID:KillAshley,项目名称:Kopernicus,代码行数:45,代码来源:HeightColorMapNoise.cs

示例15: SaveConfig

        /// <summary>Saves the settings to the configuration file.</summary>
        internal static void SaveConfig()
        {
            // KFGlobals.cfg
            System.IO.File.Delete(configFileName);

            // Sync debug state with debug options.
            if (!isDebugEnabled && debugIsWaterColliderVisible)
            {
                debugIsWaterColliderVisible = false;
            }

            var configFile = new ConfigNode();
            configFile.AddNode("KFGlobals");
            ConfigNode configNode = configFile.GetNode("KFGlobals");

            configNode.SetValue("isDustEnabled", string.Format("{0}", isDustEnabled), true);
            configNode.SetValue("isDustCameraEnabled", string.Format("{0}", isDustCameraEnabled), true);
            configNode.SetValue("isMarkerEnabled", string.Format("{0}", isMarkerEnabled), true);
            configNode.SetValue("isRepLightEnabled", string.Format("{0}", isRepLightEnabled), true);
            configNode.SetValue("dustAmount", string.Format("{0}", Mathf.Clamp(Extensions.RoundToNearestValue(dustAmount, 0.25f), 0f, 3f)), true);
            configNode.SetValue("suspensionIncrement", string.Format("{0}", Mathf.Clamp(Extensions.RoundToNearestValue(suspensionIncrement, 5f), 5f, 20f)), true);
            configNode.SetValue("isDebugEnabled", string.Format("{0}", isDebugEnabled), true);
            configNode.SetValue("debugIsWaterColliderVisible", string.Format("{0}", debugIsWaterColliderVisible), true);
            configNode.SetValue("writeToLogFile", writeToLogFile.ToString(), true);
            configNode.SetValue("logFile", logFile, true);

            configFile.Save(configFileName);

            KFLog.Log("Global Settings Saved.");
            LogConfigValues();
        }
开发者ID:Kerbas-ad-astra,项目名称:KF_plugin,代码行数:32,代码来源:KFPersistenceManager.cs


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