public static void PreDefFromNode(LoadableXmlAsset loadingAsset) { if (!_shouldCount) { return; } _currentDefNum++; _asset = loadingAsset; }
static bool Prefix(LoadableXmlAsset xmlAsset, ModContentPack mod) { if (xmlAsset.xmlDoc == null) { return(false); } XmlNodeList childNodes = xmlAsset.xmlDoc.DocumentElement.ChildNodes; foreach (XmlNode child in childNodes) { if (child.NodeType == XmlNodeType.Element) { XmlInheritance.TryRegister(child, mod); } } return(false); }
public override void PostLoad() { //Override this if you want to name your Redefines in other manner. //Modifications to DefDatabase are not realible at this stage. LoadableXmlAsset tmp = (LoadableXmlAsset)currentFile.GetValue(null); if (latestFile != tmp) { redefineID = 0; latestFile = tmp; } else { redefineID++; } this.defName = latestFile.name.Replace(".xml", "") + "_" + redefineID; }
static bool Prefix(XmlDocument xmlDoc, Dictionary <XmlNode, LoadableXmlAsset> assetlookup) { XmlNodeList childNodes = xmlDoc.DocumentElement.ChildNodes; foreach (XmlNode n in childNodes) { if (n.NodeType == XmlNodeType.Element) { LoadableXmlAsset loadableXmlAsset = assetlookup.TryGetValue(n, null); XmlInheritance.TryRegister(n, (loadableXmlAsset == null) ? null : loadableXmlAsset.mod); } } XmlInheritance.Resolve(); DefPackage defPackage = new DefPackage("Unknown", string.Empty); ModContentPack modContentPack = LoadedModManager.RunningMods.FirstOrFallback <ModContentPack>(); modContentPack.AddDefPackage(defPackage); IEnumerator enumerator = xmlDoc.DocumentElement.ChildNodes.GetEnumerator(); try { while (enumerator.MoveNext()) { XmlNode xmlNode = (XmlNode)enumerator.Current; LoadableXmlAsset loadableXmlAsset2 = assetlookup.TryGetValue(xmlNode, null); DefPackage defPackage2 = (loadableXmlAsset2 == null) ? defPackage : loadableXmlAsset2.defPackage; Def def = DirectXmlLoader.DefFromNode(xmlNode, loadableXmlAsset2); if (def != null) { def.modContentPack = ((loadableXmlAsset2 == null) ? modContentPack : loadableXmlAsset2.mod); defPackage2.AddDef(def); } } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } return(false); }
protected override bool ApplyWorker(XmlDocument xml) { foreach (object firstObject in xml.SelectNodes(this.xpath)) { XmlNode first = firstObject as XmlNode; if (first != null) { LoadableXmlAsset loadableXmlAsset = Memory.getXmlAssets().TryGetValue(first, null); bool result = false; // loop from the rear end because this is FILO (first in, last out) // each time an object is found, it's appended right after xpath // this means the last found object will be first int length = followers.Count - 1; for (int i = length; i >= 0; --i) { foreach (object currentObject in xml.SelectNodes(this.followers[i])) { XmlNode current = currentObject as XmlNode; if (current != null) { result = true; first.ParentNode.InsertAfter(current, first); if (loadableXmlAsset != null) { // assign a new LoadableXmlAsset for the moved element // this is needed if the element is moved to elements from another mod (Core is a mod in this context) Memory.getXmlAssets()[current] = loadableXmlAsset; } } } } return(result); } } return(false); }
static bool Prefix(LoadableXmlAsset __instance, string name, string fullFolderPath, string contents) { __instance.name = name; __instance.fullFolderPath = fullFolderPath; try { using (XmlReader r = XmlReader.Create(new StringReader(contents), new XmlReaderSettings() { IgnoreComments = true, IgnoreWhitespace = true })) { __instance.xmlDoc = new XmlDocument(); __instance.xmlDoc.Load(r); } } catch (Exception ex) { Log.Warning(string.Concat(new object[] { "Exception reading ", name, " as XML: ", ex }), false); __instance.xmlDoc = null; } return(false); }
static void Prefix(LoadableXmlAsset __instance, string contents) { xmlAssetHashes.Add(new Pair <LoadableXmlAsset, int>(__instance, GenText.StableStringHash(contents))); }
public override void PostLoad() { //Override this if you want to name your Redefines in other manner. //Modifications to DefDatabase are not realible at this stage. LoadableXmlAsset tmp = (LoadableXmlAsset)currentFile.GetValue(null); if (latestFile != tmp) { redefineID = 0; latestFile = tmp; }else redefineID++; this.defName = latestFile.name.Replace(".xml", "") + "_" + redefineID; }
public static void setCurrentFileName(LoadableXmlAsset current) { Instance.currentFileName = current.name; Instance.currentPatch = -1; }
static void Postfix(LoadableXmlAsset loadingAsset) { DeepProfilerStart.mute = false; StartupImpact.modlist.Get(loadingAsset == null ? null : loadingAsset.mod).Stop("defs-1-create"); }
public void Deconstruct(out ModContentPack pack, out XmlNode node, out LoadableXmlAsset asset) { pack = ContentPack; node = Node; asset = SourceAsset; }
public DefXMLNode(ModContentPack contentPack, XmlNode node, LoadableXmlAsset sourceAsset) { ContentPack = contentPack; Node = node; SourceAsset = sourceAsset; }