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


C# ConfigNode.TryGetValue方法代码示例

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


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

示例1: Load

 public void Load(ConfigNode node)
 {
     node.TryGetValue("ullageHeightMin", ref ullageHeightMin);
     node.TryGetValue("ullageHeightMax", ref ullageHeightMax);
     node.TryGetValue("ullageRadialMin", ref ullageRadialMin);
     node.TryGetValue("ullageRadialMax", ref ullageRadialMax);
     node.TryGetValue("UT", ref UT);
 }
开发者ID:Felbourn,项目名称:ModularFuelSystem,代码行数:8,代码来源:UllageSimulator.cs

示例2: DefaultConfig

 public DefaultConfig(ConfigNode configNode)
 {
     configNode.TryGetValue("name", ref this.name);
     configNode.TryGetValue("description", ref this.description);
     Random random = new Random();
     foreach (ConfigNode bodyNode in configNode.GetNodes("KRES_BODY"))
     {
         if (KRESUtils.IsCelestialBody(bodyNode.GetValue("name")))
         {
             this.bodies.Add(new DefaultBody(bodyNode, random));
         }
     }
 }
开发者ID:CYBUTEK,项目名称:KRES,代码行数:13,代码来源:DefaultConfig.cs

示例3: DefaultResource

 public DefaultResource(ConfigNode configNode, Random random)
 {
     configNode.TryGetValue("name", ref this.name);
     configNode.TryGetValue("type", ref this.type);
     configNode.TryGetValue("density", ref this.density);
     configNode.TryGetValue("octaves", ref this.octaves);
     configNode.TryGetValue("persistence", ref this.persistence);
     configNode.TryGetValue("frequency", ref this.frequency);
     configNode.TryGetValue("minAltitude", ref this.minAltitude);
     configNode.TryGetValue("maxAltitude", ref this.maxAltitude);
     configNode.TryGetValue("biomes", ref this.biomes);
     configNode.TryGetValue("excludedBiomes", ref this.excludedBiomes);
     if (this.type == "ore") { this.seed = random.Next(999999999); }
 }
开发者ID:CYBUTEK,项目名称:KRES,代码行数:14,代码来源:DefaultResource.cs

示例4: Start

        public void Start()
        {
            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEM"))
                RSSSettings = node;

            if (RSSSettings != null)
            {
                RSSSettings.TryGetValue("dumpOrbits", ref dumpOrbits);
                RSSSettings.TryGetValue("useKeypressClip", ref useKeypressClip);
            }

            UpdateAtmospheres();
            GameEvents.onVesselSOIChanged.Add(OnVesselSOIChanged);
        }
开发者ID:newtalt,项目名称:RealSolarSystem,代码行数:14,代码来源:Watchdogs.cs

示例5: Load

 public void Load(ConfigNode node)
 {
     if (node != null)
     {
         node.TryGetValue("ullageHeightMin", ref ullageHeightMin);
         node.TryGetValue("ullageHeightMax", ref ullageHeightMax);
         node.TryGetValue("ullageRadialMin", ref ullageRadialMin);
         node.TryGetValue("ullageRadialMax", ref ullageRadialMax);
         node.TryGetValue("UT", ref UT);
     #if DEBUG
         string str = "Loaded from node. H,R: " + ullageHeightMin + "/" + ullageHeightMax + ", " + ullageRadialMin + "/" + ullageRadialMax + ". UT: " + UT;
         if (Planetarium.fetch)
             str += " with current UT " + Planetarium.GetUniversalTime();
         MonoBehaviour.print("*U* UllageSim load: " + str);
     #endif
     }
 }
开发者ID:qipa,项目名称:ModularFuelSystem,代码行数:17,代码来源:UllageSimulator.cs

示例6: ResourceItem

        public ResourceItem(ConfigNode data, string resource, string body, string type, System.Random random)
        {
            DefaultResource defaultResource = DefaultLibrary.GetDefault(MapGenerator.DefaultName).GetBody(body).GetResourceOfType(resource, type);
            this.resource = PartResourceLibrary.Instance.GetDefinition(data.GetValue("name"));
            this.type = KRESUtils.GetResourceType(type);
            this.map = null;
            if (!data.TryGetValue("actualDensity", ref actualDensity))
            {
                actualDensity = KRESUtils.Clamp01(defaultResource.Density * (0.97d + (random.NextDouble() * 0.06d)));
            }

            if (!data.TryGetValue("actualError", ref actualError))
            {
                actualError = (random.NextDouble() * 2d) - 1d;
                data.AddValue("actualError", actualError);
            }
        }
