public static void Setup_Search(Dictionary <int, T_Data> datas, string search, Action <Dictionary <int, T_Data>, global::AssetBundleController, CustomDataListLoader> action) { var dir = ""; var lastSlash = search.LastIndexOf("/", StringComparison.Ordinal); if (lastSlash != -1) { dir = search.Substring(0, lastSlash); search = search.Remove(0, lastSlash + 1); } var bundleDir = GlobalData.assetBundlePath + "/" + dir; var files = Directory.GetFiles(bundleDir, search, SearchOption.TopDirectoryOnly); Array.Sort(files); foreach (var bundlePath in files) { if (Path.GetExtension(bundlePath).Length == 0) { var bundleName = Path.GetFileNameWithoutExtension(bundlePath); if (dir.Length > 0) { bundleName = dir + "/" + bundleName; } var assetBundleController = new global::AssetBundleController(); assetBundleController.OpenFromFile(GlobalData.assetBundlePath, bundleName); Setup(datas, assetBundleController, action); assetBundleController.Close(false); } } var listDir = GlobalData.assetBundlePath + "/list/" + dir; if (!Directory.Exists(listDir)) { return; } foreach (var text3 in Directory.GetFiles(listDir, search + "_Mlist.txt")) { using (var streamReader = new StreamReader(new FileStream(text3, FileMode.Open))) { var assetBundleName = streamReader.ReadLine(); var contents = streamReader.ReadToEnd(); var tempFileName = Path.GetTempFileName(); File.WriteAllText(tempFileName, contents); var customDataListLoader = new CustomDataListLoader(); customDataListLoader.Load(tempFileName); File.Delete(tempFileName); var assetBundleController2 = new global::AssetBundleController(); assetBundleController2.OpenFromFile(GlobalData.assetBundlePath, assetBundleName); action(datas, assetBundleController2, customDataListLoader); assetBundleController2.Close(false); } } }
private static void SetupSearchPatch(ref object datas, ref string search, ref Action <object, AssetBundleController, CustomDataListLoader> ___action) { int num = searchValue.LastIndexOf("/"); var text = searchValue.Substring(0, num); if (!Directory.Exists(GlobalData.assetBundlePath + "/list/" + text)) { return; } foreach (var text3 in Directory.GetFiles(GlobalData.assetBundlePath + "/list/" + text, search + "_Mlist.txt")) { Logger.LogInfo("Load Mlist:" + text3); StreamReader streamReader = new StreamReader(new FileStream(text3, FileMode.Open)); string assetBundleName = streamReader.ReadLine(); string contents = streamReader.ReadToEnd(); string tempFileName = Path.GetTempFileName(); File.WriteAllText(tempFileName, contents); CustomDataListLoader customDataListLoader = new CustomDataListLoader(); customDataListLoader.Load(tempFileName); File.Delete(tempFileName); AssetBundleController assetBundleController2 = new AssetBundleController(); assetBundleController2.OpenFromFile(GlobalData.assetBundlePath, assetBundleName); ___action(datas, assetBundleController2, customDataListLoader); assetBundleController2.Close(false); } }
private static bool SetupPatch(ref AssetBundleController abc, ref Action <object, AssetBundleController, CustomDataListLoader> ___action, ref object datas) { string text = abc.directory + "/list/" + abc.assetBundleName + "_list.txt"; if (File.Exists(text)) { Logger.LogInfo("Load list:" + text); CustomDataListLoader customDataListLoader = new CustomDataListLoader(); customDataListLoader.Load(text); ___action(datas, abc, customDataListLoader); return(false); } return(true); }
private static bool SetupPrefix(object __instance, ref object datas, ref AssetBundleController abc) { string text = BepInEx.Utility.CombinePaths(MoreSlotID.ModFolder, "list", abc.assetBundleName, "_list.txt"); if (File.Exists(text)) { Console.WriteLine("Load list:" + text); CustomDataListLoader customDataListLoader = new CustomDataListLoader(); customDataListLoader.Load(text); var args = new Type[] { datas.GetType(), typeof(AssetBundleController), typeof(CustomDataListLoader) }; Traverse.Create(__instance).Field("action").Method("Invoke", args).GetValue(datas, abc, customDataListLoader); return(false); } return(true); }
private static void LoadMods(Dictionary <int, object> datas, ref string search, Action <Dictionary <int, object>, AssetBundleController, CustomDataListLoader> ___action) { var dir = ""; var filter = ""; var lastSlash = search.LastIndexOf("/", StringComparison.Ordinal); if (lastSlash != -1) { dir = search.Substring(0, lastSlash); filter = search.Remove(0, lastSlash + 1); } foreach (var folder in modFolders) { var abdataDir = Path.Combine(folder, "abdata"); var listDir = BepInEx.Utility.CombinePaths(abdataDir, "list", dir); if (Directory.Exists(listDir)) { foreach (var listPath in Directory.GetFiles(listDir, filter + "_Mlist.txt")) { using (var fileStream = new FileStream(listPath, FileMode.Open)) using (var streamReader = new StreamReader(fileStream)) { var assetBundleName = streamReader.ReadLine(); var listLoader = new CustomDataListLoader(); Traverse.Create(listLoader).Method("Load", new[] { typeof(TextReader) }).GetValue(streamReader); var abc = new AssetBundleController(); abc.OpenFromFile(Path.Combine(folder, "abdata"), assetBundleName); var count = datas.Count; ___action(datas, abc, listLoader); for (int i = count; i < datas.Count; i++) { var prefabData = (ItemDataBase)datas.Values.ElementAt(i); prefabData.assetbundleDir = abdataDir; } abc.Close(); } } } } }
public static void Setup(Dictionary <int, T_Data> datas, global::AssetBundleController abc, Action <Dictionary <int, T_Data>, global::AssetBundleController, CustomDataListLoader> action) { var bundleName = Path.GetFileNameWithoutExtension(abc.assetBundleName); var listPath = abc.directory + "/list/" + abc.assetBundleName + "_list.txt"; if (File.Exists(listPath)) { var customDataListLoader = new CustomDataListLoader(); customDataListLoader.Load(listPath); action(datas, abc, customDataListLoader); return; } var listAsset = abc.LoadAsset <TextAsset>(bundleName + "_list"); if (listAsset) { var customDataListLoader2 = new CustomDataListLoader(); customDataListLoader2.Load(listAsset); action(datas, abc, customDataListLoader2); } }
private static bool SetupSearchPrefix(object __instance, ref object datas, ref string search) { string text = string.Empty; int num = search.LastIndexOf("/"); if (num != -1) { text = search.Substring(0, num); search = search.Remove(0, num + 1); } string[] files = Directory.GetFiles(GlobalData.assetBundlePath + "/" + text, search, SearchOption.TopDirectoryOnly); Array.Sort(files); foreach (string path in files) { if (Path.GetExtension(path).Length == 0) { string text2 = Path.GetFileNameWithoutExtension(path); if (text.Length > 0) { text2 = text + "/" + text2; } AssetBundleController assetBundleController = new AssetBundleController(); assetBundleController.OpenFromFile(GlobalData.assetBundlePath, text2); var args = new Type[] { datas.GetType(), typeof(AssetBundleController) }; Traverse.Create(__instance).Method("Setup", args).GetValue(datas, assetBundleController); assetBundleController.Close(false); } } if (Directory.Exists(MoreSlotID.ModFolder)) { foreach (var modDir in Directory.GetDirectories(MoreSlotID.ModFolder, "*", SearchOption.TopDirectoryOnly)) { var abdataDir = Path.Combine(modDir, "abdata"); var listDir = BepInEx.Utility.CombinePaths(abdataDir, "list", text); if (Directory.Exists(listDir)) { foreach (string list in Directory.GetFiles(listDir, search + "_Mlist.txt")) { Console.WriteLine("Load Mlist: " + list); StreamReader streamReader = new StreamReader(new FileStream(list, FileMode.Open)); string assetBundleName = streamReader.ReadLine(); MoreSlotID.AssetList[assetBundleName] = abdataDir; string contents = streamReader.ReadToEnd(); string tempFileName = Path.GetTempFileName(); File.WriteAllText(tempFileName, contents); CustomDataListLoader customDataListLoader = new CustomDataListLoader(); customDataListLoader.Load(tempFileName); File.Delete(tempFileName); foreach (var data in Traverse.Create(customDataListLoader).Field("datas").GetValue <List <string[]> >()) { MoreSlotID.ThumbList[data[data.Length - 1]] = abdataDir; } AssetBundleController assetBundleController2 = new AssetBundleController(); assetBundleController2.OpenFromFile(abdataDir, assetBundleName); var args = new Type[] { datas.GetType(), typeof(AssetBundleController), typeof(CustomDataListLoader) }; Traverse.Create(__instance).Field("action").Method("Invoke", args).GetValue(datas, assetBundleController2, customDataListLoader); assetBundleController2.Close(false); } } } } return(false); }