本文整理汇总了C#中ConfigNode.TryGetNode方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.TryGetNode方法的具体用法?C# ConfigNode.TryGetNode怎么用?C# ConfigNode.TryGetNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.TryGetNode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ModelConfig
/// <summary>
/// Creates a ModelConfig from the given ConfigNode
/// </summary>
/// <param name="node">ConfigNode to get the values from</param>
public ModelConfig(ConfigNode node)
{
node.TryGetValue("name", ref _name);
node.TryGetValue("diameter", ref _diameter);
node.TryGetValue("count", ref _count);
node.TryGetValue("maxDiam", ref _maxDiam);
ConfigNode chute = new ConfigNode();
if (node.TryGetNode("MAIN", ref chute)) { _main = new ModelParameters(chute); }
if (node.TryGetNode("SECONDARY", ref chute)) { _secondary = new ModelParameters(chute); }
}
示例2: RealChuteSettings
/// <summary>
/// Loads the RealChute_Settings config to memory
/// </summary>
public RealChuteSettings()
{
ConfigNode node = new ConfigNode(), settings = new ConfigNode("REALCHUTE_SETTINGS");
Debug.Log("[RealChute]: Loading settings file.");
if (!System.IO.File.Exists(RCUtils.settingsURL))
{
Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing component. Creating new version.");
settings.AddValue("autoArm", autoArm);
settings.AddValue("jokeActivated", jokeActivated);
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
else
{
node = ConfigNode.Load(RCUtils.settingsURL);
node.TryGetNode("REALCHUTE_SETTINGS", ref settings);
bool missing = false;
if (!settings.TryGetValue("autoArm", ref _autoArm)) { missing = true; }
if (!settings.TryGetValue("jokeActivated", ref _jokeActivated)) { missing = true; }
if (missing)
{
Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing component. Fixing settings file.");
settings.ClearValues();
settings.AddValue("autoArm", autoArm);
settings.AddValue("jokeActivated", jokeActivated);
node.ClearData();
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
}
}
示例3: RealChuteSettings
/// <summary>
/// Loads the RealChute_Settings config to memory
/// </summary>
public RealChuteSettings()
{
ConfigNode node = new ConfigNode(), settings = new ConfigNode("REALCHUTE_SETTINGS");
Debug.Log("[RealChute]: Loading settings file.");
if (!File.Exists(RCUtils.settingsURL))
{
Debug.LogError("[RealChute]: RealChute_Settings.cfg is missing. Creating new.");
settings.AddValue("autoArm", this._autoArm);
settings.AddValue("jokeActivated", this._jokeActivated);
settings.AddValue("guiResizeUpdates", this._guiResizeUpdates);
settings.AddValue("mustBeEngineer", this._mustBeEngineer);
settings.AddValue("engineerLevel", this._engineerLevel);
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
else
{
node = ConfigNode.Load(RCUtils.settingsURL);
bool mustSave = false;
if (!node.TryGetNode("REALCHUTE_SETTINGS", ref settings)) { SaveSettings(); return; }
if (!settings.TryGetValue("autoArm", ref this._autoArm)) { mustSave = true; return; }
if (!settings.TryGetValue("jokeActivated", ref this._jokeActivated)) { mustSave = true; return; }
if (!settings.TryGetValue("guiResizeUpdates", ref this._guiResizeUpdates)) { mustSave = true; return; }
if (!settings.TryGetValue("mustBeEngineer", ref this._mustBeEngineer)) { mustSave = true; return; }
if (!settings.TryGetValue("engineerLevel", ref this._engineerLevel)) { mustSave = true; return; }
this._presets = settings.GetNodes("PRESET");
if (mustSave) { SaveSettings(); }
}
}
示例4: RealChuteSettings
/// <summary>
/// Loads the RealChute_Settings config to memory
/// </summary>
public RealChuteSettings()
{
ConfigNode node = new ConfigNode(), settings = new ConfigNode("REALCHUTE_SETTINGS");
Debug.Log("[RealChute]: Loading settings file.");
if (!File.Exists(RCUtils.settingsURL))
{
Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing. Creating new.");
settings.AddValue("autoArm", autoArm);
settings.AddValue("jokeActivated", jokeActivated);
settings.AddValue("hideIcon", hideIcon);
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
else
{
node = ConfigNode.Load(RCUtils.settingsURL);
if (!node.TryGetNode("REALCHUTE_SETTINGS", ref settings)) { goto missing; }
if (!settings.TryGetValue("autoArm", ref _autoArm)) { goto missing; }
if (!settings.TryGetValue("jokeActivated", ref _jokeActivated)) { goto missing; }
if (settings.TryGetValue("hideIcon", ref _hideIcon)) { goto missing; }
return;
missing:
{
Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing component. Fixing settings file.");
settings.ClearValues();
settings.AddValue("autoArm", autoArm);
settings.AddValue("jokeActivated", jokeActivated);
settings.AddValue("hideIcon", hideIcon);
node.ClearData();
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
}
}