public static IEnumerable <T> GetAllInFolder(string folderPath) { if (!UnityData.IsInMainThread) { Log.Error("Tried to get all resources in a folder \"" + folderPath + "\" from a different thread. All resources must be loaded in the main thread.", false); } else { foreach (ModContentPack mod in LoadedModManager.RunningMods) { foreach (T item in mod.GetContentHolder <T>().GetAllUnderPath(folderPath)) { yield return(item); } } T[] items = null; if (typeof(T) == typeof(Texture2D)) { items = (T[])Resources.LoadAll <Texture2D>(GenFilePaths.ContentPath <Texture2D>() + folderPath); } if (typeof(T) == typeof(AudioClip)) { items = (T[])Resources.LoadAll <AudioClip>(GenFilePaths.ContentPath <AudioClip>() + folderPath); } if (items != null) { T[] array = items; for (int i = 0; i < array.Length; i++) { T item2 = array[i]; yield return(item2); } } } }
public static void LoadGameFromSaveFile(string fileName) { string str = GenText.ToCommaList(from mod in LoadedModManager.RunningMods select mod.ToString(), true); Log.Message("Loading game from file " + fileName + " with mods " + str); DeepProfiler.Start("Loading game from file " + fileName); Current.Game = new Game(); DeepProfiler.Start("InitLoading (read file)"); Scribe.loader.InitLoading(GenFilePaths.FilePathForSavedGame(fileName)); DeepProfiler.End(); ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, true); if (Scribe.EnterNode("game")) { Current.Game = new Game(); Current.Game.LoadGame(); PermadeathModeUtility.CheckUpdatePermadeathModeUniqueNameOnGameLoad(fileName); DeepProfiler.End(); } else { Log.Error("Could not find game XML node."); Scribe.ForceStop(); } }
public void ReloadAll() { foreach (Pair <string, LoadedContentItem <T> > item in ModContentLoader <T> .LoadAllForMod(mod)) { string first = item.First; first = first.Replace('\\', '/'); string text = GenFilePaths.ContentPath <T>(); if (first.StartsWith(text)) { first = first.Substring(text.Length); } if (first.EndsWith(Path.GetExtension(first))) { first = first.Substring(0, first.Length - Path.GetExtension(first).Length); } if (contentList.ContainsKey(first)) { Log.Warning("Tried to load duplicate " + typeof(T) + " with path: " + item.Second.internalFile + " and internal path: " + first); } else { contentList.Add(first, item.Second.contentItem); if (item.Second.extraDisposable != null) { extraDisposables.Add(item.Second.extraDisposable); } } } }
public static LoadedContentItem <T> LoadItem(VirtualFile file) { try { if (typeof(T) == typeof(string)) { return(new LoadedContentItem <T>(file, (T)(object)file.ReadAllText())); } if (typeof(T) == typeof(Texture2D)) { return(new LoadedContentItem <T>(file, (T)(object)LoadTexture(file))); } if (typeof(T) == typeof(AudioClip)) { if (Prefs.LogVerbose) { DeepProfiler.Start("Loading file " + file); } IDisposable extraDisposable = null; T val; try { string uri = GenFilePaths.SafeURIForUnityWWWFromPath(file.FullPath); using UnityWebRequest unityWebRequest = UnityWebRequestMultimedia.GetAudioClip(uri, GetAudioTypeFromURI(uri)); unityWebRequest.SendWebRequest(); while (!unityWebRequest.isDone) { Thread.Sleep(1); } if (unityWebRequest.error != null) { throw new InvalidOperationException(unityWebRequest.error); } val = (T)(object)DownloadHandlerAudioClip.GetContent(unityWebRequest); } finally { if (Prefs.LogVerbose) { DeepProfiler.End(); } } UnityEngine.Object @object = val as UnityEngine.Object; if (@object != null) { @object.name = Path.GetFileNameWithoutExtension(file.Name); } return(new LoadedContentItem <T>(file, val, extraDisposable)); } } catch (Exception ex) { Log.Error(string.Concat("Exception loading ", typeof(T), " from file.\nabsFilePath: ", file.FullPath, "\nException: ", ex.ToString())); } if (typeof(T) == typeof(Texture2D)) { return((LoadedContentItem <T>)(object) new LoadedContentItem <Texture2D>(file, BaseContent.BadTex)); } return(null); }
public static IEnumerable <LoadedContentItem <T> > LoadAllForMod(ModContentPack mod) { string contentDirPath = Path.Combine(mod.RootDir, GenFilePaths.ContentPath <T>()); DirectoryInfo contentDir = new DirectoryInfo(contentDirPath); if (contentDir.Exists) { DeepProfiler.Start(string.Concat(new object[] { "Loading assets of type ", typeof(T), " for mod ", mod })); FileInfo[] files = contentDir.GetFiles("*.*", SearchOption.AllDirectories); for (int i = 0; i < files.Length; i++) { FileInfo file = files[i]; if (ModContentLoader <T> .IsAcceptableExtension(file.Extension)) { LoadedContentItem <T> loadedItem = ModContentLoader <T> .LoadItem(file.FullName, contentDirPath); if (loadedItem != null) { yield return(loadedItem); } } } DeepProfiler.End(); } }
public static void CheckVersionAndLoadGame(string saveFileName) { PreLoadUtility.CheckVersionAndLoad(GenFilePaths.FilePathForSavedGame(saveFileName), ScribeMetaHeaderUtility.ScribeHeaderMode.Map, delegate { GameDataSaveLoader.LoadGame(saveFileName); }); }
public static IEnumerable <LoadedContentItem <T> > LoadAllForMod(ModContentPack mod) { string contentDirPath = Path.Combine(mod.RootDir, GenFilePaths.ContentPath <T>()); DirectoryInfo contentDir = new DirectoryInfo(contentDirPath); if (contentDir.Exists) { DeepProfiler.Start("Loading assets of type " + typeof(T) + " for mod " + mod); FileInfo[] files = contentDir.GetFiles("*.*", SearchOption.AllDirectories); foreach (FileInfo file in files) { if (IsAcceptableExtension(file.Extension)) { LoadedContentItem <T> loadedItem = LoadItem(file.FullName, contentDirPath); if (loadedItem != null) { yield return(loadedItem); /*Error: Unable to find new state assignment for yield return*/; } } } DeepProfiler.End(); } }
public static void LoadGameFromSaveFileNow(string fileName) { string str = (from mod in LoadedModManager.RunningMods select mod.ToString()).ToCommaList(); Log.Message("Loading game from file " + fileName + " with mods " + str); DeepProfiler.Start("Loading game from file " + fileName); Current.Game = new Game(); DeepProfiler.Start("InitLoading (read file)"); Scribe.loader.InitLoading(GenFilePaths.FilePathForSavedGame(fileName)); DeepProfiler.End(); try { ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, logVersionConflictWarning: true); if (!Scribe.EnterNode("game")) { Log.Error("Could not find game XML node."); Scribe.ForceStop(); return; } Current.Game = new Game(); Current.Game.LoadGame(); } catch (Exception) { Scribe.ForceStop(); throw; } PermadeathModeUtility.CheckUpdatePermadeathModeUniqueNameOnGameLoad(fileName); DeepProfiler.End(); }
private void Init() { this.meta = DirectXmlLoader.ItemFromXmlFile <ModMetaData.ModMetaDataInternal>(string.Concat(new object[] { this.RootDir.FullName, Path.DirectorySeparatorChar, "About", Path.DirectorySeparatorChar, "About.xml" }), true); if (this.meta.name.NullOrEmpty()) { if (this.OnSteamWorkshop) { this.meta.name = "Workshop mod " + this.Identifier; } else { this.meta.name = this.Identifier; } } if (!this.IsCoreMod && !this.OnSteamWorkshop && !VersionControl.IsWellFormattedVersionString(this.meta.targetVersion)) { Log.ErrorOnce(string.Concat(new string[] { "Mod ", this.meta.name, " has incorrectly formatted target version '", this.meta.targetVersion, "'. For the current version, write: <targetVersion>", VersionControl.CurrentVersionString, "</targetVersion>" }), this.Identifier.GetHashCode(), false); } LongEventHandler.ExecuteWhenFinished(delegate { string url = GenFilePaths.SafeURIForUnityWWWFromPath(this.PreviewImagePath); using (WWW www = new WWW(url)) { www.threadPriority = UnityEngine.ThreadPriority.High; while (!www.isDone) { Thread.Sleep(1); } if (www.error == null) { this.previewImage = www.textureNonReadable; } } }); string publishedFileIdPath = this.PublishedFileIdPath; if (File.Exists(this.PublishedFileIdPath)) { string s = File.ReadAllText(publishedFileIdPath); this.publishedFileIdInt = new PublishedFileId_t(ulong.Parse(s)); } }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; bool flag = false; switch (num) { case 0u: if (this.defPackages.Count != 0) { Log.ErrorOnce("LoadDefs called with already existing def packages", 39029405, false); } enumerator = DirectXmlLoader.XmlAssetsInModFolder(this, "Defs/").GetEnumerator(); num = 4294967293u; break; case 1u: break; default: return(false); } try { switch (num) { } if (enumerator.MoveNext()) { asset = enumerator.Current; defPackage = new DefPackage(asset.name, GenFilePaths.FolderPathRelativeToDefsFolder(asset.fullFolderPath, this)); base.AddDefPackage(defPackage); asset.defPackage = defPackage; this.$current = asset; if (!this.$disposing) { this.$PC = 1; } flag = true; return(true); } } finally { if (!flag) { if (enumerator != null) { enumerator.Dispose(); } } } this.$PC = -1; return(false); }
public static T Get(string itemPath, bool reportFailure = true) { T result; if (!UnityData.IsInMainThread) { Log.Error("Tried to get a resource \"" + itemPath + "\" from a different thread. All resources must be loaded in the main thread.", false); result = (T)((object)null); } else { T t = (T)((object)null); List <ModContentPack> runningModsListForReading = LoadedModManager.RunningModsListForReading; for (int i = runningModsListForReading.Count - 1; i >= 0; i--) { t = runningModsListForReading[i].GetContentHolder <T>().Get(itemPath); if (t != null) { return(t); } } if (typeof(T) == typeof(Texture2D)) { t = (T)((object)Resources.Load <Texture2D>(GenFilePaths.ContentPath <Texture2D>() + itemPath)); } if (typeof(T) == typeof(AudioClip)) { t = (T)((object)Resources.Load <AudioClip>(GenFilePaths.ContentPath <AudioClip>() + itemPath)); } if (t != null) { result = t; } else { if (reportFailure) { Log.Error(string.Concat(new object[] { "Could not load ", typeof(T), " at ", itemPath, " in any active mod or in base resources." }), false); } result = (T)((object)null); } } return(result); }
public IEnumerable <LoadableXmlAsset> LoadDefs() { if (this.defPackages.Count != 0) { Log.ErrorOnce("LoadDefs called with already existing def packages", 39029405, false); } foreach (LoadableXmlAsset asset in DirectXmlLoader.XmlAssetsInModFolder(this, "Defs/")) { DefPackage defPackage = new DefPackage(asset.name, GenFilePaths.FolderPathRelativeToDefsFolder(asset.fullFolderPath, this)); this.AddDefPackage(defPackage); asset.defPackage = defPackage; yield return(asset); } }
private static void LoadedFilesForMod() { List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (ModContentPack item in LoadedModManager.RunningModsListForReading) { ModContentPack mod = item; list.Add(new DebugMenuOption(mod.Name, DebugMenuOptionMode.Action, delegate { ModMetaData metaData = ModLister.GetModWithIdentifier(mod.PackageId); if (metaData.loadFolders != null && metaData.loadFolders.DefinedVersions().Count != 0) { Find.WindowStack.Add(new Dialog_DebugOptionListLister(from ver in metaData.loadFolders.DefinedVersions() select new DebugMenuOption(ver, DebugMenuOptionMode.Action, delegate { ShowTable((from f in metaData.loadFolders.FoldersForVersion(ver) select Path.Combine(mod.RootDir, f.folderName)).Reverse().ToList()); }))); } else { ShowTable(null); } })); void ShowTable(List <string> loadFolders) { List <Pair <string, string> > list2 = new List <Pair <string, string> >(); list2.AddRange(from f in DirectXmlLoader.XmlAssetsInModFolder(mod, "Defs/", loadFolders) select new Pair <string, string>(f.FullFilePath, "-")); list2.AddRange(from f in DirectXmlLoader.XmlAssetsInModFolder(mod, "Patches/", loadFolders) select new Pair <string, string>(f.FullFilePath, "-")); list2.AddRange(from f in ModContentPack.GetAllFilesForMod(mod, GenFilePaths.ContentPath <Texture2D>(), ModContentLoader <Texture2D> .IsAcceptableExtension, loadFolders) select new Pair <string, string>(f.Value.FullName, f.Key)); list2.AddRange(from f in ModContentPack.GetAllFilesForMod(mod, GenFilePaths.ContentPath <AudioClip>(), ModContentLoader <AudioClip> .IsAcceptableExtension, loadFolders) select new Pair <string, string>(f.Value.FullName, f.Key)); list2.AddRange(from f in ModContentPack.GetAllFilesForMod(mod, GenFilePaths.ContentPath <string>(), ModContentLoader <string> .IsAcceptableExtension, loadFolders) select new Pair <string, string>(f.Value.FullName, f.Key)); list2.AddRange(from f in ModContentPack.GetAllFilesForModPreserveOrder(mod, "Assemblies/", (string e) => e.ToLower() == ".dll", loadFolders) select new Pair <string, string>(f.Item2.FullName, f.Item1)); DebugTables.MakeTablesDialog(list2, new List <TableDataGetter <Pair <string, string> > > { new TableDataGetter <Pair <string, string> >("full path", (Pair <string, string> f) => f.First), new TableDataGetter <Pair <string, string> >("internal path", (Pair <string, string> f) => f.Second) }.ToArray()); } } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
public static IEnumerable <T> GetAllInFolder(string folderPath) { if (!UnityData.IsInMainThread) { Log.Error("Tried to get all resources in a folder \"" + folderPath + "\" from a different thread. All resources must be loaded in the main thread."); } else { foreach (ModContentPack runningMod in LoadedModManager.RunningMods) { using (IEnumerator <T> enumerator2 = runningMod.GetContentHolder <T>().GetAllUnderPath(folderPath).GetEnumerator()) { if (enumerator2.MoveNext()) { T item2 = enumerator2.Current; yield return(item2); /*Error: Unable to find new state assignment for yield return*/; } } } T[] items = null; if (typeof(T) == typeof(Texture2D)) { items = (T[])Resources.LoadAll <Texture2D>(GenFilePaths.ContentPath <Texture2D>() + folderPath); } if (typeof(T) == typeof(AudioClip)) { items = (T[])Resources.LoadAll <AudioClip>(GenFilePaths.ContentPath <AudioClip>() + folderPath); } if (items != null) { T[] array = items; int num = 0; if (num < array.Length) { T item = array[num]; yield return(item); /*Error: Unable to find new state assignment for yield return*/; } } } yield break; IL_024a: /*Error near IL_024b: Unexpected return in MoveNext()*/; }
private void <Init> m__0() { string url = GenFilePaths.SafeURIForUnityWWWFromPath(this.PreviewImagePath); using (WWW www = new WWW(url)) { www.threadPriority = UnityEngine.ThreadPriority.High; while (!www.isDone) { Thread.Sleep(1); } if (www.error == null) { this.previewImage = www.textureNonReadable; } } }
public static void SaveGame(string fileName) { try { SafeSaver.Save(GenFilePaths.FilePathForSavedGame(fileName), "savegame", delegate { ScribeMetaHeaderUtility.WriteMetaHeader(); Game target = Current.Game; Scribe_Deep.Look(ref target, "game"); }, Find.GameInfo.permadeathMode); lastSaveTick = Find.TickManager.TicksGame; } catch (Exception arg) { Log.Error("Exception while saving game: " + arg); } }
public static void SaveGame(string fileName) { try { string path = GenFilePaths.FilePathForSavedGame(fileName); SafeSaver.Save(path, "savegame", delegate { ScribeMetaHeaderUtility.WriteMetaHeader(); Game game = Current.Game; Scribe_Deep.Look <Game>(ref game, "game", new object[0]); }, Find.GameInfo.permadeathMode); GameDataSaveLoader.lastSaveTick = Find.TickManager.TicksGame; } catch (Exception arg) { Log.Error("Exception while saving game: " + arg, false); } }
private void Init() { meta = DirectXmlLoader.ItemFromXmlFile <ModMetaDataInternal>(RootDir.FullName + Path.DirectorySeparatorChar + "About" + Path.DirectorySeparatorChar + "About.xml"); if (meta.name.NullOrEmpty()) { if (OnSteamWorkshop) { meta.name = "Workshop mod " + Identifier; } else { meta.name = Identifier; } } if (!IsCoreMod && !OnSteamWorkshop && !VersionControl.IsWellFormattedVersionString(meta.targetVersion)) { Log.ErrorOnce("Mod " + meta.name + " has incorrectly formatted target version '" + meta.targetVersion + "'. For the current version, write: <targetVersion>" + VersionControl.CurrentVersionString + "</targetVersion>", Identifier.GetHashCode()); } LongEventHandler.ExecuteWhenFinished(delegate { string url = GenFilePaths.SafeURIForUnityWWWFromPath(PreviewImagePath); using (WWW wWW = new WWW(url)) { wWW.threadPriority = UnityEngine.ThreadPriority.High; while (!wWW.isDone) { Thread.Sleep(1); } if (wWW.error == null) { previewImage = wWW.textureNonReadable; } } }); string publishedFileIdPath = PublishedFileIdPath; if (File.Exists(PublishedFileIdPath)) { string s = File.ReadAllText(publishedFileIdPath); publishedFileIdInt = new PublishedFileId_t(ulong.Parse(s)); } }
public IEnumerable <LoadableXmlAsset> LoadDefs() { if (defPackages.Count != 0) { Log.ErrorOnce("LoadDefs called with already existing def packages", 39029405); } using (IEnumerator <LoadableXmlAsset> enumerator = DirectXmlLoader.XmlAssetsInModFolder(this, "Defs/").GetEnumerator()) { if (enumerator.MoveNext()) { LoadableXmlAsset asset = enumerator.Current; DefPackage defPackage = new DefPackage(asset.name, GenFilePaths.FolderPathRelativeToDefsFolder(asset.fullFolderPath, this)); AddDefPackage(defPackage); asset.defPackage = defPackage; yield return(asset); /*Error: Unable to find new state assignment for yield return*/; } } yield break; IL_0131: /*Error near IL_0132: Unexpected return in MoveNext()*/; }
public void LoadDefs(IEnumerable <PatchOperation> patches) { DeepProfiler.Start("Loading all defs"); List <LoadableXmlAsset> list = DirectXmlLoader.XmlAssetsInModFolder(this, "Defs/").ToList <LoadableXmlAsset>(); foreach (LoadableXmlAsset current in list) { foreach (PatchOperation current2 in patches) { current2.Apply(current.xmlDoc); } } for (int i = 0; i < list.Count; i++) { if (list[i] == null || list[i].xmlDoc == null || list[i].xmlDoc.DocumentElement == null) { Log.Error(string.Format("{0}: unknown parse failure", list[i].fullFolderPath + "/" + list[i].name)); } else if (list[i].xmlDoc.DocumentElement.Name != "Defs") { Log.Error(string.Format("{0}: root element named {1}; should be named Defs", list[i].fullFolderPath + "/" + list[i].name, list[i].xmlDoc.DocumentElement.Name)); } XmlInheritance.TryRegisterAllFrom(list[i], this); } XmlInheritance.Resolve(); for (int j = 0; j < list.Count; j++) { string relFolder = GenFilePaths.FolderPathRelativeToDefsFolder(list[j].fullFolderPath, this); DefPackage defPackage = new DefPackage(list[j].name, relFolder); foreach (Def current3 in DirectXmlLoader.AllDefsFromAsset(list[j])) { defPackage.defs.Add(current3); } this.defPackages.Add(defPackage); } DeepProfiler.End(); }
public static T Get(string itemPath, bool reportFailure = true) { if (!UnityData.IsInMainThread) { Log.Error("Tried to get a resource \"" + itemPath + "\" from a different thread. All resources must be loaded in the main thread."); return((T)null); } T val = (T)null; List <ModContentPack> runningModsListForReading = LoadedModManager.RunningModsListForReading; for (int num = runningModsListForReading.Count - 1; num >= 0; num--) { val = runningModsListForReading[num].GetContentHolder <T>().Get(itemPath); if (val != null) { return(val); } } if (typeof(T) == typeof(Texture2D)) { val = (T)(object)Resources.Load <Texture2D>(GenFilePaths.ContentPath <Texture2D>() + itemPath); } if (typeof(T) == typeof(AudioClip)) { val = (T)(object)Resources.Load <AudioClip>(GenFilePaths.ContentPath <AudioClip>() + itemPath); } if (val != null) { return(val); } if (reportFailure) { Log.Error("Could not load " + typeof(T) + " at " + itemPath + " in any active mod or in base resources."); } return((T)null); }
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 T Get(string itemPath, bool reportFailure = true) { if (!UnityData.IsInMainThread) { Log.Error("Tried to get a resource \"" + itemPath + "\" from a different thread. All resources must be loaded in the main thread."); return(null); } T val = null; List <ModContentPack> runningModsListForReading = LoadedModManager.RunningModsListForReading; for (int num = runningModsListForReading.Count - 1; num >= 0; num--) { val = runningModsListForReading[num].GetContentHolder <T>().Get(itemPath); if (val != null) { return(val); } } if (typeof(T) == typeof(Texture2D)) { val = (T)(object)Resources.Load <Texture2D>(GenFilePaths.ContentPath <Texture2D>() + itemPath); } if (typeof(T) == typeof(AudioClip)) { val = (T)(object)Resources.Load <AudioClip>(GenFilePaths.ContentPath <AudioClip>() + itemPath); } if (val != null) { return(val); } for (int num2 = runningModsListForReading.Count - 1; num2 >= 0; num2--) { for (int i = 0; i < runningModsListForReading[num2].assetBundles.loadedAssetBundles.Count; i++) { AssetBundle assetBundle = runningModsListForReading[num2].assetBundles.loadedAssetBundles[i]; string path = Path.Combine("Assets", "Data"); path = Path.Combine(path, runningModsListForReading[num2].FolderName); if (typeof(T) == typeof(Texture2D)) { string str = Path.Combine(Path.Combine(path, GenFilePaths.ContentPath <Texture2D>()), itemPath); for (int j = 0; j < ModAssetBundlesHandler.TextureExtensions.Length; j++) { val = (T)(object)assetBundle.LoadAsset <Texture2D>(str + ModAssetBundlesHandler.TextureExtensions[j]); if (val != null) { return(val); } } } if (!(typeof(T) == typeof(AudioClip))) { continue; } string str2 = Path.Combine(Path.Combine(path, GenFilePaths.ContentPath <AudioClip>()), itemPath); for (int k = 0; k < ModAssetBundlesHandler.AudioClipExtensions.Length; k++) { val = (T)(object)assetBundle.LoadAsset <AudioClip>(str2 + ModAssetBundlesHandler.AudioClipExtensions[k]); if (val != null) { return(val); } } } } if (reportFailure) { Log.Error(string.Concat("Could not load ", typeof(T), " at ", itemPath, " in any active mod or in base resources.")); } return(null); }
public static IEnumerable <T> GetAllInFolder(string folderPath) { if (!UnityData.IsInMainThread) { Log.Error("Tried to get all resources in a folder \"" + folderPath + "\" from a different thread. All resources must be loaded in the main thread."); yield break; } foreach (ModContentPack runningMod in LoadedModManager.RunningMods) { foreach (T item in runningMod.GetContentHolder <T>().GetAllUnderPath(folderPath)) { yield return(item); } } T[] array = null; if (typeof(T) == typeof(Texture2D)) { array = (T[])(object)Resources.LoadAll <Texture2D>(GenFilePaths.ContentPath <Texture2D>() + folderPath); } if (typeof(T) == typeof(AudioClip)) { array = (T[])(object)Resources.LoadAll <AudioClip>(GenFilePaths.ContentPath <AudioClip>() + folderPath); } if (array != null) { T[] array2 = array; for (int j = 0; j < array2.Length; j++) { yield return(array2[j]); } } List <ModContentPack> mods = LoadedModManager.RunningModsListForReading; for (int j = mods.Count - 1; j >= 0; j--) { for (int i = 0; i < mods[j].assetBundles.loadedAssetBundles.Count; i++) { AssetBundle assetBundle = mods[j].assetBundles.loadedAssetBundles[i]; string dirForBundle2 = Path.Combine("Assets", "Data"); dirForBundle2 = Path.Combine(dirForBundle2, mods[j].FolderName); if (typeof(T) == typeof(Texture2D)) { string fullPath = Path.Combine(Path.Combine(dirForBundle2, GenFilePaths.ContentPath <Texture2D>()).Replace('\\', '/'), folderPath).ToLower(); IEnumerable <string> enumerable = from p in mods[j].AllAssetNamesInBundle(i) where p.StartsWith(fullPath) select p; foreach (string item2 in enumerable) { if (ModAssetBundlesHandler.TextureExtensions.Contains(Path.GetExtension(item2))) { yield return((T)(object)assetBundle.LoadAsset <Texture2D>(item2)); } } } if (!(typeof(T) == typeof(AudioClip))) { continue; } string fullPath2 = Path.Combine(Path.Combine(dirForBundle2, GenFilePaths.ContentPath <AudioClip>()).Replace('\\', '/'), folderPath).ToLower(); IEnumerable <string> enumerable2 = from p in mods[j].AllAssetNamesInBundle(i) where p.StartsWith(fullPath2) select p; foreach (string item3 in enumerable2) { if (ModAssetBundlesHandler.AudioClipExtensions.Contains(Path.GetExtension(item3))) { yield return((T)(object)assetBundle.LoadAsset <AudioClip>(item3)); } } } } }