private static void GetObjectInfos(Dictionary <string, List <ObjectInfo> > infosByListName, string levelName, string categoryName, SarcData sarc) { Dictionary <long, ObjectInfo> objectInfosByReference = new Dictionary <long, ObjectInfo>(); if (sarc.Files.TryGetValue(levelName + categoryName + ".byml", out var data)) { ByamlIterator byamlIter = new ByamlIterator(new MemoryStream(data)); #if ODYSSEY foreach (ArrayEntry scenario in byamlIter.IterRootArray()) { foreach (DictionaryEntry entry in scenario.IterDictionary()) { if (!infosByListName.ContainsKey(entry.Key)) { continue; } List <ObjectInfo> objectInfos = new List <ObjectInfo>(); foreach (ArrayEntry obj in entry.IterArray()) { objectInfos.Add(ParseObjectInfo(obj, objectInfosByReference, infosByListName, entry.Key)); } } } #else foreach (DictionaryEntry entry in byamlIter.IterRootDictionary()) { if (!infosByListName.ContainsKey(entry.Key)) { continue; } List <ObjectInfo> objectInfos = new List <ObjectInfo>(); foreach (ArrayEntry obj in entry.IterArray()) { objectInfos.Add(ParseObjectInfo(obj, objectInfosByReference, infosByListName, entry.Key)); } } #endif } }
public static void GetObjectInfos(string fileName, Dictionary <string, List <ObjectInfo> > infosByListName) { string levelName; string categoryName; string levelNameWithSuffix = Path.GetFileName(fileName); if (fileName.EndsWith(SM3DWorldZone.MAP_SUFFIX)) { levelName = levelNameWithSuffix.Remove(levelNameWithSuffix.Length - SM3DWorldZone.MAP_SUFFIX.Length); categoryName = "Map"; } else if (fileName.EndsWith(SM3DWorldZone.DESIGN_SUFFIX)) { levelName = levelNameWithSuffix.Remove(levelNameWithSuffix.Length - SM3DWorldZone.DESIGN_SUFFIX.Length); categoryName = "Design"; } else if (fileName.EndsWith(SM3DWorldZone.SOUND_SUFFIX)) { levelName = levelNameWithSuffix.Remove(levelNameWithSuffix.Length - SM3DWorldZone.SOUND_SUFFIX.Length); categoryName = "Sound"; } else { return; } SarcData sarc = SARC.UnpackRamN(YAZ0.Decompress(fileName)); Dictionary <long, ObjectInfo> objectInfosByReference = new Dictionary <long, ObjectInfo>(); ByamlIterator byamlIter = new ByamlIterator(new MemoryStream(sarc.Files[levelName + categoryName + ".byml"])); #if ODYSSEY foreach (ArrayEntry scenario in byamlIter.IterRootArray()) { foreach (DictionaryEntry entry in scenario.IterDictionary()) { if (!infosByListName.ContainsKey(entry.Key)) { continue; } List <ObjectInfo> objectInfos = new List <ObjectInfo>(); foreach (ArrayEntry obj in entry.IterArray()) { objectInfos.Add(ParseObjectInfo(obj, objectInfosByReference, infosByListName, entry.Key)); } } } #else foreach (DictionaryEntry entry in byamlIter.IterRootDictionary()) { if (!infosByListName.ContainsKey(entry.Key)) { continue; } List <ObjectInfo> objectInfos = new List <ObjectInfo>(); foreach (ArrayEntry obj in entry.IterArray()) { objectInfos.Add(ParseObjectInfo(obj, objectInfosByReference, infosByListName, entry.Key)); } } #endif }