Beispiel #1
0
        public static void GetObjectInfos(string fileName, Dictionary <string, List <ObjectInfo> > infosByListName)
        {
            string levelName;
            string categoryName;

            string fileNameWithoutExt = Path.GetFileNameWithoutExtension(fileName);

            if (fileNameWithoutExt.EndsWith("Map1"))
            {
                levelName    = fileNameWithoutExt.Remove(fileNameWithoutExt.Length - 4);
                categoryName = "Map";
            }
            else if (fileNameWithoutExt.EndsWith("Design1"))
            {
                levelName    = fileNameWithoutExt.Remove(fileNameWithoutExt.Length - 7);
                categoryName = "Design";
            }
            else if (fileNameWithoutExt.EndsWith("Sound1"))
            {
                levelName    = fileNameWithoutExt.Remove(fileNameWithoutExt.Length - 6);
                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"]));

            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));
                }
            }
        }
Beispiel #2
0
        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
            }
        }
Beispiel #3
0
        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
        }