本文整理汇总了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");
}
示例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;
}
}