本文整理汇总了C#中ConfigNode.GetNodes方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.GetNodes方法的具体用法?C# ConfigNode.GetNodes怎么用?C# ConfigNode.GetNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.GetNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: Load
public static Layout Load(string name, ConfigNode node)
{
try
{
var layout = new Layout(name);
foreach (var child in node.GetNodes())
{
IElement element = Element.Create(child.name);
if (element != null)
{
element.Load(child);
layout.AddElement(element);
}
else
{
Historian.Print("Failed to load layout element of type '{0}'.", child.name);
}
}
return layout;
}
catch
{
Historian.Print("Failed to load layout '{0}'.", name);
}
return Empty;
}
示例3: Configure
public void Configure(ConfigNode node)
{
ConfigNode[] pages = node.GetNodes("PAGE_DEFINITION");
if (pages != null && pages.Length > 0)
{
definitions = new PageDefinition[pages.Length];
for (int i = 0; i < pages.Length; ++i)
{
string variableName = pages[i].GetValue("variableName");
string range = pages[i].GetValue("range");
string page = pages[i].GetValue("page");
if (string.IsNullOrEmpty(variableName) || string.IsNullOrEmpty(range) || string.IsNullOrEmpty(page))
{
JUtil.LogErrorMessage(this, "Incorrect page definition for page {0}", i);
definitions = null;
if (string.IsNullOrEmpty(definitionIn))
{
// Make sure we aren't crashing later.
definitionIn = definitionOut;
}
return;
}
definitions[i] = new PageDefinition(variableName, range, page);
}
}
}
示例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: 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);
_parameters = node.GetNodes("CHUTE").Select(n => new ChuteParameters(n)).ToList();
}
示例7: Load
public void Load(ConfigNode node)
{
float sum = 0;
ConfigurationName = node.GetValue("tankLoadoutName");
ConfigNode[] nodes = node.GetNodes("Resource");
for (int i = 0; i < nodes.Length; ++i)
{
WingTankResource res = new WingTankResource(nodes[i]);
resources.Add(res.resource.name, res);
sum += res.ratio;
}
foreach (KeyValuePair<string, WingTankResource> kvp in resources)
{
kvp.Value.fraction = kvp.Value.ratio / sum;
}
}
示例8: TryParse
public static ContextMenuNode TryParse(ConfigNode node)
{
if (node != null)
{
var metrics = node
.GetNodes("METRIC")
.Where(i => !i.GetValue("name").EndsWith("Template"))
.Select(MetricNode.TryParse)
.Where(i => i != null)
.ToArray();
return new ContextMenuNode(metrics);
}
Log.Warning("Could not parse missing CONTEXT_MENU node");
return null;
}
示例9: Load
public void Load(ConfigNode node)
{
float ratioTotal = 0;
GUIName = node.GetValue("name");
ConfigNode[] nodes = node.GetNodes("Resource");
for (int i = 0; i < nodes.Length; ++i)
{
WingTankResource res = new WingTankResource(nodes[i]);
if (res.resource != null)
{
resources.Add(res.resource.name, res);
ratioTotal += res.ratio;
}
}
foreach (KeyValuePair<string, WingTankResource> kvp in resources)
kvp.Value.SetUnitsPerVolume(ratioTotal);
}
示例10: foreach
// Generates the system prefab from the configuration
void IParserEventSubscriber.PostApply(ConfigNode node)
{
// Dictionary of bodies generated
Dictionary<string, Body> bodies = new Dictionary<string, Body>();
// Load all of the bodies
foreach (ConfigNode bodyNode in node.GetNodes(bodyNodeName))
{
// Create a logger for this body
Logger bodyLogger = new Logger(bodyNode.GetValue("name") + ".Body");
bodyLogger.SetAsActive();
// Attempt to create the body
try
{
currentBody = new Body();
Parser.LoadObjectFromConfigurationNode(currentBody, bodyNode);
bodies.Add(currentBody.name, currentBody);
Logger.Default.Log("[Kopernicus]: Configuration.Loader: Loaded Body: " + currentBody.name);
}
catch (Exception e)
{
bodyLogger.LogException(e);
Logger.Default.Log("[Kopernicus]: Configuration.Loader: Failed to load Body: " + bodyNode.GetValue("name"));
}
// Restore default logger
bodyLogger.Flush ();
Logger.Default.SetAsActive ();
}
// Load all of the asteroids
foreach (ConfigNode asteroidNode in node.GetNodes(asteroidNodeName))
{
// Create a logger for this asteroid
Logger logger = new Logger(asteroidNode.GetValue("name") + ".Asteroid");
logger.SetAsActive();
// Attempt to create the Asteroid
try
{
Asteroid asteroid = Parser.CreateObjectFromConfigNode<Asteroid>(asteroidNode);
DiscoverableObjects.asteroids.Add(asteroid);
Logger.Default.Log("[Kopernicus]: Configuration.Loader: Loaded Asteroid: " + asteroid.name);
}
catch (Exception e)
{
logger.LogException(e);
Logger.Default.Log("[Kopernicus]: Configuration.Loader: Failed to load Asteroid: " + asteroidNode.GetValue("name"));
}
// Restore default logger
logger.Flush();
Logger.Default.SetAsActive();
}
// Glue all the orbits together in the defined pattern
foreach (KeyValuePair<string, Body> body in bodies)
{
// If this body is in orbit around another body
if(body.Value.orbit != null)
{
// Get the Body object for the reference body
Body parent = null;
if(!bodies.TryGetValue(body.Value.orbit.referenceBody, out parent))
{
throw new Exception("\"" + body.Value.orbit.referenceBody + "\" not found.");
}
// Setup the orbit of the body
parent.generatedBody.children.Add(body.Value.generatedBody);
body.Value.generatedBody.orbitDriver.referenceBody = parent.generatedBody.celestialBody;
body.Value.generatedBody.orbitDriver.orbit.referenceBody = parent.generatedBody.celestialBody;
}
// Parent the generated body to the PSystem
body.Value.generatedBody.transform.parent = systemPrefab.transform;
}
// Elect root body
systemPrefab.rootBody = bodies.First(p => p.Value.orbit == null).Value.generatedBody;
// Sort by distance from parent (discover how this effects local bodies)
RecursivelySortBodies (systemPrefab.rootBody);
// Fix doubled flightGlobals
List<int> numbers = new List<int>() { 0 };
int index = bodies.Sum(b => b.Value.generatedBody.flightGlobalsIndex);
PatchFGI(ref numbers, ref index, systemPrefab.rootBody);
// Main Menu bodies
if (randomMainMenuBodies.Any())
Templates.menuBody = randomMainMenuBodies[new System.Random().Next(0, randomMainMenuBodies.Count)];
}
示例11: OnLoad
public override void OnLoad(ConfigNode node)
{
base.OnLoad(node);
if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
{
foreach (ConfigNode n in node.GetNodes("EngineConfigUpgrade"))
{
EngineConfigUpgrade eCfg = null;
if (n.HasValue("name"))
{
string cfgName = n.GetValue("name");
if (configUpgrades.TryGetValue(cfgName, out eCfg))
eCfg.Load(n);
else
{
eCfg = new EngineConfigUpgrade(n);
configUpgrades[cfgName] = eCfg;
}
}
}
foreach (ConfigNode n in node.GetNodes("TLUpgrade"))
{
TLUpgrade tU = null;
if (n.HasValue("name"))
{
string tlName = n.GetValue("name");
if (techLevelUpgrades.TryGetValue(tlName, out tU))
tU.Load(n);
else
{
tU = new TLUpgrade(n);
techLevelUpgrades[tlName] = tU;
}
}
}
}
}
示例12: OnLoad
public override void OnLoad(ConfigNode node)
{
base.OnLoad(node);
if (node.HasNode("ScienceData"))
{
foreach (ConfigNode dataNode in node.GetNodes("ScienceData"))
{
ScienceData data = new ScienceData(dataNode);
scienceData.Add(data);
_DataAmount += data.dataAmount;
}
}
Events["reviewScience"].guiActive = scienceData.Count > 0;
}
示例13: buildConstruct
public static ShipConstruct buildConstruct(ConfigNode vessel)
{
ShipConstruct ship = new ShipConstruct();
ConfigNode[] partNodes = vessel.GetNodes("PART");
List<Part> parts = new List<Part>();
string[] partNameByIdx = new string[partNodes.Length];
Dictionary<string, Part> partByName = new Dictionary<string, Part>();
int part_idx = 0;
foreach (ConfigNode partNode in partNodes)
{
// get part name
string[] str_part = partNode.GetValue("part").Split('_');
partNameByIdx[part_idx] = partNode.GetValue("part");
// get part from loader
Part part = PartLoader.getPartInfoByName(str_part[0]).partPrefab;
partByName[partNode.GetValue("part")] = part;
// add info
part.orgPos = Utils.StringToVector3(partNode.GetValue("pos"));
part.attPos = Utils.StringToVector3(partNode.GetValue("attPos"));
part.attPos0 = Utils.StringToVector3(partNode.GetValue("attPos0"));
part.orgRot = Utils.StringToQuaternion(partNode.GetValue("rot"));
part.attRotation = Utils.StringToQuaternion(partNode.GetValue("attRot"));
part.attRotation0 = Utils.StringToQuaternion(partNode.GetValue("attRot0"));
part.mirrorVector = Utils.StringToVector3(partNode.GetValue("mir"));
string symMethod = partNode.GetValue("symMethod");
if (symMethod == "Radial")
{
part.symMethod = SymmetryMethod.Radial;
}
else if (symMethod == "Mirror")
{
part.symMethod = SymmetryMethod.Mirror;
}
part.inverseStage = int.Parse(partNode.GetValue("istg"));
part.defaultInverseStage = int.Parse(partNode.GetValue("istg"));
part.stageOffset = int.Parse(partNode.GetValue("sidx"));
//part.manualStageOffset = int.Parse(partNode.GetValue("sqor"));
part.separationIndex = int.Parse(partNode.GetValue("sepI"));
string attm = partNode.GetValue("attm");
if (attm == "0")
{
part.attachMode = AttachModes.STACK;
}
else if (attm == "1")
{
part.attachMode = AttachModes.SRF_ATTACH;
}
// modCost = 0
// modMass = 0
// modSize = (0.0, 0.0, 0.0)
// add to part list
parts.Add(part);
ship.Add(part);
++part_idx;
}
// add links
part_idx = 0;
foreach (Part part in parts)
{
string[] links = partNodes[part_idx].GetValues("link");
foreach (string link in links)
{
Part linkedPart = partByName[link];
if (linkedPart != null)
{
part.editorLinks.Add(linkedPart);
part.children.Add(linkedPart);
//AttachNode attN = new AttachNode(
//part.attachNodes.Add
//part.AddAttachNode(partNodes[part_idx]);
}
}
++part_idx;
}
ship.shipFacility = EditorFacility.VAB;
return ship;
}
示例14: OnLoad
public override void OnLoad(ConfigNode node)
{
// KSP Seems to want to make an instance of my partModule during initial load
if (vessel == null) return;
foreach (var hdNode in node.GetNodes("harddisk"))
{
var newDisk = new Harddisk(hdNode);
HardDisk = newDisk;
}
UnityEngine.Debug.Log("******************************* ON LOAD ");
InitCpu();
UnityEngine.Debug.Log("******************************* CPU Inited ");
if (cpu != null) cpu.OnLoad(node);
base.OnLoad(node);
}
示例15: OnLoad
public override void OnLoad(ConfigNode node) {
base.OnLoad(node);
foreach(ConfigNode dataNode in node.GetNodes("ScienceData")) {
AddData(new ScienceData(dataNode));
}
}