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


C# ConfigNode.HasValue方法代码示例

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


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

示例1: Awake

        public void Awake()
        {
            //            Debug.Log("********************************************************************" + HighLogic.LoadedScene + "*********************************************************************");
            settings = ConfigNode.Load("GameData/CustomerSatisfactionProgram/Config.cfg");

            if (settings.HasNode("SETTINGS")) {
                Debug.Log("Loading Settings");
                settings = settings.GetNode("SETTINGS");

                if (settings.HasValue("VERSION")) {
                    version = (settings.GetValue("VERSION"));
                }
                if (settings.HasValue("CAP")) {
                    cap = (int.Parse(settings.GetValue("CAP")));
                }
                if (settings.HasValue("CLEANUP")) {
                    cleanup = (int.Parse(settings.GetValue("CLEANUP")));
                    if (cleanup == 2) {
                        settings.AddValue("CLEANUP", 0);
                    }
                }
            }

            GameEvents.onKerbalRemoved.Add(OnKerbalRemoved);
            GameEvents.onKerbalAdded.Add(OnKerbalAdded);
            GameEvents.onKerbalTypeChange.Add(OnKerbalTypeChange);
            GameEvents.onGameSceneLoadRequested.Add(OnGameSceneLoadRequested);
        }
开发者ID:SpareToast,项目名称:CustomerSatisfactionProgram,代码行数:28,代码来源:CustomerManager.cs

示例2: KIS_Item

 /// <summary>Creates a new part from save.</summary>
 public KIS_Item(AvailablePart availablePart, ConfigNode itemNode, ModuleKISInventory inventory,
           float quantity = 1)
 {
     // Get part node
     this.availablePart = availablePart;
     partNode = new ConfigNode();
     itemNode.GetNode("PART").CopyTo(partNode);
     // init config
     this.InitConfig(availablePart, inventory, quantity);
     // Get mass
     if (itemNode.HasValue("resourceMass")) {
       resourceMass = float.Parse(itemNode.GetValue("resourceMass"));
     } else {
       resourceMass = availablePart.partPrefab.GetResourceMass();
     }
     if (itemNode.HasValue("contentMass")) {
       contentMass = float.Parse(itemNode.GetValue("contentMass"));
     }
     if (itemNode.HasValue("contentCost")) {
       contentCost = float.Parse(itemNode.GetValue("contentCost"));
     }
     if (itemNode.HasValue("inventoryName")) {
       inventoryName = itemNode.GetValue("inventoryName");
     }
 }
开发者ID:Kerbas-ad-astra,项目名称:KIS,代码行数:26,代码来源:KIS_Item.cs

示例3: Load

 public void Load(ConfigNode node)
 {
     if(node.HasValue("ConversionRate"))
         ConversionRate = float.Parse(node.GetValue("ConversionRate"));
     if(node.HasValue("ConsumptionRate"))
         ConsumptionRate = float.Parse(node.GetValue("ConsumptionRate"));
 }
开发者ID:kevin-ye,项目名称:hangar,代码行数:7,代码来源:HangarGenericInflatable.cs

示例4: SatSettingNode

        public SatSettingNode(ProtoPartModuleSnapshot s, Vessel v, ProtoPartSnapshot sn)
        {
            this.protoPartModule = s;
            this.vessel = v;
            this.snapshot = sn;
            isLoaded = false;

            ConfigNode n = new ConfigNode();
            protoPartModule.Save(n);

            if (n.HasValue("pointedAt"))
                this.pointedAt = new Target(n.GetValue("pointedAt"));
            else
                this.pointedAt = new Target();

            if (n.HasValue("dishRange"))
                this.dishRange = float.Parse(n.GetValue("dishRange"));
            else
                this.dishRange = 0;

            if (n.HasValue("antennaName"))
                this.antennaName = n.GetValue("antennaName");

            for (int i = 0; i < RTGlobals.targets.Count; i++)
            {
                if (pointedAt.Equals(RTGlobals.targets[i])) { selectedTarget = i; break; }
            }
        }
开发者ID:JDPKSP,项目名称:RemoteTechLegacy,代码行数:28,代码来源:SatSettings.cs

示例5: MappedVariable

        public MappedVariable(ConfigNode node)
        {
            if (!node.HasValue("mappedVariable") || !node.HasValue("mappedRange") || !node.HasValue("sourceVariable") || !node.HasValue("sourceRange"))
            {
                throw new ArgumentException("MappedVariable missing required values");
            }

            sourceVariable = node.GetValue("sourceVariable");
            string sourceRange = node.GetValue("sourceRange");
            string[] sources = sourceRange.Split(',');
            if (sources.Length != 2)
            {
                throw new ArgumentException("MappedVariable sourceRange does not have exactly two values");
            }

            if (!float.TryParse(sources[0].Trim(), out sourceMin))
            {
                sourceMinStr = sources[0].Trim();
            }
            if (!float.TryParse(sources[1].Trim(), out sourceMax))
            {
                sourceMaxStr = sources[1].Trim();
            }

            mappedVariable = node.GetValue("mappedVariable");
            mappedRange = ConfigNode.ParseVector2(node.GetValue("mappedRange"));
        }
