本文整理汇总了C#中System.ConfigNode.GetNodes方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.GetNodes方法的具体用法?C# ConfigNode.GetNodes怎么用?C# ConfigNode.GetNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.GetNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigNode
/*public override void OnSave(ConfigNode node)
{
Debug.Log("# OnSave " + node);
return;
base.OnSave(node);
Debug.Log("# Saving hatches");
ConfigNode hatchNode = new ConfigNode("Hatch");
foreach (Hatch h in Hatches)
{
hatchNode.AddValue("attachNodeId", h.AttachNodeId);
hatchNode.AddValue("position", h.Position.x + ", " + h.Position.y + ", " + h.Position.z);
hatchNode.AddValue("scale", h.Scale.x + ", " + h.Scale.y + ", " + h.Scale.z);
}
Debug.Log("# Adding hatch node " + hatchNode);
node.AddNode(hatchNode);
}*/
public override void OnLoad(ConfigNode node)
{
if (node.HasValue("CanIva"))
CanIva = bool.Parse(node.GetValue("CanIva"));
if (node.HasNode("Hatch"))
{
ConfigNode[] hatchNodes = node.GetNodes("Hatch");
foreach (var hn in hatchNodes)
{
Hatch h = ParseHatch(hn);
if (h != null)
{
Hatches.Add(h);
if (h.Collider != null)
InternalColliders.Add(h.Collider);
}
}
PersistenceManager.instance.AddHatches(part.name, Hatches);
}
Debug.Log("# Hatches loaded from config for part " + part.name + ": " + Hatches.Count);
if (node.HasNode("InternalCollider"))
{
ConfigNode[] colliderNodes = node.GetNodes("InternalCollider");
foreach (var cn in colliderNodes)
{
InternalCollider ic = ParseInternalCollider(cn);
if (ic != null)
InternalColliders.Add(ic);
}
PersistenceManager.instance.AddInternalColliders(part.name, InternalColliders);
Debug.Log("# Internal colliders loaded from config for part " + part.name + ": " + InternalColliders.Count);
}
}
示例2: SSTUEngineLayout
public SSTUEngineLayout(ConfigNode node)
{
name = node.GetStringValue("name");
mountSizeMult = node.GetFloatValue("mountSizeMult", mountSizeMult);
defaultUpperStageMount = node.GetStringValue("defaultUpperStageMount", defaultUpperStageMount);
defaultLowerStageMount = node.GetStringValue("defaultLowerStageMount", defaultLowerStageMount);
ConfigNode[] posNodes = node.GetNodes("POSITION");
int len = posNodes.Length;
for (int i = 0; i < len; i++)
{
positions.Add(new SSTUEnginePosition(posNodes[i]));
}
ConfigNode[] mountNodes = node.GetNodes("MOUNT");
len = mountNodes.Length;
List<SSTUEngineLayoutMountOption> mountOptionsList = new List<SSTUEngineLayoutMountOption>();
string mountName;
ModelDefinition md;
for (int i = 0; i < len; i++)
{
mountName = mountNodes[i].GetStringValue("name");
md = SSTUModelData.getModelDefinition(mountName);
if (md != null)
{
mountOptionsList.Add(new SSTUEngineLayoutMountOption(mountNodes[i]));
}
else
{
MonoBehaviour.print("ERROR: Could not locate mount model data for name: " + mountName + " -- please check your configs for errors.");
}
}
mountOptions = mountOptionsList.ToArray();
}
示例3: OnLoad
public override void OnLoad(ConfigNode node)
{
base.OnLoad(node);
ConfigNode[] efficiencyNodes = node.GetNodes(kEfficiencyData);
ConfigNode[] toolTipsShown = node.GetNodes(kToolTip);
string value = node.GetValue("reputationIndex");
if (string.IsNullOrEmpty(value) == false)
reputationIndex = int.Parse(value);
foreach (ConfigNode efficiencyNode in efficiencyNodes)
{
EfficiencyData efficiencyData = new EfficiencyData();
efficiencyData.Load(efficiencyNode);
efficiencyDataMap.Add(efficiencyData.Key, efficiencyData);
}
foreach (ConfigNode toolTipNode in toolTipsShown)
{
if (toolTipNode.HasValue("name") == false)
continue;
value = toolTipNode.GetValue("name");
if (toolTips.ContainsKey(value))
toolTips[value] = toolTipNode;
else
toolTips.Add(value, toolTipNode);
}
}
示例4: OnLoad
public override void OnLoad(ConfigNode node)
{
try
{
foreach (ConfigNode child in node.GetNodes("CONTRACT"))
{
ConfiguredContract contract = null;
try
{
contract = new ConfiguredContract();
Contract.Load(contract, child);
}
catch (Exception e)
{
LoggingUtil.LogWarning(this, "Ignored an exception while trying to load a pre-loaded contract:");
LoggingUtil.LogException(e);
}
if (contract != null && contract.contractType != null)
{
contract.preLoaded = true;
contracts.Add(contract);
}
}
}
catch (Exception e)
{
LoggingUtil.LogError(this, "Error loading ContractPreLoader from persistance file!");
LoggingUtil.LogException(e);
ExceptionLogWindow.DisplayFatalException(ExceptionLogWindow.ExceptionSituation.SCENARIO_MODULE_LOAD, e, "ContractPreLoader");
}
}
示例5: AddGrabModule
private void AddGrabModule(ConfigNode node)
{
foreach (ConfigNode grabNode in node.GetNodes("GRAB"))
{
// Check if the node has value
if (!grabNode.HasValue("stockPartName"))
{
KAS_Shared.DebugWarning("AddGrabModule(AddModule) Missing stockPartName node !");
continue;
}
// Add and Retrieve the module
string partName = grabNode.GetValue("stockPartName").Replace('_', '.');
AvailablePart aPart = PartLoader.getPartInfoByName(partName);
if (aPart == null)
{
KAS_Shared.DebugError("AddModule(AddModule) - " + partName + " not found in partloader");
continue;
}
// get or add grab module
KASModuleGrab grabModule = aPart.partPrefab.GetComponent<KASModuleGrab>();
if (grabModule)
{
KAS_Shared.DebugWarning("AddModule(AddModule) - KASModuleGrab already added to " + partName);
}
else
{
grabModule = aPart.partPrefab.AddModule("KASModuleGrab") as KASModuleGrab;
if (!grabModule)
{
KAS_Shared.DebugError("AddGrabModule(AddModule) Error when adding module !");
continue;
}
}
// Configure the module
if (grabNode.HasValue("evaPartPos")) grabModule.evaPartPos = KAS_Shared.ParseCfgVector3(grabNode.GetValue("evaPartPos"));
if (grabNode.HasValue("evaPartDir")) grabModule.evaPartDir = KAS_Shared.ParseCfgVector3(grabNode.GetValue("evaPartDir"));
if (grabNode.HasValue("customGroundPos")) grabModule.customGroundPos = bool.Parse(grabNode.GetValue("customGroundPos"));
if (grabNode.HasValue("dropPartPos")) grabModule.dropPartPos = KAS_Shared.ParseCfgVector3(grabNode.GetValue("dropPartPos"));
if (grabNode.HasValue("dropPartRot")) grabModule.dropPartRot = KAS_Shared.ParseCfgVector3(grabNode.GetValue("dropPartRot"));
if (grabNode.HasValue("physicJoint")) grabModule.physicJoint = bool.Parse(grabNode.GetValue("physicJoint"));
if (grabNode.HasValue("addPartMass")) grabModule.addPartMass = bool.Parse(grabNode.GetValue("addPartMass"));
if (grabNode.HasValue("storable")) grabModule.storable = bool.Parse(grabNode.GetValue("storable"));
if (grabNode.HasValue("storedSize")) grabModule.storedSize = int.Parse(grabNode.GetValue("storedSize"));
if (grabNode.HasValue("bayType")) grabModule.bayType = grabNode.GetValue("bayType").ToString();
if (grabNode.HasValue("bayNode")) grabModule.bayNode = grabNode.GetValue("bayNode").ToString();
if (grabNode.HasValue("bayRot")) grabModule.bayRot = KAS_Shared.ParseCfgVector3(grabNode.GetValue("bayRot"));
if (grabNode.HasValue("grabSndPath")) grabModule.grabSndPath = grabNode.GetValue("grabSndPath").ToString();
if (grabNode.HasValue("attachMaxDist")) grabModule.attachMaxDist = float.Parse(grabNode.GetValue("attachMaxDist"));
if (grabNode.HasValue("attachOnPart")) grabModule.attachOnPart = bool.Parse(grabNode.GetValue("attachOnPart"));
if (grabNode.HasValue("attachOnEva")) grabModule.attachOnEva = bool.Parse(grabNode.GetValue("attachOnEva"));
if (grabNode.HasValue("attachOnStatic")) grabModule.attachOnStatic = bool.Parse(grabNode.GetValue("attachOnStatic"));
if (grabNode.HasValue("attachSendMsgOnly")) grabModule.attachSendMsgOnly = bool.Parse(grabNode.GetValue("attachSendMsgOnly"));
if (grabNode.HasValue("attachPartSndPath")) grabModule.attachPartSndPath = grabNode.GetValue("attachPartSndPath").ToString();
if (grabNode.HasValue("attachStaticSndPath")) grabModule.attachStaticSndPath = grabNode.GetValue("attachStaticSndPath").ToString();
if (grabNode.HasValue("detachSndPath")) grabModule.detachSndPath = grabNode.GetValue("detachSndPath").ToString();
KAS_Shared.DebugLog("AddGrabModule(AddModule) Module successfully configured on " + partName);
}
}
示例6: loadFromNode
public ConverterRecipe loadFromNode(ConfigNode node)
{
ConfigNode[] inputNodes = node.GetNodes("RECIPEINPUT");
ConfigNode[] outputNodes = node.GetNodes("RECIPEOUTPUT");
int len = inputNodes.Length;
for (int i = 0; i < len; i++)
{
inputs.Add(new ConverterResourceEntry().loadFromNode(inputNodes[i]));
}
len = outputNodes.Length;
for (int i = 0; i < len; i++)
{
outputs.Add(new ConverterResourceEntry().loadFromNode(outputNodes[i]));
}
return this;
}
示例7: SelectVariable
internal SelectVariable(ConfigNode node, RasterPropMonitorComputer rpmComp)
{
name = node.GetValue("name");
foreach (ConfigNode sourceVarNode in node.GetNodes("VARIABLE_DEFINITION"))
{
bool reverseVal;
VariableOrNumberRange vonr = ProcessSourceNode(sourceVarNode, rpmComp, out reverseVal);
sourceVariables.Add(vonr);
reverse.Add(reverseVal);
VariableOrNumber val = rpmComp.InstantiateVariableOrNumber(sourceVarNode.GetValue("value"));
result.Add(val);
}
if (node.HasValue("defaultValue"))
{
VariableOrNumber val = rpmComp.InstantiateVariableOrNumber(node.GetValue("defaultValue"));
result.Add(val);
}
else
{
throw new Exception(string.Format("Select variable {0} is missing its defaultValue", name));
}
if (sourceVariables.Count == 0)
{
throw new ArgumentException("Did not find any VARIABLE_DEFINITION nodes in RPM_SELECT_VARIABLE", name);
}
}
示例8: OnLoad
public void OnLoad(ConfigNode configNode)
{
name = ConfigNodeUtil.ParseValue<string>(configNode, "name");
aspectRatio = ConfigNodeUtil.ParseValue<float>(configNode, "aspectRatio");
foreach (ConfigNode child in configNode.GetNodes())
{
Type nodeType = ConfigNodeUtil.ParseTypeValue(child.name);
if (nodeType.IsSubclassOf(typeof(CutSceneCamera)))
{
CutSceneCamera cameraDefinition = Activator.CreateInstance(nodeType) as CutSceneCamera;
cameraDefinition.OnLoad(child);
cameras.Add(cameraDefinition);
}
else if (nodeType.IsSubclassOf(typeof(Actor)))
{
Actor actor = Activator.CreateInstance(nodeType) as Actor;
actor.OnLoad(child);
actors.Add(actor);
}
else if (nodeType.IsSubclassOf(typeof(CutSceneAction)))
{
CutSceneAction action = Activator.CreateInstance(nodeType) as CutSceneAction;
action.cutSceneDefinition = this;
action.OnLoad(child);
actions.Add(action);
}
else
{
LoggingUtil.LogError(this, "Couldn't load CutSceneDefinition - unknown type '" + child.name + "'.");
}
}
}
示例9: Chapter
public Chapter(ConfigNode configNode)
{
this.Id = configNode.GetValue("id");
var instructor = configNode.GetNode("INSTRACTOR");
this.InstructorName = instructor.GetValue("name");
this.InstractorType = instructor.GetValue("type");
this.Title = configNode.GetValue("title");
this.Story = configNode.GetValue("story").Replace("\\n", "\n");
this.Difficulty = configNode.GetValue("difficulty").ToEnum<Contract.ContractPrestige>();
this.Science = Int32.Parse(configNode.GetValue("science"));
this.Reputation = Int32.Parse(configNode.GetValue("reputation"));
var funds = configNode.GetValue("funds").Split(',');
this.AdvanceFunds = Int32.Parse(funds[0]);
this.CompletionFunds = Int32.Parse(funds[1]);
this.FailureFunds = Int32.Parse(funds[2]);
this.ContractParameters = configNode.GetNodes("PARAM").Select(node => {
var paramName = node.GetValue("name");
var parameterType = ContractSystem.GetParameterType(paramName);
var contractParameter = (ContractParameter)Activator.CreateInstance(parameterType);
contractParameter.Load(node);
return contractParameter;
}).ToList();
}
示例10: ProcessNodeAsFloatCurve
public FloatCurve ProcessNodeAsFloatCurve(ConfigNode node)
{
FloatCurve resultCurve = new FloatCurve();
ConfigNode[] moduleNodeArray = node.GetNodes(nodeName);
debugMessage("ProcessNodeAsFloatCurve: moduleNodeArray.length " + moduleNodeArray.Length);
for (int k = 0; k < moduleNodeArray.Length; k++)
{
debugMessage("found node");
string[] valueArray = moduleNodeArray[k].GetValues(valueName);
debugMessage("found " + valueArray.Length + " values");
for (int l = 0; l < valueArray.Length; l++)
{
string[] splitString = valueArray[l].Split(' ');
try
{
Vector2 v2 = new Vector2(float.Parse(splitString[0]), float.Parse(splitString[1]));
resultCurve.Add(v2.x, v2.y, 0, 0);
}
catch
{
Debug.Log("Error parsing vector2");
}
}
}
return resultCurve;
}
示例11: CustomVariable
public CustomVariable(ConfigNode node)
{
name = node.GetValue("name");
foreach (ConfigNode sourceVarNode in node.GetNodes("SOURCE_VARIABLE")) {
SourceVariable sourceVar = new SourceVariable(sourceVarNode);
sourceVariables.Add(sourceVar);
}
if(sourceVariables.Count == 0) {
throw new ArgumentException("Did not find any SOURCE_VARIABLE nodes in RPM_CUSTOM_VARIABLE", name);
}
string oper = node.GetValue("operator");
if (oper == Operator.NONE.ToString()) {
op = Operator.NONE;
} else if (oper == Operator.AND.ToString()) {
op = Operator.AND;
} else if (oper == Operator.OR.ToString()) {
op = Operator.OR;
} else if (oper == Operator.XOR.ToString()) {
op = Operator.XOR;
} else {
throw new ArgumentException("Found an invalid operator type in RPM_CUSTOM_VARIABLE", oper);
}
}
示例12: BitmapFont
public BitmapFont(ConfigNode node, string nodeUrl)
{
id = node.GetValue("id");
name = node.GetValue("name");
displayName = node.GetValue("displayName");
size = int.Parse(node.GetValue("size"));
UnityEngine.Texture2D texture = Utils.LoadTexture("GameData/" + nodeUrl + ".pngmap", false);
characterMap = new Dictionary<char, BitmapChar>();
float h = 0;
foreach(ConfigNode n in node.GetNodes("ASP_BITMAP_CHAR"))
{
BitmapChar cMap = new BitmapChar(n, texture);
characterMap[cMap.character] = cMap;
// vh is -ve
if (cMap.vh < height) h = cMap.vh;
}
height = (int) Math.Abs(h);
UnityEngine.Object.Destroy(texture);
}
示例13: Load
public void Load(ConfigNode node)
{
ConfigNode[] converterNodes = node.GetNodes("KolonyConverter");
KolonyConverter converter;
if (converterNodes == null)
{
Log("converter nodes are null");
return;
}
//Clear the list of converters (if any)
Clear();
//Go through all the nodes, create a new converter, and tell it to load its data.
foreach (ConfigNode converterNode in converterNodes)
{
//Create the converter
converter = (KolonyConverter)this.part.AddModule("KolonyConverter");
//Load its data from the node
LoadFromNode(converter, converterNode);
//Remove its gui elements?
converter.ShowGUI(_showGUI);
//Add to the list
converters.Add(converter);
}
}
示例14: DefaultBody
public DefaultBody(ConfigNode configNode, Random random)
{
configNode.TryGetValue("name", ref this.name);
foreach (ConfigNode resourceNode in configNode.GetNodes("KRES_RESOURCE"))
{
this.resources.Add(new DefaultResource(resourceNode, random));
}
}
示例15: Load
public void Load(ConfigNode node)
{
foreach (ConfigNode pn in node.GetNodes("PROGRAM"))
{
Program prog = new Program();
prog.Load(pn);
putProgram(prog);
}
}