Example #1
0
        /// <summary>
        /// Constructs a new instance of the Gesture class.
        /// </summary>
        /// <param name="Reader">A FileReader used to read a HandGroup file.</param>
        public Gesture(FileReader Reader)
        {
            uint FileID = Reader.ReadUInt32();
            uint TypeID = Reader.ReadUInt32();

            AppearanceID = new UniqueFileID(TypeID, FileID);
        }
Example #2
0
        public Binding(Stream Data)
        {
            FileReader Reader = new FileReader(Data, true);

            Reader.ReadUInt32(); //Version

            Bone = Reader.ReadPascalString();

            uint AssetType = Reader.ReadUInt32();
            uint FileID = 0, TypeID = 0;

            if (AssetType == 8)
            {
                //A 4-byte unsigned integer specifying the type of data that follows; should be 0xA96F6D42 for cAssetKey
                Reader.ReadUInt32();
                FileID = Reader.ReadUInt32();
                TypeID = Reader.ReadUInt32();
                MeshID = new UniqueFileID(TypeID, FileID);
            }

            AssetType = Reader.ReadUInt32();

            if (AssetType == 8)
            {
                //A 4-byte unsigned integer specifying the type of data that follows; should be 0xA96F6D42 for cAssetKey
                Reader.ReadUInt32();
                FileID    = Reader.ReadUInt32();
                TypeID    = Reader.ReadUInt32();
                TextureID = new UniqueFileID(TypeID, FileID);
            }
        }
        /// <summary>
        /// Reads all the entries in the archive into memory.
        /// </summary>
        /// <param name="ThrowException">Wether or not to throw an exception if the archive was not a FAR3. If false, function will return.</param>
        public bool ReadArchive(bool ThrowException)
        {
            m_FinishedReading.Reset();

            if (m_Reader == null)
            {
                m_Reader = new FileReader(m_Path, false);
            }

            lock (m_Reader)
            {
                ASCIIEncoding Enc         = new ASCIIEncoding();
                string        MagicNumber = Enc.GetString(m_Reader.ReadBytes(8));

                if (!MagicNumber.Equals("FAR!byAZ", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (ThrowException)
                    {
                        throw new FAR3Exception("MagicNumber was wrong - FAR3Archive.cs!");
                    }
                    else
                    {
                        m_Reader.Close();
                        return(false);
                    }
                }

                m_Reader.ReadUInt32(); //Version.
                m_Reader.Seek((long)m_Reader.ReadUInt32());

                uint NumFiles = m_Reader.ReadUInt32();

                for (int i = 0; i < NumFiles; i++)
                {
                    FAR3Entry Entry = new FAR3Entry();
                    Entry.DecompressedDataSize = m_Reader.ReadUInt32();
                    byte[] Dummy = m_Reader.ReadBytes(3);
                    Entry.CompressedDataSize = (uint)((Dummy[0] << 0) | (Dummy[1] << 8) | (Dummy[2]) << 16);
                    m_Reader.ReadByte(); //Unknown.
                    Entry.DataOffset     = m_Reader.ReadUInt32();
                    Entry.Flags          = m_Reader.ReadUShort();
                    Entry.FileNameLength = m_Reader.ReadUShort();
                    Entry.TypeID         = m_Reader.ReadUInt32();
                    Entry.FileID         = m_Reader.ReadUInt32();
                    Entry.Filename       = Enc.GetString(m_Reader.ReadBytes(Entry.FileNameLength));

                    UniqueFileID ID = new UniqueFileID(Entry.TypeID, Entry.FileID);

                    if (!m_Entries.ContainsKey(ID.UniqueID))
                    {
                        m_Entries.AddOrUpdate(ID.UniqueID, Entry, (Key, ExistingValue) => ExistingValue = Entry);
                    }
                }
            }

            m_FinishedReading.Set();

            return(true);
        }
Example #4
0
        public Outfit(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            uint Version = m_Reader.ReadUInt32(); //Version
            m_Reader.ReadUInt32(); //Unknown

            LightAppearance = ReadBackwardsID();
            MediumAppearance = ReadBackwardsID();
            DarkAppearance = ReadBackwardsID();
            m_HandGroup = m_Reader.ReadUInt32();
            Region = (OutfitRegion)Endian.SwapUInt32(m_Reader.ReadUInt32());
        }
Example #5
0
        public Outfit(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            uint Version = m_Reader.ReadUInt32(); //Version

            m_Reader.ReadUInt32();                //Unknown

            LightAppearance  = ReadBackwardsID();
            MediumAppearance = ReadBackwardsID();
            DarkAppearance   = ReadBackwardsID();
            m_HandGroup      = m_Reader.ReadUInt32();
            Region           = (OutfitRegion)Endian.SwapUInt32(m_Reader.ReadUInt32());
        }
        public Appearance(Stream Data)
        {
            FileReader Reader = new FileReader(Data, true);

            Reader.ReadUInt32(); //Version

            uint FileID = Reader.ReadUInt32(), TypeID = Reader.ReadUInt32();

            ThumbnailID = new UniqueFileID(TypeID, FileID);

            uint BindingCount = Reader.ReadUInt32();
            for (uint i = 0; i < BindingCount; i++)
            {
                FileID = Reader.ReadUInt32();
                TypeID = Reader.ReadUInt32();
                BindingIDs.Add(new UniqueFileID(TypeID, FileID));
            }
        }
        public Appearance(Stream Data)
        {
            FileReader Reader = new FileReader(Data, true);

            Reader.ReadUInt32(); //Version

            uint FileID = Reader.ReadUInt32(), TypeID = Reader.ReadUInt32();

            ThumbnailID = new UniqueFileID(TypeID, FileID);

            uint BindingCount = Reader.ReadUInt32();

            for (uint i = 0; i < BindingCount; i++)
            {
                FileID = Reader.ReadUInt32();
                TypeID = Reader.ReadUInt32();
                BindingIDs.Add(new UniqueFileID(TypeID, FileID));
            }
        }
Example #8
0
        /// <summary>
        /// Returns an entry in this archive as a Stream instance.
        /// Throws a DBPFException if entry was not found.
        /// </summary>
        /// <param name="ID">ID of the entry to grab from archive.</param>
        /// <returns>The entry's data as a Stream instance.</returns>
        public Stream GrabEntry(UniqueFileID ID)
        {
            m_FinishedReading.WaitOne();

            if (!ContainsEntry(ID))
            {
                throw new DBPFException("Couldn't find entry - DBPFArchive.cs!");
            }

            DBPFEntry Entry = m_Entries[ID];

            m_Reader.Seek(Entry.FileOffset);

            MemoryStream Data = new MemoryStream(m_Reader.ReadBytes((int)Entry.FileSize));

            Data.Position = 0;

            return(Data);
        }
        /// <summary>
        /// Constructs a new instance of the PurchasableOutfit class.
        /// </summary>
        /// <param name="Data">A Stream of data retrieved from a FAR3 archive.</param>
        public PurchasableOutfit(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version
            m_Reader.ReadUInt32(); //Unknown
            OutfitType = m_Reader.ReadUInt32();

            if(OutfitType != 0)
            {
                //A 4-byte unsigned integer specifying the type of data that follows; should be 0xA96F6D42 for cAssetKey
                m_Reader.ReadUInt32();
                uint FileID = m_Reader.ReadUInt32();
                uint TypeID = m_Reader.ReadUInt32();
                OutfitID = new UniqueFileID(TypeID, FileID);
            }

            m_Reader.ReadUInt32(); //Unknown.

            m_Reader.Close();
        }
Example #10
0
        /// <summary>
        /// Constructs a new instance of the PurchasableOutfit class.
        /// </summary>
        /// <param name="Data">A Stream of data retrieved from a FAR3 archive.</param>
        public PurchasableOutfit(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version
            m_Reader.ReadUInt32(); //Unknown
            OutfitType = m_Reader.ReadUInt32();

            if (OutfitType != 0)
            {
                //A 4-byte unsigned integer specifying the type of data that follows; should be 0xA96F6D42 for cAssetKey
                m_Reader.ReadUInt32();
                uint FileID = m_Reader.ReadUInt32();
                uint TypeID = m_Reader.ReadUInt32();
                OutfitID = new UniqueFileID(TypeID, FileID);
            }

            m_Reader.ReadUInt32(); //Unknown.

            m_Reader.Close();
        }
Example #11
0
        public override bool Equals(object obj)
        {
            try
            {
                UniqueFileID OtherID = (UniqueFileID)obj;
                if (OtherID.FileID == FileID && OtherID.GroupID == GroupID && OtherID.TypeID == TypeID)
                {
                    return(true);
                }

                if (OtherID.FileID == FileID && OtherID.TypeID == TypeID)
                {
                    return(true);
                }

                return(false);
            }
            catch
            {
                return(false);
            }
        }
Example #12
0
        /// <summary>
        /// Reads all entries in this archive into memory.
        /// </summary>
        /// <param name="ThrowException">Wether or not to throw an exception if the archive was not a DBPF. If false, function will return.</param>
        public bool ReadArchive(bool ThrowException)
        {
            m_FinishedReading.Reset();

            if (m_Reader == null)
            {
                try
                {
                    m_Reader = new FileReader(m_Path, false);
                }
                //This will be thrown because of file access privileges or because an archive is being tentatively opened twice.
                catch (Exception)
                {
                    if (ThrowException)
                    {
                        throw;
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            lock (m_Reader)
            {
                ASCIIEncoding Enc         = new ASCIIEncoding();
                string        MagicNumber = Enc.GetString(m_Reader.ReadBytes(4));

                if (!MagicNumber.Equals("DBPF", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (ThrowException)
                    {
                        throw new DBPFException("MagicNumber was wrong - DBPFArchive.cs!");
                    }
                    else
                    {
                        m_Reader.Close();
                        return(false);
                    }
                }

                m_Reader.ReadUInt32();  //MajorVersion
                m_Reader.ReadUInt32();  //MinorVersion
                m_Reader.ReadBytes(12); //Reserved.
                m_Reader.ReadBytes(4);  //Date created.
                m_Reader.ReadBytes(4);  //Date modified.
                m_Reader.ReadUInt32();  //Index major version.
                IndexEntryCount = m_Reader.ReadUInt32();
                IndexOffset     = m_Reader.ReadUInt32();
                IndexSize       = m_Reader.ReadUInt32();

                m_Reader.Seek(IndexOffset);

                for (int i = 0; i < IndexEntryCount; i++)
                {
                    DBPFEntry Entry = new DBPFEntry();
                    Entry.TypeID     = m_Reader.ReadUInt32();
                    Entry.GroupID    = m_Reader.ReadUInt32();
                    Entry.InstanceID = m_Reader.ReadUInt32();
                    Entry.FileOffset = m_Reader.ReadUInt32();
                    Entry.FileSize   = m_Reader.ReadUInt32();

                    UniqueFileID ID = new UniqueFileID(Entry.TypeID, Entry.InstanceID, Entry.GroupID);
                    Entry.EntryID = ID;
                    m_Entries.Add(ID, Entry);
                }
            }

            m_FinishedReading.Set();

            return(true);
        }
Example #13
0
 /// <summary>
 /// Does this archive contain the specified entry?
 /// </summary>
 /// <param name="ID">ID of the entry to search for.</param>
 /// <returns>True if entry was found, false otherwise.</returns>
 public bool ContainsEntry(UniqueFileID ID)
 {
     return(m_Entries.ContainsKey(ID));
 }
 /// <summary>
 /// Does this archive contain the specified entry?
 /// </summary>
 /// <param name="ID">ID of the entry to search for.</param>
 /// <returns>True if entry was found, false otherwise.</returns>
 public bool ContainsEntry(UniqueFileID ID)
 {
     return m_Entries.ContainsKey(ID);
 }
        /// <summary>
        /// Reads all entries in this archive into memory.
        /// </summary>
        /// <param name="ThrowException">Wether or not to throw an exception if the archive was not a DBPF. If false, function will return.</param>
        public bool ReadArchive(bool ThrowException)
        {
            m_FinishedReading.Reset();

            if (m_Reader == null)
            {
                try
                {
                    m_Reader = new FileReader(m_Path, false);
                }
                //This will be thrown because of file access privileges or because an archive is being tentatively opened twice.
                catch (Exception)
                {
                    if (ThrowException)
                        throw;
                    else
                        return false;
                }
            }

            lock (m_Reader)
            {
                ASCIIEncoding Enc = new ASCIIEncoding();
                string MagicNumber = Enc.GetString(m_Reader.ReadBytes(4));

                if (!MagicNumber.Equals("DBPF", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (ThrowException)
                        throw new DBPFException("MagicNumber was wrong - DBPFArchive.cs!");
                    else
                    {
                        m_Reader.Close();
                        return false;
                    }
                }

                m_Reader.ReadUInt32();  //MajorVersion
                m_Reader.ReadUInt32();  //MinorVersion
                m_Reader.ReadBytes(12); //Reserved.
                m_Reader.ReadBytes(4);  //Date created.
                m_Reader.ReadBytes(4);  //Date modified.
                m_Reader.ReadUInt32();  //Index major version.
                IndexEntryCount = m_Reader.ReadUInt32();
                IndexOffset = m_Reader.ReadUInt32();
                IndexSize = m_Reader.ReadUInt32();

                m_Reader.Seek(IndexOffset);

                for(int i = 0; i < IndexEntryCount; i++)
                {
                    DBPFEntry Entry = new DBPFEntry();
                    Entry.TypeID = m_Reader.ReadUInt32();
                    Entry.GroupID = m_Reader.ReadUInt32();
                    Entry.InstanceID = m_Reader.ReadUInt32();
                    Entry.FileOffset = m_Reader.ReadUInt32();
                    Entry.FileSize = m_Reader.ReadUInt32();

                    UniqueFileID ID = new UniqueFileID(Entry.TypeID, Entry.InstanceID, Entry.GroupID);
                    Entry.EntryID = ID;
                    m_Entries.Add(ID, Entry);
                }
            }

            m_FinishedReading.Set();

            return true;
        }
        /// <summary>
        /// Returns an entry in this archive as a Stream instance.
        /// Throws a DBPFException if entry was not found.
        /// </summary>
        /// <param name="ID">ID of the entry to grab from archive.</param>
        /// <returns>The entry's data as a Stream instance.</returns>
        public Stream GrabEntry(UniqueFileID ID)
        {
            m_FinishedReading.WaitOne();

            if (!ContainsEntry(ID))
                throw new DBPFException("Couldn't find entry - DBPFArchive.cs!");

            DBPFEntry Entry = m_Entries[ID];

            m_Reader.Seek(Entry.FileOffset);

            MemoryStream Data = new MemoryStream(m_Reader.ReadBytes((int)Entry.FileSize));
            Data.Position = 0;

            return Data;
        }
        /// <summary>
        /// Reads all the entries in the archive into memory.
        /// </summary>
        /// <param name="ThrowException">Wether or not to throw an exception if the archive was not a FAR3. If false, function will return.</param>
        public bool ReadArchive(bool ThrowException)
        {
            m_FinishedReading.Reset();

            if (m_Reader == null)
                m_Reader = new FileReader(m_Path, false);

            lock (m_Reader)
            {
                ASCIIEncoding Enc = new ASCIIEncoding();
                string MagicNumber = Enc.GetString(m_Reader.ReadBytes(8));

                if (!MagicNumber.Equals("FAR!byAZ", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (ThrowException)
                        throw new FAR3Exception("MagicNumber was wrong - FAR3Archive.cs!");
                    else
                    {
                        m_Reader.Close();
                        return false;
                    }
                }

                m_Reader.ReadUInt32(); //Version.
                m_Reader.Seek((long)m_Reader.ReadUInt32());

                uint NumFiles = m_Reader.ReadUInt32();

                for (int i = 0; i < NumFiles; i++)
                {
                    FAR3Entry Entry = new FAR3Entry();
                    Entry.DecompressedDataSize = m_Reader.ReadUInt32();
                    byte[] Dummy = m_Reader.ReadBytes(3);
                    Entry.CompressedDataSize = (uint)((Dummy[0] << 0) | (Dummy[1] << 8) | (Dummy[2]) << 16);
                    m_Reader.ReadByte(); //Unknown.
                    Entry.DataOffset = m_Reader.ReadUInt32();
                    Entry.Flags = m_Reader.ReadUShort();
                    Entry.FileNameLength = m_Reader.ReadUShort();
                    Entry.TypeID = m_Reader.ReadUInt32();
                    Entry.FileID = m_Reader.ReadUInt32();
                    Entry.Filename = Enc.GetString(m_Reader.ReadBytes(Entry.FileNameLength));

                    UniqueFileID ID = new UniqueFileID(Entry.TypeID, Entry.FileID);

                    if (!m_Entries.ContainsKey(ID.UniqueID))
                        m_Entries.AddOrUpdate(ID.UniqueID, Entry, (Key, ExistingValue) => ExistingValue = Entry);
                }
            }

            m_FinishedReading.Set();

            return true;
        }
        /// <summary>
        /// Gets an HLS instance from the FileManager.
        /// </summary>
        /// <param name="ID">The FileID/InstanceID of the hitlist to get.</param>
        /// <returns>A new HLS instance.</returns>
        public static HLS GetHLS(uint ID)
        {
            UniqueFileID UID = new UniqueFileID((uint)TypeIDs.HIT, ID);

            if (m_Assets.ContainsKey(UID.UniqueID))
            {
                m_AssetsResetEvent.WaitOne();
                return (HLS)m_Assets[UID.UniqueID].AssetData;
            }

            return (HLS)GrabItem(ID, TypeIDs.HIT);
        }
Example #19
0
 /// <summary>
 /// Constructs a new instance of the Gesture class.
 /// </summary>
 /// <param name="Reader">A FileReader used to read a HandGroup file.</param>
 public Gesture(FileReader Reader)
 {
     uint FileID = Reader.ReadUInt32();
     uint TypeID = Reader.ReadUInt32();
     AppearanceID = new UniqueFileID(TypeID, FileID);
 }
        /// <summary>
        /// Returns a Stream instance with data from the specified item.
        /// </summary>
        /// <param name="ID">ID of the item to grab.</param>
        /// <param name="TypeID">TypeID of the the item to grab.</param>
        /// <returns>An object that can be casted to the instance corresponding to the TypeID.</returns>
        private static object GrabItem(uint ID, TypeIDs TypeID)
        {
            Stream Data;

            m_StillLoading.WaitOne();

            foreach (DBPFArchive Archive in m_DBPFArchives)
            {
                if (Archive.ContainsEntry(new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.Custom)))
                {
                    UniqueFileID UniqueID = new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.Custom);
                    Data = Archive.GrabEntry(UniqueID);

                    if (!m_Assets.ContainsKey(UniqueID.UniqueID))
                    {
                        if (IsUTK(Data))
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new UTKFile2(Data)));
                        else
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new XAFile(Data)));
                    }

                    return m_Assets[UniqueID.UniqueID].AssetData;
                }

                if (Archive.ContainsEntry(new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.CustomTrks)))
                {
                    UniqueFileID UniqueID = new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.CustomTrks);

                    Data = Archive.GrabEntry(UniqueID);

                    if (!m_Assets.ContainsKey(UniqueID.UniqueID))
                        AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new TRK(Data)));

                    return Archive.GrabEntry(UniqueID);
                }

                if (Archive.ContainsEntry(new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.EP2)))
                {
                    UniqueFileID UniqueID = new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.EP2);
                    Data = Archive.GrabEntry(UniqueID);

                    if (!m_Assets.ContainsKey(UniqueID.UniqueID))
                    {
                        if (IsUTK(Data))
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new UTKFile2(Data)));
                        else
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new XAFile(Data)));
                    }

                    return Archive.GrabEntry(UniqueID);
                }

                if (Archive.ContainsEntry(new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.EP5Samps)))
                {
                    UniqueFileID UniqueID = new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.EP5Samps);
                    Data = Archive.GrabEntry(UniqueID);

                    if (!m_Assets.ContainsKey(UniqueID.UniqueID))
                    {
                        if (IsUTK(Data))
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new UTKFile2(Data)));
                        else
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new XAFile(Data)));
                    }

                    return m_Assets[UniqueID.UniqueID].AssetData;
                }

                if (Archive.ContainsEntry(new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.HitLists)))
                {
                    UniqueFileID UniqueID = new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.HitLists);

                    Data = Archive.GrabEntry(UniqueID);

                    if (!m_Assets.ContainsKey(UniqueID.UniqueID))
                        AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new HLS(Data)));

                    return m_Assets[UniqueID.UniqueID].AssetData;
                }

                if (Archive.ContainsEntry(new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.HitListsTemp)))
                {
                    UniqueFileID UniqueID = new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.HitListsTemp);

                    Data = Archive.GrabEntry(UniqueID);

                    if (!m_Assets.ContainsKey(UniqueID.UniqueID))
                        AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new HLS(Data)));

                    return m_Assets[UniqueID.UniqueID].AssetData;
                }

                if (Archive.ContainsEntry(new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.Multiplayer)))
                {
                    UniqueFileID UniqueID = new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.Multiplayer);
                    Data = Archive.GrabEntry(UniqueID);

                    if (!m_Assets.ContainsKey(UniqueID.UniqueID))
                    {
                        if (IsUTK(Data))
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new UTKFile2(Data)));
                        else
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new XAFile(Data)));
                    }

                    return m_Assets[UniqueID.UniqueID].AssetData;
                }

                if (Archive.ContainsEntry(new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.Samples)))
                {
                    UniqueFileID UniqueID = new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.Samples);
                    Data = Archive.GrabEntry(UniqueID);

                    if (!m_Assets.ContainsKey(UniqueID.UniqueID))
                    {
                        if (IsUTK(Data))
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new UTKFile2(Data)));
                        else
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new XAFile(Data)));
                    }

                    return m_Assets[UniqueID.UniqueID].AssetData;
                }

                if (Archive.ContainsEntry(new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.TrackDefs)))
                {
                    UniqueFileID UniqueID = new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.TrackDefs);
                    Data = Archive.GrabEntry(UniqueID);

                    if (!m_Assets.ContainsKey(UniqueID.UniqueID))
                        AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new TRK(Data)));

                    return m_Assets[UniqueID.UniqueID].AssetData;
                }

                if (Archive.ContainsEntry(new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.Tracks)))
                {
                    UniqueFileID UniqueID = new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.Tracks);
                    Data = Archive.GrabEntry(UniqueID);

                    if (!m_Assets.ContainsKey(UniqueID.UniqueID))
                        AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new TRK(Data)));

                    return m_Assets[UniqueID.UniqueID].AssetData;
                }

                if (Archive.ContainsEntry(new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.tsov2)))
                {
                    UniqueFileID UniqueID = new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.tsov2);
                    Data = Archive.GrabEntry(UniqueID);

                    if (!m_Assets.ContainsKey(UniqueID.UniqueID))
                    {
                        if (IsUTK(Data))
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new UTKFile2(Data)));
                        else
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new XAFile(Data)));
                    }

                    return m_Assets[UniqueID.UniqueID].AssetData;
                }

                if (Archive.ContainsEntry(new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.Stings)))
                {
                    UniqueFileID UniqueID = new UniqueFileID((uint)TypeID, ID, (uint)GroupIDs.Stings);
                    Data = Archive.GrabEntry(UniqueID);

                    if (!m_Assets.ContainsKey(UniqueID.UniqueID))
                    {
                        if (IsUTK(Data))
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new UTKFile2(Data)));
                        else
                            AddItem(UniqueID.UniqueID, new Asset(UniqueID.UniqueID, (uint)Data.Length, new XAFile(Data)));
                    }

                    return m_Assets[UniqueID.UniqueID].AssetData;
                }
            }

            return null;
        }
        /// <summary>
        /// Gets an TRK instance from the FileManager.
        /// </summary>
        /// <param name="ID">The FileID/InstanceID of the track to get.</param>
        /// <returns>A new TRK instance.</returns>
        public static TRK GetTRK(uint ID)
        {
            UniqueFileID UID = new UniqueFileID((uint)TypeIDs.TRK, ID);

            if (m_Assets.ContainsKey(UID.UniqueID))
            {
                m_AssetsResetEvent.WaitOne();
                return (TRK)m_Assets[UID.UniqueID].AssetData;
            }

            return (TRK)GrabItem(UID.FileID, TypeIDs.TRK);
        }
        /// <summary>
        /// Gets a sound (XA or UTK) from the FileManager.
        /// </summary>
        /// <param name="ID">The FileID/InstanceID of the sound to get.</param>
        /// <returns>A new ISoundCodec instance.</returns>
        public static ISoundCodec GetSound(uint ID)
        {
            UniqueFileID UID = new UniqueFileID((uint)TypeIDs.UTK, ID);

            if (m_Assets.ContainsKey(UID.UniqueID))
            {
                m_AssetsResetEvent.WaitOne();
                return (ISoundCodec)m_Assets[UID.UniqueID].AssetData;
            }

            UID = new UniqueFileID((uint)TypeIDs.XA, ID);

            if (m_Assets.ContainsKey(UID.UniqueID))
            {
                m_AssetsResetEvent.WaitOne();
                return (ISoundCodec)m_Assets[UID.UniqueID].AssetData;
            }

            UID = new UniqueFileID((uint)TypeIDs.SoundFX, ID);

            if (m_Assets.ContainsKey(UID.UniqueID))
            {
                m_AssetsResetEvent.WaitOne();
                return (ISoundCodec)m_Assets[UID.UniqueID].AssetData;
            }

            ISoundCodec Data = (ISoundCodec)GrabItem(ID, TypeIDs.UTK);

            if (Data == null)
                Data = (ISoundCodec)GrabItem(ID, TypeIDs.XA);
            if(Data == null)
                Data = (ISoundCodec)GrabItem(ID, TypeIDs.SoundFX);

            return Data;
        }