本文整理汇总了C#中System.ConfigNode.AddNode方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.AddNode方法的具体用法?C# ConfigNode.AddNode怎么用?C# ConfigNode.AddNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.AddNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsConfigNode
public ConfigNode AsConfigNode()
{
//save the source node, the variables, the teacher name, the student names, Started/Completed and the elapsed time
ConfigNode node = new ConfigNode("ACTIVE_COURSE");
node.AddValue("id", id);
node.AddValue("name", name);
node.AddValue("elapsedTime", elapsedTime);
node.AddValue("Started", Started);
node.AddValue("Completed", Completed);
node.AddValue("teacher", Teacher != null ? Teacher.name : "NA");
ConfigNode studentNode = new ConfigNode("STUDENTS");
foreach (ProtoCrewMember student in Students)
studentNode.AddValue("student", student.name);
node.AddNode("STUDENTS", studentNode);
ConfigNode variableNode = new ConfigNode("VARIABLES");
foreach (KeyValuePair<string, string> kvp in Variables)
{
variableNode.AddValue(kvp.Key, kvp.Value);
}
node.AddNode("VARIABLES", variableNode);
node.AddNode("SOURCE_NODE", sourceNode);
return node;
}
示例2: OnSave
public void OnSave(ConfigNode configNode)
{
configNode.AddValue("name", name);
configNode.AddValue("aspectRatio", aspectRatio);
foreach (CutSceneCamera cameraDefinition in cameras)
{
ConfigNode child = new ConfigNode(cameraDefinition.GetType().Name);
configNode.AddNode(child);
cameraDefinition.OnSave(child);
}
foreach (Actor actor in actors)
{
ConfigNode child = new ConfigNode(actor.GetType().Name);
configNode.AddNode(child);
actor.OnSave(child);
}
foreach (CutSceneAction action in actions)
{
ConfigNode child = new ConfigNode(action.GetType().Name);
configNode.AddNode(child);
action.OnSave(child);
}
}
示例3: OnSave
public override void OnSave(ConfigNode node)
{
try
{
if (!vessel.isEVA)
{
foreach (ProtoCrewMember crewmember in part.protoModuleCrew)
{
if (VanAllen.crew_rad_exposure.ContainsKey(crewmember.name))
{
double current_rad = VanAllen.crew_rad_exposure[crewmember.name];
ConfigNode rad_node = new ConfigNode("KERBAL_RADIATION_" + crewmember.name);
rad_node.AddValue("lifetimeDose", current_rad);
node.AddNode(rad_node);
}
}
}
else
{
if (VanAllen.crew_rad_exposure.ContainsKey(vessel.vesselName))
{
double current_rad = VanAllen.crew_rad_exposure[vessel.vesselName];
ConfigNode rad_node = new ConfigNode("KERBAL_RADIATION_" + vessel.vesselName);
rad_node.AddValue("lifetimeDose", current_rad);
node.AddNode(rad_node);
}
}
}
catch (Exception ex) { }
}
示例4: test
public static void test()
{
ConfigNode testNode = new ConfigNode("TESTNODE");
testNode.AddValue("fooName", "fooValue");
ConfigNode innerTestNode = new ConfigNode("INNERTESTNODE");
ConfigNode innerInnerTestNode = new ConfigNode("SUPERINNERTESTNODE");
innerInnerTestNode.AddValue("superFooName", "superFooValue");
innerTestNode.AddValue("innerFooName", "innerFooValue");
innerTestNode.AddNode(innerInnerTestNode);
testNode.AddNode(innerTestNode);
innerTestNode = new ConfigNode("INNERTESTNODE2");
innerTestNode.AddValue("innerFooName2", "innerFooValue2");
innerTestNode.AddValue("innerFooName2-2", "innerFooValue2-2");
testNode.AddNode(innerTestNode);
String data = testNode.ToString();
MonoBehaviour.print("raw node string: " + data);
ConfigNode reparsedNode = SSTUNodeUtils.parseConfigNode(data);
MonoBehaviour.print("new node: " + reparsedNode);
ConfigNode stockReparsedNode = ConfigNode.Parse(data);
MonoBehaviour.print("stockNewNode: " + stockReparsedNode.nodes[0]);
}
示例5: Save
public void Save(ConfigNode resourceNode)
{
resourceNode.AddNode(generatorNode);
foreach (var body in bodies)
{
var bodyNode = new ConfigNode("Body");
bodyNode.AddValue("Name", body.Key.name);
body.Value.Save(bodyNode);
resourceNode.AddNode(bodyNode);
}
}
示例6: Commit
/// <summary>
/// Called when the game is saved, commits inventory values into save game.
/// </summary>
/// <param name="root">ConfigNode passed from GameEvent</param>
public void Commit(ConfigNode root)
{
// Parts
ConfigNode N = new ConfigNode(this.GetType().FullName);
ConfigNode p = N.AddNode("PARTS");
foreach (string P in Parts.Inventory.Keys.Where(x => Parts.Inventory[x] != 0)) p.AddValue(P, Parts.Inventory[P]);
// Resources, load even if recover_resources = false
ConfigNode r = N.AddNode("RESOURCES");
foreach (string P in Resources.Inventory.Keys.Where(x => Resources.Get(x) != 0)) r.AddValue(P, Resources.Inventory[P]);
root.AddNode(N);
}
示例7: Save
public void Save (ConfigNode node)
{
var req = node.AddNode ("Required");
foreach (var res in required) {
var r = req.AddNode ("BuildResrouce");
res.Save (r);
}
var opt = node.AddNode ("Optional");
foreach (var res in optional) {
var r = opt.AddNode ("BuildResrouce");
res.Save (r);
}
}
示例8: SaveHallOfFame
/***************************************************************************************************************
* new persistence model
***************************************************************************************************************/
public static void SaveHallOfFame(List<LogbookEntry> logbook, ConfigNode node)
{
Log.Info("saving hall of fame (" + logbook.Count + " logbook entries)");
List<LogbookEntry> logbookCopy = new List<LogbookEntry>(logbook);
Stopwatch sw = new Stopwatch();
sw.Start();
try
{
foreach (LogbookEntry entry in logbookCopy)
{
ConfigNode entryNode = new ConfigNode(PERSISTENCE_NODE_ENTRY_NAME);
if (Log.IsLogable(Log.LEVEL.DETAIL)) Log.Detail("saving logbook entry " + entry);
entryNode.AddValue(Constants.CONFIGNODE_KEY_TIME, entry.UniversalTime.ToString());
entryNode.AddValue(Constants.CONFIGNODE_KEY_NAME, entry.Name);
entryNode.AddValue(Constants.CONFIGNODE_KEY_CODE, entry.Code);
entryNode.AddValue(Constants.CONFIGNODE_KEY_DATA, entry.Data);
node.AddNode(entryNode);
}
}
catch
{
Log.Error("exception while saving hall of fame detected; hall of fame may be corrupt");
}
finally
{
sw.Stop();
Log.Info("hall of fame saved in " + sw.ElapsedMilliseconds + "ms");
}
}
示例9: Save
/// <summary>
/// Save settings to the underlying storage
/// </summary>
public void Save()
{
ConfigNode node = AsConfigNode;
var clsNode = new ConfigNode (GetType ().Name);
clsNode.AddNode (node);
clsNode.Save (filePath);
}
示例10: DumpCurrentTreeToFile
static public void DumpCurrentTreeToFile( string sFileName, string sTreeName )
{
// only attempt to dump if the current game mode has a tech tree, and the tech tree is present
if ( HighLogic.CurrentGame != null && ( HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX )
&& AssetBase.RnDTechTree != null && AssetBase.RnDTechTree.GetTreeNodes() != null )
{
ConfigNode fileConfigNode = new ConfigNode();
ConfigNode treeConfigNode = new ConfigNode( "TECH_TREE" );
treeConfigNode.AddValue( "name", sTreeName );
AddAllTechNodesToTreeNode( treeConfigNode );
AddPlanetScienceValuesToTreeNode( treeConfigNode );
fileConfigNode.AddNode( treeConfigNode );
fileConfigNode.Save( KSPUtil.ApplicationRootPath.Replace( "\\", "/" ) + "GameData/ATC/" + sFileName,
"Config file representing the stock tech tree\r\n" +
"// WARNING: This file should not be edited directly, but rather should either be altered using ModuleManager commands within your own .cfg files OR\r\n" +
"// a new tree .cfg should be created which settings.cfg can then be set to point to." );
m_bHasTreeAlreadyBeenDumped = true;
}
}
示例11: CheckForDataNodes
private bool CheckForDataNodes(ConfigNode node)
{
foreach (string type in KRESUtils.types.Values)
{
if (!node.HasNode(type)) { goto Incomplete; }
ConfigNode t = node.GetNode(type);
foreach (CelestialBody body in KRESUtils.GetRelevantBodies(type))
{
if (!t.HasNode(body.bodyName)) { goto Incomplete; }
}
}
return true;
Incomplete:
{
print("no nodes");
node.ClearNodes();
foreach(string type in KRESUtils.types.Values)
{
ConfigNode t = node.AddNode(type);
foreach(CelestialBody body in KRESUtils.GetRelevantBodies(type))
{
ConfigNode b = t.AddNode(body.bodyName);
b.AddValue("currentError", 1d);
}
}
return false;
}
}
示例12: SaveCustomStressTemplates
public static void SaveCustomStressTemplates()
{
ConfigNode node = new ConfigNode("@FARAeroStress[default]:FOR[FerramAerospaceResearch]");
int i = 0;
node.AddNode(new ConfigNode("!FARPartStressTemplate,*"));
foreach (FARPartStressTemplate template in StressTemplates)
{
node.AddNode(CreateAeroStressConfigNode(template, i));
i++;
}
ConfigNode saveNode = new ConfigNode();
saveNode.AddNode(node);
saveNode.Save(KSPUtil.ApplicationRootPath.Replace("\\", "/") + "GameData/FerramAerospaceResearch/CustomFARAeroStress.cfg");
}
示例13: Save
/// <summary>
/// Save settings to the underlying storage
/// </summary>
public void Save ()
{
ConfigNode node = AsConfigNode;
var clsNode = new ConfigNode (nodeName);
clsNode.AddNode (node);
clsNode.Save (path);
}
示例14: OnSave
public override void OnSave(ConfigNode config)
{
var settings = new ConfigNode ("Settings");
config.AddNode (settings);
//XXX fill in with config node stuff to save settings to the
// settings config node
}
示例15: OnSave
protected override void OnSave(ConfigNode configNode)
{
base.OnSave(configNode);
ConfigNode child = new ConfigNode("CUTSCENE_DEFINITION");
cutSceneDefinition.OnSave(child);
configNode.AddNode(child);
}