static bool Prefix(Verse.ModContentPack __instance) { DeepProfiler.Start("Loading all patches"); List <PatchOperation> lst = new List <PatchOperation>(); typeof(ModContentPack).GetField("patches", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance) .SetValue(__instance, lst); List <LoadableXmlAsset> list = DirectXmlLoader.XmlAssetsInModFolder(__instance, "Patches/").ToList <LoadableXmlAsset>(); for (int i = 0; i < list.Count; i++) { XmlElement documentElement = list[i].xmlDoc.DocumentElement; if (documentElement.Name != "Patch") { Log.Error(string.Format("Unexpected document element in patch XML; got {0}, expected 'Patch'", documentElement.Name), false); } else { foreach (XmlNode xmlNode in documentElement.ChildNodes) { if (xmlNode.NodeType == XmlNodeType.Element) { if (xmlNode.Name != "Operation") { Log.Error(string.Format("Unexpected element in patch XML; got {0}, expected 'Operation'", xmlNode.Name), false); } else { PatchOperation patchOperation = DirectXmlToObject.ObjectFromXml <PatchOperation>(xmlNode, false); patchOperation.sourceFile = list[i].FullFilePath; lst.Add(patchOperation); } } } } } DeepProfiler.End(); return(false); }
// // Constructors // public SaM_Mod(Verse.ModContentPack content) : base(content) { settings = this.GetSettings <SaM_ModSettings>(); }
public ModContentHolder(ModContentPack mod) { this.mod = mod; }
private static string GetActiveLanguageCoreModFolderPath() { ModContentPack modContentPack = LoadedModManager.RunningMods.FirstOrDefault((ModContentPack x) => x.IsCoreMod); return(GetLanguageFolderPath(LanguageDatabase.activeLanguage, modContentPack.RootDir)); }
public ModAssemblyHandler(ModContentPack mod) { this.mod = mod; }
public static IEnumerable <T> DefsToGoInDatabase <T>(ModContentPack mod) { return(mod.AllDefs.OfType <T>()); }
public string GetFullFolderPath(ModContentPack mod) { return(Path.GetFullPath(Path.Combine(Path.Combine(mod.RootDir, "Defs/"), relFolder))); }
public static IEnumerable <Pair <string, LoadedContentItem <T> > > LoadAllForMod(ModContentPack mod) { DeepProfiler.Start(string.Concat("Loading assets of type ", typeof(T), " for mod ", mod)); Dictionary <string, FileInfo> allFilesForMod = ModContentPack.GetAllFilesForMod(mod, GenFilePaths.ContentPath <T>(), IsAcceptableExtension); foreach (KeyValuePair <string, FileInfo> item in allFilesForMod) { LoadedContentItem <T> loadedContentItem = LoadItem((FilesystemFile)item.Value); if (loadedContentItem != null) { yield return(new Pair <string, LoadedContentItem <T> >(item.Key, loadedContentItem)); } } DeepProfiler.End(); }
public static List <Tuple <string, FileInfo> > GetAllFilesForModPreserveOrder(ModContentPack mod, string contentPath, Func <string, bool> validateExtension = null, List <string> foldersToLoadDebug = null) { List <string> list = foldersToLoadDebug ?? mod.foldersToLoadDescendingOrder; List <Tuple <string, FileInfo> > list2 = new List <Tuple <string, FileInfo> >(); for (int num = list.Count - 1; num >= 0; num--) { string text = list[num]; DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(text, contentPath)); if (directoryInfo.Exists) { FileInfo[] files = directoryInfo.GetFiles("*.*", SearchOption.AllDirectories); foreach (FileInfo fileInfo in files) { if (validateExtension == null || validateExtension(fileInfo.Extension)) { string item = fileInfo.FullName.Substring(text.Length + 1); list2.Add(new Tuple <string, FileInfo>(item, fileInfo)); } } } } HashSet <string> hashSet = new HashSet <string>(); for (int num2 = list2.Count - 1; num2 >= 0; num2--) { Tuple <string, FileInfo> tuple = list2[num2]; if (!hashSet.Contains(tuple.Item1)) { hashSet.Add(tuple.Item1); } else { list2.RemoveAt(num2); } } return(list2); }
public static void ParseAndProcessXML(XmlDocument xmlDoc, Dictionary <XmlNode, LoadableXmlAsset> assetlookup) { XmlNodeList childNodes = xmlDoc.DocumentElement.ChildNodes; List <XmlNode> list = new List <XmlNode>(); foreach (object item in childNodes) { list.Add(item as XmlNode); } DeepProfiler.Start("Loading asset nodes " + list.Count); try { for (int i = 0; i < list.Count; i++) { if (list[i].NodeType == XmlNodeType.Element) { LoadableXmlAsset value = null; DeepProfiler.Start("assetlookup.TryGetValue"); try { assetlookup.TryGetValue(list[i], out value); } finally { DeepProfiler.End(); } DeepProfiler.Start("XmlInheritance.TryRegister"); try { XmlInheritance.TryRegister(list[i], value?.mod); } finally { DeepProfiler.End(); } } } } finally { DeepProfiler.End(); } DeepProfiler.Start("XmlInheritance.Resolve()"); try { XmlInheritance.Resolve(); } finally { DeepProfiler.End(); } runningMods.FirstOrDefault(); DeepProfiler.Start("Loading defs for " + list.Count + " nodes"); try { foreach (XmlNode item2 in list) { LoadableXmlAsset loadableXmlAsset = assetlookup.TryGetValue(item2); Def def = DirectXmlLoader.DefFromNode(item2, loadableXmlAsset); if (def != null) { ModContentPack modContentPack = loadableXmlAsset?.mod; if (modContentPack != null) { modContentPack.AddDef(def, loadableXmlAsset.name); } else { patchedDefs.Add(def); } } } } finally { DeepProfiler.End(); } }
public Mod(ModContentPack content) { this.intContent = content; }
private static string <LoadGameFromSaveFileNow> m__0(ModContentPack mod) { return(mod.ToString()); }
public Mod(ModContentPack content) { intContent = content; }
private static string <InitNewGame> m__1(ModContentPack mod) { return(mod.ToString()); }
public ModAssetBundlesHandler(ModContentPack mod) { this.mod = mod; }