开发者ID:Tahvohck,项目名称:RasterPropMonitor,代码行数:27,代码来源:MappedVariable.cs

示例6: OnLoad

        /// <summary>
        /// Loads any additional fields not loaded automatically.
        /// </summary>
        /// <param name="node">The config node for this module.</param>
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            if (node.HasValue("chanceToFailPerfect")) { chanceToFailPerfect = double.Parse(node.GetValue("chanceToFailPerfect")); }
            if (node.HasValue("chanceToFailTerrible")) { chanceToFailTerrible = double.Parse(node.GetValue("chanceToFailTerrible")); }
        }
开发者ID:panarchist,项目名称:KerbalMechanics,代码行数:11,代码来源:ModuleReliabilityInstrument.cs

示例7: Load

        /// <summary>
        /// Load the saved CancelCommand and find the element to cancel, based on the saved queue position
        /// </summary>
        /// <returns>true - loaded successfull</returns>
        public override bool Load(ConfigNode n, FlightComputer computer)
        {
            if(base.Load(n, computer))
            {
                if (n.HasValue("CancelCmdGuid"))
                {
                    this.CancelCmdGuid = new Guid(n.GetValue("CancelCmdGuid"));
                }

                // old way to cancel a command
                if (n.HasValue("queueIndex"))
                {
                    try
                    {
                        int queueIndex = int.Parse(n.GetValue("queueIndex"));
                        // try to find the command to cancel
                        this.CancelCmdGuid = computer.QueuedCommands.ElementAt(queueIndex).CmdGuid;
                    }
                    catch (Exception)
                    { }
                }

                // loaded successfull
                if (this.CancelCmdGuid != Guid.Empty)
                    return true;
            }
            return false;
        }
开发者ID:RemoteTechnologiesGroup,项目名称:RemoteTech,代码行数:32,代码来源:CancelCommand.cs

示例8: Load

        public override bool Load(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.Load(configNode);

            // Check on active contracts too
            checkOnActiveContract = configNode.HasValue("checkOnActiveContract") ? checkOnActiveContract : true;

            valid &= ConfigNodeUtil.ParseValue<List<string>>(configNode, "tech", x => techs = x, this, new List<string>());

            if (configNode.HasValue("part"))
            {
                List<AvailablePart> parts = new List<AvailablePart>();
                valid &= ConfigNodeUtil.ParseValue<List<AvailablePart>>(configNode, "part", x => parts = x, this);

                foreach (AvailablePart part in parts)
                {
                    techs.AddUnique(part.TechRequired);
                }
            }

            valid &= ConfigNodeUtil.AtLeastOne(configNode, new string[] { "tech", "part" }, this);

            return valid;
        }
开发者ID:linuxgurugamer,项目名称:ContractConfigurator,代码行数:25,代码来源:CanResearchTechRequirement.cs

示例9: Load

        public override bool Load(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.Load(configNode);

            valid &= ConfigNodeUtil.ParseValue<ExperimentalPart.UnlockCriteria>(configNode, "unlockCriteria", x => unlockCriteria = x, this, ExperimentalPart.UnlockCriteria.CONTRACT_ACCEPTANCE);
            if (unlockCriteria == ExperimentalPart.UnlockCriteria.PARAMETER_COMPLETION)
            {
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "unlockParameter", x => unlockParameter = x, this);
            }
            valid &= ConfigNodeUtil.ParseValue<ExperimentalPart.LockCriteria>(configNode, "lockCriteria", x => lockCriteria = x, this, ExperimentalPart.LockCriteria.CONTRACT_COMPLETION);
            if (lockCriteria == ExperimentalPart.LockCriteria.PARAMETER_COMPLETION)
            {
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "lockParameter", x => lockParameter = x, this);
            }

            valid &= ConfigNodeUtil.ParseValue<List<AvailablePart>>(configNode, "part", x => parts = x, this);

            if (configNode.HasValue("add"))
            {
                LoggingUtil.LogWarning(this, "The 'add' attribute of ExperimentalPartFactory is deprecated.  Use 'unlockCriteria' instead.");
                valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "add", x => unlockCriteria = x ? ExperimentalPart.UnlockCriteria.CONTRACT_ACCEPTANCE : ExperimentalPart.UnlockCriteria.DO_NOT_UNLOCK, this);
            }
            if (configNode.HasValue("remove"))
            {
                LoggingUtil.LogWarning(this, "The 'remove' attribute of ExperimentalPartFactory is deprecated.  Use 'lockCriteria' instead.");
                valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "remove", x => lockCriteria = x ? ExperimentalPart.LockCriteria.CONTRACT_COMPLETION : ExperimentalPart.LockCriteria.DO_NOT_LOCK, this);
            }

            return valid;
        }
