本文整理汇总了C#中System.ConfigNode.RemoveNodes方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.RemoveNodes方法的具体用法?C# ConfigNode.RemoveNodes怎么用?C# ConfigNode.RemoveNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.RemoveNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSave
public override void OnSave(ConfigNode node)
{
base.OnSave(node);
node.RemoveNodes("ScienceData");
foreach(ScienceData data in storedData) {
data.Save((ConfigNode)node.AddNode("ScienceData"));
}
}
示例2: GameSaveTrigger
//called on GameSave event, refresh all data from loaded vessels and save to .sfs
private void GameSaveTrigger(ConfigNode node)
{
//need to call save routines here
if (node.HasNode("VMSNode")) //note that we do not load data at this point, our data storage is static so we know what's in the save file is old, invalid data
{
node.RemoveNodes("VMSNode"); //should only ever be on VMSnode in a file, remove all nodes to error trap it
}
node.AddNode(VesselModuleStaticData.SaveRoutine());
}
示例3: OnSave
public static void OnSave(ConfigNode node, ImpactScienceData data)
{
ImpactMonitor.Log("Saving spectrometerr");
node.RemoveNodes("ScienceData"); //** Prevent duplicates
if (data != null)
{
ConfigNode storedDataNode = node.AddNode("ScienceData");
ImpactMonitor.Log("saving data");
data.SaveImpact(storedDataNode);
}
}
示例4: SanitizeNode
private void SanitizeNode(ConfigNode module, ConfigNode[] templates)
{
string name = module.GetValue("name");
if (module.HasNode("ScienceData"))
{
module.RemoveNodes("ScienceData");
}
if (name == "Log")
module.ClearValues();
ConfigNode template = templates.FirstOrDefault(t => t.GetValue("name") == name);
if (template == null) return;
ConfigNode.ValueList values = template.values;
foreach (ConfigNode.Value val in values)
{
module.SetValue(val.name, val.value);
}
foreach (ConfigNode node in template.GetNodes()) //This should account for nested nodes, like RealChutes' PARACHUTE node
{
if (module.HasNode(node.name))
{
foreach (ConfigNode.Value val in node.values)
module.GetNode(node.name).SetValue(val.name, val.value);
}
}
foreach (ConfigNode node in module.GetNodes("MODULE"))
SanitizeNode(node, templates);
/*
if (name.Contains("ModuleEngines"))
{
module.SetValue("staged", "False");
module.SetValue("flameout", "False");
module.SetValue("EngineIgnited", "False");
module.SetValue("engineShutdown", "False");
module.SetValue("currentThrottle", "0");
module.SetValue("manuallyOverridden", "False");
}
else if (name == "ModuleScienceExperiment")
{
module.SetValue("Deployed", "False");
module.SetValue("Inoperable", "False");
}
else if (name == "ModuleParachute")
{
module.SetValue("staged", "False");
module.SetValue("persistentState", "STOWED");
}
else if (name == "Log")
{
module.ClearValues();
}
if (module.HasNode("ScienceData"))
{
module.RemoveNodes("ScienceData");
}
*/
}
示例5: InsertNode
private static void InsertNode(ConfigNode newNode, ConfigNode subMod, int index)
{
string modName = subMod.name;
ConfigNode[] oldValues = newNode.GetNodes(modName);
if (index < oldValues.Length)
{
newNode.RemoveNodes(modName);
int i = 0;
for (; i < index; ++i)
newNode.AddNode(oldValues[i]);
newNode.AddNode(subMod);
for (; i < oldValues.Length; ++i)
newNode.AddNode(oldValues[i]);
}
else
newNode.AddNode(subMod);
}
示例6: OnSave
public override void OnSave(ConfigNode node)
{
node.RemoveNodes("ScienceData"); //** Prevent duplicates
foreach (ScienceData SCANData in storedData)
{
ConfigNode storedDataNode = node.AddNode("ScienceData");
SCANData.Save(storedDataNode);
}
if (RPMList.Count > 0)
{
ConfigNode RPMPersistence = new ConfigNode("SCANsatRPM");
foreach (RPMPersistence RPMMFD in RPMList)
{
ConfigNode RPMProp = new ConfigNode("Prop");
RPMProp.AddValue("Prop ID", RPMMFD.RPMID);
RPMProp.AddValue("Mode", RPMMFD.RPMMode);
RPMProp.AddValue("Color", RPMMFD.RPMColor);
RPMProp.AddValue("Zoom", RPMMFD.RPMZoom);
RPMProp.AddValue("Lines", RPMMFD.RPMLines);
RPMPersistence.AddNode(RPMProp);
}
node.AddNode(RPMPersistence);
}
}
示例7: Update
//.........这里部分代码省略.........
{
oldVsl.RemoveValue("groupNames");
}
oldVsl.AddValue("groupNames", SaveGroupNames(""));
errLine = "14";
//errLine = "15";
if (oldVsl.HasValue("groupVisibility"))
{
oldVsl.RemoveValue("groupVisibility");
}
oldVsl.AddValue("groupVisibility", SaveGroupVisibility(""));
errLine = "15";
//errLine = "16";
if (oldVsl.HasValue("groupVisibilityNames"))
{
errLine = "15b";
oldVsl.RemoveValue("groupVisibilityNames");
errLine = "15c";
}
errLine = "15d";
oldVsl.AddValue("groupVisibilityNames", SaveGroupVisibilityNames(""));
errLine = "16";
if (oldVsl.HasValue("DirectActionState"))
{
errLine = "16b";
oldVsl.RemoveValue("DirectActionState");
errLine = "16c";
}
errLine = "16d";
oldVsl.AddValue("DirectActionState", SaveDirectActionState(""));
oldVsl.RemoveNodes("PART");
foreach (Part p in AGXRoot.vessel.Parts)
{
errLine = "17";
List<AGXAction> thisPartsActions = new List<AGXAction>();
errLine = "18 ";
//print("part 18a" + p.ConstructID + " " + CurrentVesselActions);
thisPartsActions.AddRange(StaticData.CurrentVesselActions.FindAll(p2 => p2.ba.listParent.part == p));
errLine = "18a";
//errLine = "18";
if (thisPartsActions.Count > 0)
{
errLine = "18b";
ConfigNode partTemp = new ConfigNode("PART");
errLine = "19";
partTemp.AddValue("name", p.vessel.vesselName);
partTemp.AddValue("vesselID", p.vessel.id);
//partTemp.AddValue("relLocX", AGXRoot.vessel.rootPart.transform.InverseTransformPoint(p.transform.position).x);
//partTemp.AddValue("relLocY", AGXRoot.vessel.rootPart.transform.InverseTransformPoint(p.transform.position).y);
//partTemp.AddValue("relLocZ", AGXRoot.vessel.rootPart.transform.InverseTransformPoint(p.transform.position).z);
partTemp.AddValue("flightID", p.flightID.ToString());
errLine = "20";
foreach (AGXAction agxAct in thisPartsActions)
{
errLine = "21";
partTemp.AddNode(AGextScenario.SaveAGXActionVer2(agxAct));
}
errLine = "22";
oldVsl.AddNode(partTemp);
errLine = "23";
示例8: FlightSaveToFile
//.........这里部分代码省略.........
//}
//print("step2");
while (actionsToSave.Count > 0)
{
//print("step3");
//foreach (AGXAction agAct in actionsToSave)
//{
// print("FlightSaveWhile " + agAct.ba.name + " " + agAct.ba.listParent.part.ConstructID);
//}
//print("step4");
Vessel vslToSave = actionsToSave.First().ba.listParent.part.vessel;
if(loadedVessels.Contains(vslToSave))
{
ConfigNode thisVslNode = new ConfigNode(vslToSave.id.ToString());
if (AGXFlightNode.HasNode(vslToSave.id.ToString()))
{
thisVslNode = AGXFlightNode.GetNode(vslToSave.id.ToString());
thisVslNode.RemoveValue("name");
thisVslNode.AddValue("name", vslToSave.vesselName);
}
else
{
thisVslNode.AddValue("name", vslToSave.vesselName);
errLine = "13";
thisVslNode.AddValue("currentKeyset", "1");
errLine = "14";
thisVslNode.AddValue("groupNames", "");
errLine = "15";
thisVslNode.AddValue("groupVisibility", "");
errLine = "16";
thisVslNode.AddValue("groupVisibilityNames", "");
}
thisVslNode.RemoveNodes("PART");
foreach (Part p in vslToSave.parts)
{
List<AGXAction> thisPartsActions = new List<AGXAction>();
thisPartsActions.AddRange(actionsToSave.FindAll(p2 => p2.prt == p));
errLine = "18";
if (thisPartsActions.Count > 0)
{
ConfigNode partTemp = new ConfigNode("PART");
errLine = "19";
partTemp.AddValue("name", p.vessel.name);
partTemp.AddValue("vesselID", vslToSave.id.ToString());
partTemp.AddValue("relLocX", p.orgPos.x);
partTemp.AddValue("relLocY", p.orgPos.y);
partTemp.AddValue("relLocZ", p.orgPos.z);
errLine = "20";
foreach (AGXAction agxAct in thisPartsActions)
{
errLine = "21";
partTemp.AddNode(AGextScenario.SaveAGXActionVer2(agxAct));
}
errLine = "22";
thisVslNode.AddNode(partTemp);
errLine = "23";
}
}
if (AGXFlightNode.HasNode(vslToSave.id.ToString()))
{
AGXFlightNode.RemoveNode(vslToSave.id.ToString());
示例9: SavePartSnapshot
public static ConfigNode SavePartSnapshot(Part part)
{
// Seems fine with a null vessel in 0.23 if some empty lists are allocated below
ProtoPartSnapshot snapshot = new ProtoPartSnapshot(part, null);
ConfigNode node = new ConfigNode("CONTENT_PART");
snapshot.attachNodes = new List<AttachNodeSnapshot>();
snapshot.srfAttachNode = new AttachNodeSnapshot("attach,-1");
snapshot.symLinks = new List<ProtoPartSnapshot>();
snapshot.symLinkIdxs = new List<int>();
snapshot.Save(node);
node.AddValue("kas_total_mass", part.mass+part.GetResourceMass());
// Prune unimportant data
node.RemoveValues("parent");
node.RemoveValues("position");
node.RemoveValues("rotation");
node.RemoveValues("istg");
node.RemoveValues("dstg");
node.RemoveValues("sqor");
node.RemoveValues("sidx");
node.RemoveValues("attm");
node.RemoveValues("srfN");
node.RemoveValues("attN");
node.RemoveValues("connected");
node.RemoveValues("attached");
node.RemoveValues("flag");
node.RemoveNodes("ACTIONS");
// Remove modules that are not in prefab since they won't load anyway
var module_nodes = node.GetNodes("MODULE");
var prefab_modules = part.partInfo.partPrefab.GetComponents<PartModule>();
node.RemoveNodes("MODULE");
for (int i = 0; i < prefab_modules.Length && i < module_nodes.Length; i++)
{
var module = module_nodes[i];
var name = module.GetValue("name") ?? "";
node.AddNode(module);
if (name == "KASModuleContainer")
{
// Containers get to keep their contents
module.RemoveNodes("EVENTS");
}
else if (name.StartsWith("KASModule"))
{
// Prune the state of the KAS modules completely
module.ClearData();
module.AddValue("name", name);
continue;
}
module.RemoveNodes("ACTIONS");
}
return node;
}
示例10: SaveNodeData
//take data from VSM module Save routine and write to static data
public static void SaveNodeData(VesselModuleSave vsm, ConfigNode node)
{
ConfigNode modNode = new ConfigNode(vsm.IDType()); //make our mod node, name is IDType
if (VesselModuleConfigNodes.ContainsKey(vsm.IDType())) //do we already have an entry for this mod?
{
modNode = VesselModuleConfigNodes[vsm.IDType()]; //yes, refer to existing node
}
else
{
VesselModuleConfigNodes.Add(vsm.IDType(), modNode); //no, add mod to our mod list
}
if (modNode.HasNode(vsm.vessel.id.ToString())) //is this vessel already existant?
{
modNode.RemoveNodes(vsm.vessel.id.ToString()); //remove vessel if it exists, static node has old data in it
}
node.name = vsm.vessel.id.ToString();
modNode.AddNode(node); //add node to static data, this adds to VesselModuleConfigNodes via reference
}
示例11: OnSave
public override void OnSave(ConfigNode node)
{
string ErrLine = "1";
//Debug.Log("AGX Saving Module start");
try
{
node.RemoveNodes("ACTION");
//node.RemoveNodes("TOGGLE");
//node.RemoveNodes("HOLD");
ErrLine = "2";
List<AGXAction> actsToSave = new List<AGXAction>();
ErrLine = "2a";
actsToSave.AddRange(agxActionsThisPart);
ErrLine = "2b";
if (HighLogic.LoadedSceneIsEditor)
{
//Debug.Log("AGX Editor save called by partmodule!");
ErrLine = "2c";
foreach (AGXAction agActSD in StaticData.CurrentVesselActions.Where(act => act.ba.listParent.part == this.part))
{
if (!actsToSave.Contains(agActSD))
{
actsToSave.Add(agActSD);
}
}
}
else if (HighLogic.LoadedSceneIsFlight)
{
ErrLine = "2d";
foreach (AGXAction agActSD in StaticData.CurrentVesselActions.Where(act => act.ba.listParent.part == this.part))
{
if (!actsToSave.Contains(agActSD))
{
actsToSave.Add(agActSD);
}
}
//Debug.Log("AGX Partmodule Save action saved okay");
}
ErrLine = "3";
foreach (AGXAction agAct in actsToSave)
{
ErrLine = "4";
ConfigNode actionNode = new ConfigNode("ACTION");
ErrLine = "5";
if (agAct != null)
{
ErrLine = "5a";
actionNode = StaticData.SaveAGXActionVer2(agAct);
}
ErrLine = "6";
node.AddNode(actionNode);
ErrLine = "7";
}
//actions themselves are now saved
ErrLine = "7a";
if (HighLogic.LoadedSceneIsEditor)
{
if (AGXEditor.LoadFinished)
{
//node.RemoveNodes("TOGGLE"); //not using confignode to save this stuff
//node.RemoveNodes("HOLD");
//ErrLine = "7b";
//ConfigNode toggleStates = new ConfigNode("TOGGLE");
//ConfigNode holdStates = new ConfigNode("HOLD");
//ErrLine = "7c";
//for (int i = 1; i <= 250; i++)
//{
// ErrLine = "7ca";
// if (AGXEditor.IsGroupToggle[i])
// {
// ErrLine = "7cb";
// toggleStates.AddValue("toggle", i.ToString());
// }
// ErrLine = "7cc";
// if (AGXEditor.isDirectAction[i])
// {
// ErrLine = "7cd";
// holdStates.AddValue("hold", i.ToString());
// }
//}
//ErrLine = "7d";
//node.AddNode(toggleStates);
//node.AddNode(holdStates);
//toggleNode = toggleStates;
//holdNode = holdStates;
node.SetValue("groupNames", AGXEditor.SaveGroupNames(""), true);
ErrLine = "7e";
node.SetValue("groupVisibility", AGXEditor.SaveGroupVisibility(""), true);
ErrLine = "7f";
node.SetValue("groupVisibilityNames", AGXEditor.SaveGroupVisibilityNames(""), true);
ErrLine = "7g";
node.SetValue("DirectActionState", AGXEditor.SaveDirectActionState(""), true);
node.SetValue("hasData", "true", true);
//.........这里部分代码省略.........
示例12: SaveThisVessel
public void SaveThisVessel()
{
string errLine = "1";
try
{
if (vesselInstanceOK)
{
ConfigNode thisVslNode = new ConfigNode(flightID.ToString());
errLine = "2";
if (AGXFlight.AGXFlightNode.HasNode(flightID.ToString()))
{
errLine = "3";
thisVslNode = AGXFlight.AGXFlightNode.GetNode(thisVsl.rootPart.flightID.ToString());
errLine = "4";
AGXFlight.AGXFlightNode.RemoveNode(thisVsl.rootPart.flightID.ToString());
}
errLine = "5";
thisVslNode.RemoveNodes("PART");
errLine = "6";
foreach (Part p in thisVsl.Parts)
{
errLine = "7";
List<AGXAction> thisPartsActions = new List<AGXAction>();
errLine = "8";
thisPartsActions.AddRange(actionsList.FindAll(p2 => p2.ba.listParent.part == p));
errLine = "18";
if (thisPartsActions.Count > 0)
{
//print("acts count " + thisPartsActions.Count);
ConfigNode partTemp = new ConfigNode("PART");
errLine = "19";
partTemp.AddValue("name", p.partInfo.name);
partTemp.AddValue("vesselName", p.vessel.vesselName);
//partTemp.AddValue("relLocX", FlightGlobals.ActiveVessel.rootPart.transform.InverseTransformPoint(p.transform.position).x);
//partTemp.AddValue("relLocY", FlightGlobals.ActiveVessel.rootPart.transform.InverseTransformPoint(p.transform.position).y);
//partTemp.AddValue("relLocZ", FlightGlobals.ActiveVessel.rootPart.transform.InverseTransformPoint(p.transform.position).z);
partTemp.AddValue("flightID", p.flightID.ToString());
errLine = "20";
foreach (AGXAction agxAct in thisPartsActions)
{
//print("acts countb " + thisPartsActions.Count);
errLine = "21";
partTemp.AddNode(StaticData.SaveAGXActionVer2(agxAct));
}
errLine = "22";
thisVslNode.AddNode(partTemp);
errLine = "23";
}
errLine = "24";
}
errLine = "25";
if (AGXFlight.AGXFlightNode.HasNode(thisVsl.id.ToString()))
{
errLine = "26";
AGXFlight.AGXFlightNode.RemoveNode(thisVsl.id.ToString());
}
errLine = "27";
if (AGXFlight.AGXFlightNode.HasNode(thisVsl.rootPart.flightID.ToString()))
{
errLine = "28";
AGXFlight.AGXFlightNode.RemoveNode(thisVsl.rootPart.flightID.ToString());
}
errLine = "29";
//print("save node " + thisVsl);
AGXFlight.AGXFlightNode.AddNode(thisVslNode);
}
}
catch (Exception e)
{
Debug.Log("AGX OtherVslSaveNode Fail " + errLine + " " + e);
}
}
示例13: VesselOnRails
public void VesselOnRails(Vessel vsl)
{
print("Vessel on rails! " + vsl.name );
partOldVessel.RemoveAll(vsl2 => vsl2.pVsl == vsl);
List<AGXAction> UnloadVslActionsCheck = new List<AGXAction>();
UnloadVslActionsCheck.AddRange(AllVesselsActions.Where(agx => agx.ba.listParent.part.vessel == vsl));
//print("count check " + UnloadVslActionsCheck.Count + vsl.id.ToString());
//foreach (AGXAction agact in UnloadVslActionsCheck)
//{
// print("actionunload " + agact.ba.listParent.part.vessel.id.ToString() + " " + agact.ba.listParent.part.ConstructID);
//}
if (UnloadVslActionsCheck.Count > 0)
{
ConfigNode vslToUnload = new ConfigNode(vsl.id.ToString());
if(AGXFlightNode.HasNode(vsl.id.ToString()))
{
vslToUnload = AGXFlightNode.GetNode(vsl.id.ToString());
vslToUnload.RemoveNodes("PART");
AGXFlightNode.RemoveNode(vsl.id.ToString());
}
if (vsl == FlightGlobals.ActiveVessel)
{
if(vslToUnload.HasValue("name"))
{
vslToUnload.RemoveValue("name");
}
vslToUnload.AddValue("name",FlightGlobals.ActiveVessel.vesselName);
if (vslToUnload.HasValue("currentKeyset"))
{
vslToUnload.RemoveValue("currentKeyset");
}
vslToUnload.AddValue("currentKeyset", CurrentKeySet.ToString());
if (vslToUnload.HasValue("groupNames"))
{
vslToUnload.RemoveValue("groupNames");
}
vslToUnload.AddValue("groupNames", SaveGroupNames(""));
if (vslToUnload.HasValue("groupVisibility"))
{
vslToUnload.RemoveValue("groupVisibility");
}
vslToUnload.AddValue("groupVisibility", SaveGroupVisibility(""));
if (vslToUnload.HasValue("groupVisibilityNames"))
{
vslToUnload.RemoveValue("groupVisibilityNames");
}
vslToUnload.AddValue("groupVisibilityNames", SaveGroupVisibilityNames(""));
}
foreach (Part p in vsl.Parts)
{
List<AGXAction> thisPartsActions = new List<AGXAction>();
thisPartsActions.AddRange(UnloadVslActionsCheck.FindAll(p2 => p2.ba.listParent.part == p));
//errLine = "18";
if (thisPartsActions.Count > 0)
{
ConfigNode partTemp = new ConfigNode("PART");
//errLine = "19";
partTemp.AddValue("name", p.vessel.vesselName);
partTemp.AddValue("vesselID", p.vessel.id);
partTemp.AddValue("relLocX", p.orgPos.x);
partTemp.AddValue("relLocY", p.orgPos.y);
partTemp.AddValue("relLocZ", p.orgPos.z);
//errLine = "20";
foreach (AGXAction agxAct in thisPartsActions)
{
//errLine = "21";
partTemp.AddNode(AGextScenario.SaveAGXActionVer2(agxAct));
}
// errLine = "22";
vslToUnload.AddNode(partTemp);
//errLine = "23";
}
}
AGXFlightNode.AddNode(vslToUnload);
}
AllVesselsActions.RemoveAll(act2 => act2.ba.listParent.part.vessel == vsl);
loadedVessels.Remove(vsl); //remove vessel from loaded vessels list
}
示例14: OnSave
public override void OnSave(ConfigNode node)
{
base.OnSave(node);
ConfigNode efficiencyNode;
if (node.HasValue("reputationIndex"))
node.SetValue("reputationIndex", reputationIndex.ToString());
else
node.AddValue("reputationIndex", reputationIndex.ToString());
foreach (EfficiencyData data in efficiencyDataMap.Values)
{
efficiencyNode = new ConfigNode(kEfficiencyData);
data.Save(efficiencyNode);
node.AddNode(efficiencyNode);
}
node.RemoveNodes(kToolTip);
foreach (ConfigNode toolTipNode in toolTips.Values)
node.AddNode(toolTipNode);
}
示例15: OnSave
public override void OnSave(ConfigNode node)
{
node.RemoveNodes("ScienceData"); //** Prevent duplicates
foreach (ScienceData SCANData in storedData)
{
ConfigNode storedDataNode = node.AddNode("ScienceData");
SCANData.Save(storedDataNode);
}
}