开发者ID:CYBUTEK,项目名称:KRES,代码行数:17,代码来源:ResourceItem.cs

示例7: DefaultBody

 public DefaultBody(ConfigNode configNode, Random random)
 {
     configNode.TryGetValue("name", ref this.name);
     foreach (ConfigNode resourceNode in configNode.GetNodes("KRES_RESOURCE"))
     {
         this.resources.Add(new DefaultResource(resourceNode, random));
     }
 }
开发者ID:CYBUTEK,项目名称:KRES,代码行数:8,代码来源:DefaultBody.cs

示例8: Load

        public void Load(ConfigNode node)
        {
            unlocked = false;

            node.TryGetValue("name", ref name);

            double cost = 0d;
            node.TryGetValue("cost", ref cost);

            node.TryGetValue("entryCost", ref entryCost);
            if(double.IsNaN(entryCost))
                entryCost = Math.Max(0d, cost * RFSettings.Instance.configEntryCostMultiplier);

            node.TryGetValue("sciEntryCost", ref sciEntryCost);
            if(double.IsNaN(sciEntryCost))
                sciEntryCost = Math.Max(0d, cost * RFSettings.Instance.configScienceCostMultiplier);

            node.TryGetValue("unlocked", ref unlocked);

            node.TryGetValue("techRequired", ref techRequired);

            if (node.HasNode("entryCostMultipliers"))
                LoadMultipliers(node.GetNode("entryCostMultipliers"));

            if (node.HasNode("entryCostSubtractors"))
                LoadSubtractors(node.GetNode("entryCostSubtractors"));

            node.TryGetValue("maxSubtraction", ref maxSubtraction);
        }
开发者ID:Kerbas-ad-astra,项目名称:ModularFuelSystem,代码行数:29,代码来源:EngineConfigUpgrade.cs

示例9: TLUpgrade

        public TLUpgrade(ConfigNode node, ModuleEngineConfigs mec)
        {
            techLevelEntryCost = 0d;
            techLevelSciEntryCost = 0d;

            if (node.HasValue("name"))
            {
                bool calc = true, sciCalc = true;
                string cfgName = node.GetValue("name");

                calc = !node.TryGetValue("entryCost", ref techLevelEntryCost);

                sciCalc = !node.TryGetValue("sciEntryCost", ref techLevelSciEntryCost);

                if (mec.part.partInfo != null)
                {
                    double configCost = 0d;
                    node.TryGetValue("cost", ref configCost);

                    if (calc)
                    {
                        // calculate from what we know
                        techLevelEntryCost += configCost * RFSettings.Instance.configEntryCostMultiplier;
                    }
                    if (sciCalc)
                    {
                        techLevelSciEntryCost += configCost * RFSettings.Instance.configScienceCostMultiplier;
                    }

                    techLevelEntryCost += mec.part.partInfo.entryCost;
                    techLevelSciEntryCost += mec.part.partInfo.entryCost * RFSettings.Instance.configScienceCostMultiplier;
                }
                techLevelEntryCost = Math.Max(0d, techLevelEntryCost * RFSettings.Instance.techLevelEntryCostFraction);
                techLevelSciEntryCost = Math.Max(0d, techLevelSciEntryCost * RFSettings.Instance.techLevelScienceEntryCostFraction);

                currentTL = mec.techLevel;

                Load(node); // override the values if we have the real values.

                name = Utilities.GetPartName(mec.part) + cfgName;
            }
        }
开发者ID:Kerbas-ad-astra,项目名称:ModularFuelSystem,代码行数:42,代码来源:TLUpgrade.cs

示例10: Load

 public void Load(ConfigNode node)
 {
     if (node.HasNode(configNodeName))
     {
         ConfigNode TSTStockPlanetOrderNode = new ConfigNode();
         node.TryGetNode(configNodeName, ref TSTStockPlanetOrderNode);
         string tmpPlanetOrderString = "";
         TSTStockPlanetOrderNode.TryGetValue("planets", ref tmpPlanetOrderString);
         string[] tmpPlanetOrder = tmpPlanetOrderString.Split(',');
         NHPlanetOrder = new string[tmpPlanetOrder.Length];
         if (tmpPlanetOrder.Length > 0)
         {
             for (int i = 0; i < tmpPlanetOrder.Length; i++)
             {
                 NHPlanetOrder[i] = tmpPlanetOrder[i];
             }
         }
     }
     Utilities.Log_Debug("TSTNHPlanetOrder load complete");
 }
