public static IEnumerable <T> LoadXmlDataInResourcesFolder <T>(string folderPath) where T : new() { XmlInheritance.Clear(); List <LoadableXmlAsset> assets = new List <LoadableXmlAsset>(); object[] textObjects = Resources.LoadAll <TextAsset>(folderPath); object[] array = textObjects; for (int j = 0; j < array.Length; j++) { TextAsset textAsset = (TextAsset)array[j]; LoadableXmlAsset loadableXmlAsset = new LoadableXmlAsset(textAsset.name, string.Empty, textAsset.text); XmlInheritance.TryRegisterAllFrom(loadableXmlAsset, null); assets.Add(loadableXmlAsset); } XmlInheritance.Resolve(); for (int i = 0; i < assets.Count; i++) { using (IEnumerator <T> enumerator = DirectXmlLoader.AllGameItemsFromAsset <T>(assets[i]).GetEnumerator()) { if (enumerator.MoveNext()) { T item = enumerator.Current; yield return(item); /*Error: Unable to find new state assignment for yield return*/; } } } XmlInheritance.Clear(); yield break; IL_0195: /*Error near IL_0196: Unexpected return in MoveNext()*/; }
public static IEnumerable <T> LoadXmlDataInResourcesFolder <T>(string folderPath) where T : new() { XmlInheritance.Clear(); List <LoadableXmlAsset> assets = new List <LoadableXmlAsset>(); object[] array = Resources.LoadAll <TextAsset>(folderPath); for (int j = 0; j < array.Length; j++) { TextAsset textAsset = (TextAsset)array[j]; LoadableXmlAsset loadableXmlAsset = new LoadableXmlAsset(textAsset.name, "", textAsset.text); XmlInheritance.TryRegisterAllFrom(loadableXmlAsset, null); assets.Add(loadableXmlAsset); } XmlInheritance.Resolve(); for (int i = 0; i < assets.Count; i++) { foreach (T item in AllGameItemsFromAsset <T>(assets[i])) { yield return(item); } } XmlInheritance.Clear(); }
public static IEnumerable <T> LoadXmlDataInResourcesFolder <T>(string folderPath) where T : new() { XmlInheritance.Clear(); List <LoadableXmlAsset> assets = new List <LoadableXmlAsset>(); object[] textObjects = Resources.LoadAll <TextAsset>(folderPath); foreach (TextAsset textAsset in textObjects) { LoadableXmlAsset loadableXmlAsset = new LoadableXmlAsset(textAsset.name, string.Empty, textAsset.text); XmlInheritance.TryRegisterAllFrom(loadableXmlAsset, null); assets.Add(loadableXmlAsset); } XmlInheritance.Resolve(); for (int i = 0; i < assets.Count; i++) { foreach (T item in DirectXmlLoader.AllGameItemsFromAsset <T>(assets[i])) { yield return(item); } } XmlInheritance.Clear(); yield break; }
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(); }