當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。