开发者ID:Kerbas-ad-astra,项目名称:TarsierSpaceTechnology,代码行数:20,代码来源:TSTSettings.cs

示例11: TextureConfig

        /// <summary>
        /// Initiates all the texture and model nodes in this model config
        /// </summary>
        public TextureConfig(ConfigNode node)
        {
            node.TryGetValue("name", ref _name);

            this._cases = node.GetNodes("CASE_TEXTURE").Select(n => new CaseConfig(n)).ToDictionary(c => c.name, c => c);
            this._caseNames = this._cases.Keys.ToArray();
            this._types = this._cases.Values.SelectMany(c => c.types).Distinct()
                .ToDictionary(t => t, t => this._cases.Values.Where(c => c.types.Contains(t)).Select(c => c.name).ToArray());

            this._canopies = node.GetNodes("CANOPY_TEXTURE").Select(n => new CanopyConfig(n)).ToDictionary(c => c.name, c => c);
            this._canopyNames = this._canopies.Keys.ToArray();

            this._models = node.GetNodes("CANOPY_MODEL").Select(n => new ModelConfig(n)).ToDictionary(m => m.name, m => m);
            this._modelNames = this._models.Keys.ToArray();
            int max = this._models.Values.Select(m => m.parameters.Count).Max();
            for (int i = 1; i <= max; i++)
            {
                this._parameters.Add(i, this.models.Values.Where(m => m.parameters.Count >= i).Select(m => m.name).ToArray());
            }
            foreach (ModelConfig model in this._models.Values)
            {
                model.parameters.ForEach(p => this._transforms.Add(p.transformName, model));
            }
        }
开发者ID:pcwilcox,项目名称:RealChute,代码行数:27,代码来源:TextureConfig.cs

示例12: Load

        internal static AlarmInfo Load(ConfigNode node)
        {
            Guid vesselID = Utilities.GetNodeValue(node, "vesselID");
            string Name = "";
            node.TryGetValue("Name", ref Name);

            AlarmInfo info = new AlarmInfo(Name, vesselID);

            info.AlarmType = Utilities.GetNodeValue(node, "AlarmType", KACWrapper.KACAPI.AlarmTypeEnum.Raw);
            node.TryGetValue("Notes", ref info.Notes);
            node.TryGetValue("AlarmTime", ref info.AlarmTime);
            node.TryGetValue("AlarmMargin", ref info.AlarmMargin);
            node.TryGetValue("AlarmExecute", ref info.AlarmExecute);

            string frzkbllst = "";
            node.TryGetValue("FrzKerbals", ref frzkbllst);
            string thwkbllst = "";
            node.TryGetValue("ThwKerbals", ref thwkbllst);

            string[] frzStrings = frzkbllst.Split(',');
            if (frzStrings.Length > 0)
            {
                for (int i = 0; i < frzStrings.Length; i++)
                {
                    info.FrzKerbals.Add(frzStrings[i]);
                }
            }
            string[] thwStrings = thwkbllst.Split(',');
            if (thwStrings.Length > 0)
            {
                for (int i = 0; i < thwStrings.Length; i++)
                {
                    if (thwStrings[i].Length > 0)
                        info.ThwKerbals.Add(thwStrings[i]);
                }
            }
            return info;
        }
开发者ID:Kerbas-ad-astra,项目名称:DeepFreeze,代码行数:38,代码来源:DFAlarmInfo.cs

