示例#1
0
        public static MotionTable ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((MotionTable)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader   datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                MotionTable m         = new MotionTable();
                m.Id = datReader.ReadUInt32();

                m.DefaultStyle = datReader.ReadUInt32();

                uint numStyleDefaults = datReader.ReadUInt32();
                for (uint i = 0; i < numStyleDefaults; i++)
                {
                    m.StyleDefaults.Add(datReader.ReadUInt32(), datReader.ReadUInt32());
                }

                uint numCycles = datReader.ReadUInt32();
                for (uint i = 0; i < numCycles; i++)
                {
                    uint       key = datReader.ReadUInt32();
                    MotionData md  = MotionData.Read(datReader);
                    m.Cycles.Add(key, md);
                }

                uint numModifiers = datReader.ReadUInt32();
                for (uint i = 0; i < numModifiers; i++)
                {
                    uint       key = datReader.ReadUInt32();
                    MotionData md  = MotionData.Read(datReader);
                    m.Modifiers.Add(key, md);
                }

                uint numLinks = datReader.ReadUInt32();
                for (uint i = 0; i < numLinks; i++)
                {
                    uint firstKey    = datReader.ReadUInt32();
                    uint numSubLinks = datReader.ReadUInt32();
                    Dictionary <uint, MotionData> links = new Dictionary <uint, MotionData>();
                    for (uint j = 0; j < numSubLinks; j++)
                    {
                        uint       subKey = datReader.ReadUInt32();
                        MotionData md     = MotionData.Read(datReader);
                        links.Add(subKey, md);
                    }
                    m.Links.Add(firstKey, links);
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = m;

                return(m);
            }
        }