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


C# ConfigNode.TryGetNode方法代码示例

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


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

示例1: 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

示例2: LoadKerbal

        private void LoadKerbal(ConfigNode crewNode)
        {
            if (crewNode == null)
            {
                DarkLog.Debug("crewNode is null!");
                return;
            }

            if (crewNode.GetValue("type") == "Tourist")
            {
                ConfigNode dmpNode = null;
                if (crewNode.TryGetNode("DarkMultiPlayer", ref dmpNode))
                {
                    string dmpOwner = null;
                    if (dmpNode.TryGetValue("touristOwner", ref dmpOwner))
                    {
                        if (dmpOwner != Settings.fetch.playerPublicKey)
                        {
                            DarkLog.Debug("Skipping load of tourist that belongs to another player");
                            return;
                        }
                    }
                }
            }

            ProtoCrewMember protoCrew = new ProtoCrewMember(HighLogic.CurrentGame.Mode, crewNode);
            if (protoCrew == null)
            {
                DarkLog.Debug("protoCrew is null!");
                return;
            }
            if (string.IsNullOrEmpty(protoCrew.name))
            {
                DarkLog.Debug("protoName is blank!");
                return;
            }
            if (!HighLogic.CurrentGame.CrewRoster.Exists(protoCrew.name))
            {
                AddCrewMemberToRoster(protoCrew);
                ConfigNode kerbalNode = new ConfigNode();
                protoCrew.Save(kerbalNode);
                byte[] kerbalBytes = ConfigNodeSerializer.fetch.Serialize(kerbalNode);
                if (kerbalBytes != null && kerbalBytes.Length != 0)
                {
                    serverKerbals[protoCrew.name] = Common.CalculateSHA256Hash(kerbalBytes);
                }
            }
            else
            {
                ConfigNode careerLogNode = crewNode.GetNode("CAREER_LOG");
                if (careerLogNode != null)
                {
                    //Insert wolf howling at the moon here
                    HighLogic.CurrentGame.CrewRoster[protoCrew.name].careerLog.Entries.Clear();
                    HighLogic.CurrentGame.CrewRoster[protoCrew.name].careerLog.Load(careerLogNode);
                }
                else
                {
                    DarkLog.Debug("Career log node for " + protoCrew.name + " is empty!");
                }

                ConfigNode flightLogNode = crewNode.GetNode("FLIGHT_LOG");
                if (flightLogNode != null)
                {
                    //And here. Someone "cannot into" lists and how to protect them.
                    HighLogic.CurrentGame.CrewRoster[protoCrew.name].flightLog.Entries.Clear();
                    HighLogic.CurrentGame.CrewRoster[protoCrew.name].flightLog.Load(flightLogNode);
                }

                HighLogic.CurrentGame.CrewRoster[protoCrew.name].courage = protoCrew.courage;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].experience = protoCrew.experience;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].experienceLevel = protoCrew.experienceLevel;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].experienceTrait = protoCrew.experienceTrait;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].gender = protoCrew.gender;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].gExperienced = protoCrew.gExperienced;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].hasToured = protoCrew.hasToured;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].isBadass = protoCrew.isBadass;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].KerbalRef = protoCrew.KerbalRef;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].outDueToG = protoCrew.outDueToG;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].rosterStatus = protoCrew.rosterStatus;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].seat = protoCrew.seat;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].seatIdx = protoCrew.seatIdx;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].stupidity = protoCrew.stupidity;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].trait = protoCrew.trait;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].type = protoCrew.type;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].UTaR = protoCrew.UTaR;
                HighLogic.CurrentGame.CrewRoster[protoCrew.name].veteran = protoCrew.veteran;
            }
        }
开发者ID:citruspress,项目名称:DarkMultiPlayer,代码行数:89,代码来源:VesselWorker.cs


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