示例13: LoadScaledSpace

        private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, CelestialBody body, double origRadius)
        {
            #region ScaledSpace
            // Scaled space
            Transform scaledSpaceTransform = null;
            Transform atmo = null;
            guiMinor = "Scaled Space";
            //OnGui();
            if (ScaledSpace.Instance != null)
            {
                float SSTScale = 1.0f;
                node.TryGetValue("SSTScale", ref SSTScale);
                foreach (Transform t in ScaledSpace.Instance.scaledSpaceTransforms)
                {
                    if (t.name.Equals(node.name))
                    {
                        print("*RSS* Found scaledspace transform for " + t.name + ", scale " + t.localScale.x);
                        scaledSpaceTransform = t;
                        // replace
                        int replaceColor = 0;
                        string path = "";
                        if (node.HasValue("SSColor"))
                        {
                            replaceColor = 1;
                            path = node.GetValue("SSColor");
                        }
                        if (node.HasValue("SSColor32"))
                        {
                            replaceColor = 2;
                            path = node.GetValue("SSColor32");
                        }
                        if (replaceColor > 0)
                        {
                            guiExtra = "Color map";
                            Texture2D map = null;
                            bool local = Utils.LoadTexture(path, ref map, true, true, true);
                            if ((object)map != null)
                            {
                                Texture oldColor = t.gameObject.renderer.material.GetTexture("_MainTex");
                                if ((object)oldColor != null)
                                {
                                    foreach (Material m in Resources.FindObjectsOfTypeAll(typeof(Material)))
                                    {
                                        if (m.GetTexture("_MainTex") == oldColor)
                                            m.SetTexture("_MainTex", map);
                                    }
                                    DestroyImmediate(oldColor);
                                    oldColor = null;
                                    yield return null;
                                }
                            }
                        }
                        yield return null;
                        guiExtra = "";
                        if (node.HasValue("SSBump"))
                        {
                            guiExtra = "Normal Map";
                            path = node.GetValue("SSBump");
                            Texture2D map = null;
                            bool local = Utils.LoadTexture(path, ref map, loadInfo.compressNormals, true, true);
                            yield return null;
                            if ((object)map != null)
                            {
                                Texture oldBump = t.gameObject.renderer.material.GetTexture("_BumpMap");
                                if (oldBump != null)
                                {
                                    foreach (Material m in Resources.FindObjectsOfTypeAll(typeof(Material)))
                                    {
                                        if (m.GetTexture("_BumpMap") == oldBump)
                                            m.SetTexture("_BumpMap", map);
                                    }
                                    t.gameObject.renderer.material.SetTexture("_BumpMap", map); // in case one wasn't set.
                                    DestroyImmediate(oldBump);
                                    oldBump = null;
                                    yield return null;
                                }
                            }
                            yield return null;
                            guiExtra = "";
                            //OnGui();
                        }
                        /*if (t.gameObject.renderer.material.GetTexture("_rimColorRamp") != null)
                        {
                            try
                            {
                                System.IO.File.WriteAllBytes(KSPUtil.ApplicationRootPath + body.name + "Ramp.png", ((Texture2D)t.gameObject.renderer.material.GetTexture("_rimColorRamp")).EncodeToPNG());
                            }
                            catch (Exception e)
                            {
                                print("*RSS* Failed to get/write ramp for " + body.name + ", exception: " + e.Message);
                            }
                        }*/
                        guiExtra = "Ramp and Specularity";
                        yield return null;
                        if (node.HasValue("SSRampRef"))
                        {
                            //if (t.gameObject.renderer.material.GetTexture("_rimColorRamp") != null)
                            // for now try setting anyway.
                            Texture map = null;
                            map = GetRamp(node.GetValue("SSRampRef"));
//.........这里部分代码省略.........
开发者ID:tudela,项目名称:RealSolarSystem,代码行数:101,代码来源:RealSolarSystem.cs

示例14: RSSLoadInfo

        public RSSLoadInfo(ConfigNode RSSnode)
        {
            useEpoch = RSSnode.TryGetValue("Epoch", ref epoch);
            RSSnode.TryGetValue("wrap", ref doWrap);
            RSSnode.TryGetValue("compressNormals", ref compressNormals);
            RSSnode.TryGetValue("spheresOnly", ref spheresOnly);
            RSSnode.TryGetValue("orbitCalc", ref orbitCalc);
            RSSnode.TryGetValue("defaultAtmoScale", ref defaultAtmoScale);
            RSSnode.TryGetValue("SSAtmoScale", ref SSAtmoScale);

            node = new ConfigNode();
            RSSnode.CopyTo(node);
            // get spherical scaledspace mesh
            if (ScaledSpace.Instance != null)
            {
                //print("*RSS* Printing ScaledSpace Transforms");
                foreach (Transform t in ScaledSpace.Instance.scaledSpaceTransforms)
                {
                    /*print("***** TRANSFROM: " + t.name);
                    Utils.PrintTransformUp(t);
                    Utils.PrintTransformRecursive(t);*/
                    if (t.name.Equals("Jool"))
                        joolMesh = (MeshFilter)t.GetComponent(typeof(MeshFilter));
                }
                //print("*RSS* InverseScaleFactor = " + ScaledSpace.InverseScaleFactor);
            }
        }
开发者ID:tudela,项目名称:RealSolarSystem,代码行数:27,代码来源:RealSolarSystem.cs

示例15: LoadCB

        private IEnumerator<YieldInstruction> LoadCB(ConfigNode node, CelestialBody body)
        {
            bool updateMass = false;
            //OnGui();
            #region CBChanges
            print("Fixing CB " + node.name + " of radius " + body.Radius);
            guiMinor = "CelestialBody";
            //OnGui();
            double origRadius = body.Radius;
            double origAtmo = body.maxAtmosphereAltitude;

            #region CBMassRadius

            node.TryGetValue("bodyName", ref body.bodyName);
            node.TryGetValue("bodyDescription", ref body.bodyDescription);
            if (node.TryGetValue("Radius", ref body.Radius))
                updateMass = true;
            print("Radius ratio: " + body.Radius / origRadius);

            if (node.TryGetValue("Mass", ref body.Mass))
            {
                MassToOthers(body);

            }
            if (node.TryGetValue("GeeASL", ref body.GeeASL))
            {
                GeeASLToOthers(body);
                updateMass = false;
            }
            if (node.TryGetValue("gravParameter", ref body.gravParameter))
            {
                GravParamToOthers(body);
                updateMass = false;
            }
            #endregion

            #region CBAtmosphereTemperature
            node.TryGetValue("atmosphericAmbientColor", ref body.atmosphericAmbientColor);
            node.TryGetValue("atmosphere", ref body.atmosphere);
            node.TryGetValue("atmosphereScaleHeight", ref body.atmosphereScaleHeight);
            node.TryGetValue("atmosphereMultiplier", ref body.atmosphereMultiplier);
            node.TryGetValue("maxAtmosphereAltitude", ref body.maxAtmosphereAltitude);
            node.TryGetValue("staticPressureASL", ref body.staticPressureASL);
            node.TryGetValue("useLegacyAtmosphere", ref body.useLegacyAtmosphere);
            if (!body.useLegacyAtmosphere)
            {
                ConfigNode PCnode = node.GetNode("pressureCurve");
                if (PCnode != null)
                {
                    body.altitudeMultiplier = 1f;
                    body.pressureMultiplier = 1f;
                    AnimationCurve pressureCurve = Utils.LoadAnimationCurve(PCnode);
                    if (pressureCurve != null)
                        body.pressureCurve = pressureCurve;
                    else
                    {
                        body.useLegacyAtmosphere = true;
                        Debug.LogWarning("Unable to load pressureCurve data for " + body.name + ": Using legacy atmosphere");
                    }
                    print("*RSS* finished with " + body.GetName() + ".pressureCurve (" + body.pressureCurve.keys.Length.ToString() + " keys)");
                }
                else
                {
                    print("*RSS* useLegacyAtmosphere = False but pressureCurve not found!");
                }
            }
            if (node.HasNode("temperatureCurve"))
            {
                ConfigNode TCnode = node.GetNode("temperatureCurve");
                if (TCnode != null)
                {
                    AnimationCurve temperatureCurve = Utils.LoadAnimationCurve(TCnode);
                    if (temperatureCurve != null)
                    {
                        body.temperatureCurve = temperatureCurve;
                        // Following two lines corrects situations where planets without atmosphere's have these two fields zeroed out
                        // Maybe think about making these configurable in the planet's config node? yes? no? meh?
                        body.atmoshpereTemperatureMultiplier = 1f;
                        body.altitudeMultiplier = 1f;
                        print("*RSS* found and loaded temperatureCurve data for " + body.name);
                    }
                }
            }
            #endregion

            #region CBRotation
            node.TryGetValue("rotationPeriod", ref body.rotationPeriod);
            node.TryGetValue("tidallyLocked", ref body.tidallyLocked);
            node.TryGetValue("initialRotation", ref body.initialRotation);
            node.TryGetValue("inverseRotation", ref body.inverseRotation);
            #endregion

            if (updateMass)
                GeeASLToOthers(body);

            /*if (node.HasValue("axialTilt"))
            {
                if (!body.inverseRotation && double.TryParse(node.GetValue("axialTilt"), out dtmp))
                {
                    CBRotationFixer.CBRotations.Add(body.name, new CBRotation(body.name, dtmp, body.rotationPeriod, body.initialRotation));
//.........这里部分代码省略.........
开发者ID:tudela,项目名称:RealSolarSystem,代码行数:101,代码来源:RealSolarSystem.cs


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