本文整理汇总了C#中ConfigNode.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.TryGetValue方法的具体用法?C# ConfigNode.TryGetValue怎么用?C# ConfigNode.TryGetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.TryGetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
}
示例2: MaterialDefinition
/// <summary>
/// Creates a material definition from a config node
/// </summary>
/// <param name="node">Node to initiate the material from</param>
public MaterialDefinition(ConfigNode node)
{
node.TryGetValue("name", ref _name);
node.TryGetValue("description", ref _description);
node.TryGetValue("areaDensity", ref _areaDensity);
node.TryGetValue("dragCoefficient", ref _dragCoefficient);
}
示例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 (!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);
}
}
}
示例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.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(); }
}
}
示例5: 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);
_parameters = new List<ModelParameters>(node.GetNodes("PARAMETERS").Select(n => new ModelParameters(n)));
}
示例6: 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); }
}
示例7: ResourceInfo
public ResourceInfo(ConfigNode node)
{
node.TryGetValue("name", ref this.name);
resource = PartResourceLibrary.Instance.GetDefinition(this.Name);
node.TryGetValue("realName", ref this.realName);
node.TryGetValue("colour", ref this.colour);
}
示例8: TextureConfig
/// <summary>
/// Initiates all the texture and model nodes in this model config
/// </summary>
public TextureConfig(ConfigNode node)
{
node.TryGetValue("name", ref _name);
_cases = node.GetNodes("CASE_TEXTURE").Select(n => new CaseConfig(n)).ToDictionary(c => c, c => c.name);
_canopies = node.GetNodes("CANOPY_TEXTURE").Select(n => new CanopyConfig(n)).ToDictionary(c => c, c => c.name);
_models = node.GetNodes("CANOPY_MODEL").Select(n => new ModelConfig(n)).ToDictionary(m => m, m => m.name);
}
示例9: TextureConfig
/// <summary>
/// Initiates all the texture and model nodes in this model config
/// </summary>
public TextureConfig(ConfigNode node)
{
node.TryGetValue("name", ref _name);
foreach(ConfigNode cfg in node.nodes)
{
if (cfg.name == "CASE_TEXTURE")
{
CaseConfig parachuteCase = new CaseConfig(cfg);
_cases.Add(parachuteCase);
continue;
}
if (cfg.name == "CANOPY_TEXTURE")
{
CanopyConfig canopy = new CanopyConfig(cfg);
_canopies.Add(canopy);
continue;
}
if (cfg.name == "CANOPY_MODEL")
{
ModelConfig model = new ModelConfig(cfg);
_models.Add(model);
continue;
}
}
if (_cases.Count > 0) { _caseNames = _cases.Select(c => c.name).ToArray(); }
if (_canopies.Count > 0) { _canopyNames = _canopies.Select(c => c.name).ToArray(); }
if (_models.Count > 0) { _modelNames = _models.Select(m => m.name).ToArray(); }
}
示例10: MaterialDefinition
/// <summary>
/// Creates a material definition from a config node
/// </summary>
/// <param name="node">Node to initiate the material from</param>
public MaterialDefinition(ConfigNode node)
{
node.TryGetValue("name", ref this._name);
node.TryGetValue("description", ref this._description);
node.TryGetValue("areaDensity", ref this._areaDensity);
node.TryGetValue("dragCoefficient", ref this._dragCoefficient);
node.TryGetValue("areaCost", ref this._areaCost);
node.TryGetValue("maxTemp", ref this._maxTemp);
node.TryGetValue("specificHeat", ref this._specificHeat);
node.TryGetValue("emissivity", ref this._emissivity);
}
示例11: SizeNode
/// <summary>
/// Creates a new SizeNode from the given ConfigNode
/// </summary>
/// <param name="node">ConfigNode to create the object from</param>
public SizeNode(ConfigNode node)
{
node.TryGetValue("size", ref _size);
node.TryGetValue("sizeID", ref _sizeID);
node.TryGetValue("caseMass", ref _caseMass);
node.TryGetValue("topNode", ref _topNode);
node.TryGetValue("topNodeSize", ref _topNodeSize);
node.TryGetValue("bottomNode", ref _bottomNode);
node.TryGetValue("bottomNodeSize", ref _bottomNodeSize);
node.TryGetValue("cost", ref _cost);
}
示例12: DataBody
public DataBody(ConfigNode body, string type)
{
this.name = body.name;
this.type = type;
if (!body.TryGetValue("currentError", ref currentError))
{
currentError = 1d;
body.AddValue("currentError", currentError.ToString("0.00000"));
}
}
示例13: Load
internal static VesselInfo Load(ConfigNode node)
{
string vesselName = "Unknown";
node.TryGetValue("vesselName", ref vesselName);
double lastUpdate = 0f;
node.TryGetValue("lastUpdate", ref lastUpdate);
//string vesselName = Utilities.GetNodeValue(node, "vesselName", "Unknown");
//double lastUpdate = Utilities.GetNodeValue(node, "lastUpdate", 0.0);
VesselInfo info = new VesselInfo(vesselName, lastUpdate);
node.TryGetValue("numSeats", ref info.numSeats);
node.TryGetValue("numCrew", ref info.numCrew);
node.TryGetValue("numOccupiedParts", ref info.numOccupiedParts);
node.TryGetValue("numFrznCrew", ref info.numFrznCrew);
node.TryGetValue("hibernating", ref info.hibernating);
node.TryGetValue("hasextDoor", ref info.hasextDoor);
node.TryGetValue("hasextPod", ref info.hasextPod);
node.TryGetValue("storedEC", ref info.storedEC);
node.TryGetValue("predictedECOut", ref info.predictedECOut);
info.vesselType = Utilities.GetNodeValue(node, "vesselType", VesselType.Unknown);
return info;
}
示例14: Preset
/// <summary>
/// Creates a new Preset from the given ConfigNode
/// </summary>
/// <param name="node">ConfigNode to create the object from</param>
public Preset(ConfigNode node)
{
node.TryGetValue("name", ref _name);
node.TryGetValue("description", ref _description);
node.TryGetValue("textureLibrary", ref _textureLibrary);
node.TryGetValue("sizeID", ref _sizeID);
node.TryGetValue("cutSpeed", ref _cutSpeed);
node.TryGetValue("timer", ref _timer);
node.TryGetValue("mustGoDown", ref _mustGoDown);
node.TryGetValue("deployOnGround", ref _deployOnGround);
node.TryGetValue("spares", ref _spares);
node.TryGetValue("caseName", ref _caseName);
node.TryGetValue("bodyName", ref _bodyName);
if (node.HasNode("MAIN")) { _main = new ChuteParameters(node.GetNode("MAIN")); }
if (node.HasNode("SECONDARY")) { _secondary = new ChuteParameters(node.GetNode("SECONDARY")); }
}
示例15: ChuteParameters
/// <summary>
/// Creates a new ChuteParameters from the ConfigNode
/// </summary>
/// <param name="node">ConfigNode to create the object from</param>
public ChuteParameters(ConfigNode node)
{
node.TryGetValue("material", ref _material);
node.TryGetValue("preDeployedDiameter", ref _preDeployedDiameter);
node.TryGetValue("deployedDiameter", ref _deployedDiameter);
node.TryGetValue("minIsPressure", ref _minIsPressure);
node.TryGetValue("minDeployment", ref _minDeployment);
node.TryGetValue("minPressure", ref _minPressure);
node.TryGetValue("deploymentAlt", ref _deploymentAlt);
node.TryGetValue("cutAlt", ref _cutAlt);
node.TryGetValue("preDeploymentSpeed", ref _preDeploymentSpeed);
node.TryGetValue("deploymentSpeed", ref _deploymentSpeed);
node.TryGetValue("chuteTexture", ref _chuteTexture);
node.TryGetValue("modelName", ref _modelName);
node.TryGetValue("type", ref _type);
node.TryGetValue("calcSelect", ref _calcSelect);
node.TryGetValue("getMass", ref _getMass);
node.TryGetValue("useDry", ref _useDry);
node.TryGetValue("mass", ref _mass);
node.TryGetValue("landingSpeed", ref _landingSpeed);
node.TryGetValue("deceleration", ref _deceleration);
node.TryGetValue("refDepAlt", ref _refDepAlt);
node.TryGetValue("chuteCount", ref _chuteCount);
}