开发者ID:linuxgurugamer,项目名称:ContractConfigurator,代码行数:31,代码来源:ExperimentalPartFactory.cs

示例10: MappedVariable

        public MappedVariable(ConfigNode node, RasterPropMonitorComputer rpmComp)
        {
            if (!node.HasValue("mappedVariable") || !node.HasValue("mappedRange") || !node.HasValue("sourceVariable") || !node.HasValue("sourceRange"))
            {
                throw new ArgumentException("MappedVariable missing required values");
            }

            string sourceVariableStr = node.GetValue("sourceVariable");
            string sourceRange = node.GetValue("sourceRange");
            string[] sources = sourceRange.Split(',');
            if (sources.Length != 2)
            {
                throw new ArgumentException("MappedVariable sourceRange does not have exactly two values");
            }

            sourceVariable = new VariableOrNumberRange(rpmComp, sourceVariableStr, sources[0], sources[1]);

            mappedVariable = node.GetValue("mappedVariable");
            string[] destinations = node.GetValue("mappedRange").Split(',');
            if (destinations.Length != 2)
            {
                throw new ArgumentException("MappedVariable mappedRange does not have exactly two values");
            }
            mappedExtent1 = rpmComp.InstantiateVariableOrNumber(destinations[0]);
            mappedExtent2 = rpmComp.InstantiateVariableOrNumber(destinations[1]);
        }
开发者ID:Kerbas-ad-astra,项目名称:RasterPropMonitor,代码行数:26,代码来源:MappedVariable.cs

示例11: OnLoad

        public override void OnLoad(ConfigNode node)
        {
            return;
            if (node.HasValue ("difficultySetting"))
                difficultySetting = int.Parse (node.GetValue ("difficultySetting"));

            if (node.HasValue("displayParachuteWarning"))
                bool.TryParse(node.GetValue("displayParachuteWarning"), out displayParachuteWarning);
        }
开发者ID:NathanKell,项目名称:DeadlyReentry,代码行数:9,代码来源:DeadlyReentryScenario.cs

示例12: OnLoad

 public void OnLoad(ConfigNode node)
 {
     if (node.HasValue("cancerTime"))
         Double.TryParse(node.GetValue("cancerTime"), out mCancerTime);
     if (node.HasValue("softDose"))
         Double.TryParse(node.GetValue("softDose"), out softDose);
     if (node.HasValue("hardDose"))
         Double.TryParse(node.GetValue("hardDose"), out hardDose);
 }
开发者ID:kjoenth,项目名称:kpu_mod,代码行数:9,代码来源:KerbalTracker.cs

示例13: OnLoad

 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasValue("chargeRate"))
         Single.TryParse(node.GetValue("chargeRate"), out chargeRate);
     if (node.HasValue("initChargeRate"))
         Single.TryParse(node.GetValue("initChargeRate"), out initChargeRate);
     else
         initChargeRate = chargeRate;
 }
开发者ID:kjoenth,项目名称:kpu_mod,代码行数:10,代码来源:ModuleKappaRaySolarPanel.cs

示例14: FromConfigNode

        public void FromConfigNode(ConfigNode node)
        {
            if (node.HasValue("Name"))
                Name = node.GetValue("Name");

            if (node.HasValue("LastUpdated"))
                double.TryParse(node.GetValue("LastUpdated"), out LastUpdated);

            if (node.HasValue("LastSated"))
                double.TryParse(node.GetValue("LastSated"), out LastSated);
        }
开发者ID:magico13,项目名称:TerminusLS,代码行数:11,代码来源:KerbalInfo.cs

示例15: Harddisk

        public Harddisk(ConfigNode node)
        {
            Capacity = 10000;

            if (node.HasValue("capacity")) Capacity = int.Parse(node.GetValue("capacity"));
            if (node.HasValue("volumeName")) Name = node.GetValue("volumeName");

            foreach (ConfigNode fileNode in node.GetNodes("file"))
            {
                Add(new ProgramFile(fileNode));
            }
        }
开发者ID:WazWaz,项目名称:KOS,代码行数:12,代码来源:Harddisk.cs


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