Пример #1
0
        public static void LoadFromVD(int filetype, int body, BinaryReader bin)
        {
            AnimIdx[] cache = GetCache(filetype);
            FileIndex fileIndex;
            int       index;

            GetFileIndex(body, filetype, 0, 0, out fileIndex, out index);
            int animlength = Animations.GetAnimLength(body, filetype) * 5;

            Entry3D[] entries = new Entry3D[animlength];

            for (int i = 0; i < animlength; ++i)
            {
                entries[i].lookup = bin.ReadInt32();
                entries[i].length = bin.ReadInt32();
                entries[i].extra  = bin.ReadInt32();
            }

            foreach (Entry3D entry in entries)
            {
                if ((entry.lookup > 0) && (entry.lookup < bin.BaseStream.Length) && (entry.length > 0))
                {
                    bin.BaseStream.Seek(entry.lookup, SeekOrigin.Begin);
                    cache[index] = new AnimIdx(bin, entry.extra);
                }

                ++index;
            }
        }
Пример #2
0
        public static void ExportToVD(int filetype, int body, BinaryWriter bin)
        {
            AnimIdx[] cache = GetCache(filetype);
            FileIndex fileIndex;
            int index;
            GetFileIndex(body, filetype, 0, 0, out fileIndex, out index);

            int animlength = Animations.GetAnimLength(body, filetype);
            long indexpos = bin.BaseStream.Position;
            long animpos = bin.BaseStream.Position + 12 * animlength * 5;
            for (int i = index; i < index + animlength * 5; i++)
            {
                AnimIdx anim;
                if (cache != null)
                {
                    if (cache[i] != null)
                        anim = cache[i];
                    else
                        anim = cache[i] = new AnimIdx(i, fileIndex, filetype);
                }
                else
                    anim = cache[i] = new AnimIdx(i, fileIndex, filetype);

                if (anim == null)
                {
                    bin.BaseStream.Seek(indexpos, SeekOrigin.Begin);
                    bin.Write((int)-1);
                    bin.Write((int)-1);
                    bin.Write((int)-1);
                    indexpos = bin.BaseStream.Position;
                }
                else
                    anim.ExportToVD(bin, ref indexpos, ref animpos);
            }
        }
Пример #3
0
 /// <summary>
 /// Inizializza una nuova istanza della classe <see cref="T:System.Object"/>.
 /// </summary>
 public AnimationEdit(Verdata verdata, Animations animations, Files files)
 {
     this._Animations = animations;
     _files           = files;
     m_FileIndex      = new FileIndex("Anim.idx", "Anim.mul", 6, verdata, _files);
     m_FileIndex2     = new FileIndex("Anim2.idx", "Anim2.mul", -1, verdata, _files);
     m_FileIndex3     = new FileIndex("Anim3.idx", "Anim3.mul", -1, verdata, _files);
     m_FileIndex4     = new FileIndex("Anim4.idx", "Anim4.mul", -1, verdata, _files);
     m_FileIndex5     = new FileIndex("Anim5.idx", "Anim5.mul", -1, verdata, _files);
     if (m_FileIndex.IdxLength > 0)
     {
         animcache = new AnimIdx[m_FileIndex.IdxLength / 12];
     }
     if (m_FileIndex2.IdxLength > 0)
     {
         animcache = new AnimIdx[m_FileIndex2.IdxLength / 12];
     }
     if (m_FileIndex3.IdxLength > 0)
     {
         animcache = new AnimIdx[m_FileIndex3.IdxLength / 12];
     }
     if (m_FileIndex4.IdxLength > 0)
     {
         animcache = new AnimIdx[m_FileIndex4.IdxLength / 12];
     }
     if (m_FileIndex5.IdxLength > 0)
     {
         animcache = new AnimIdx[m_FileIndex5.IdxLength / 12];
     }
 }
Пример #4
0
        public static void Save(int filetype, string path)
        {
            string filename;

            AnimIdx[] cache;
            FileIndex fileindex;

            switch (filetype)
            {
            case 1: filename = "anim"; cache = animcache; fileindex = m_FileIndex; break;

            case 2: filename = "anim2"; cache = animcache2; fileindex = m_FileIndex2; break;

            case 3: filename = "anim3"; cache = animcache3; fileindex = m_FileIndex3; break;

            case 4: filename = "anim4"; cache = animcache4; fileindex = m_FileIndex4; break;

            case 5: filename = "anim5"; cache = animcache5; fileindex = m_FileIndex5; break;

            default: filename = "anim"; cache = animcache; fileindex = m_FileIndex; break;
            }
            string idx = Path.Combine(path, filename + ".idx");
            string mul = Path.Combine(path, filename + ".mul");

            using (FileStream fsidx = new FileStream(idx, FileMode.Create, FileAccess.Write, FileShare.Write),
                   fsmul = new FileStream(mul, FileMode.Create, FileAccess.Write, FileShare.Write))
            {
                using (BinaryWriter binidx = new BinaryWriter(fsidx),
                       binmul = new BinaryWriter(fsmul))
                {
                    for (int idxc = 0; idxc < cache.Length; ++idxc)
                    {
                        AnimIdx anim;
                        if (cache[idxc] != null)
                        {
                            anim = cache[idxc];
                        }
                        else
                        {
                            anim = cache[idxc] = new AnimIdx(idxc, fileindex, filetype);
                        }

                        if (anim == null)
                        {
                            // WTF? Вообще возможно ли это???
                            throw new Exception("AnimationEdit saving null error.");
                            binidx.Write((int)-1);
                            binidx.Write((int)-1);
                            binidx.Write((int)-1);
                        }
                        else
                        {
                            anim.Save(binmul, binidx);
                        }
                    }
                }
            }
        }
Пример #5
0
        public static void ExportToVD(int filetype, int body, string file)
        {
            AnimIdx[] cache = GetCache(filetype);
            FileIndex fileIndex;
            int       index;

            GetFileIndex(body, filetype, 0, 0, out fileIndex, out index);
            using (FileStream fs = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.Write))
            {
                using (BinaryWriter bin = new BinaryWriter(fs))
                {
                    bin.Write((short)6);
                    int animlength = Animations.GetAnimLength(body, filetype);
                    int currtype   = animlength == 22 ? 0 : animlength == 13 ? 1 : 2;
                    bin.Write((short)currtype);
                    long indexpos = bin.BaseStream.Position;
                    long animpos  = bin.BaseStream.Position + 12 * animlength * 5;
                    for (int i = index; i < index + animlength * 5; i++)
                    {
                        AnimIdx anim;
                        if (cache != null)
                        {
                            if (cache[i] != null)
                            {
                                anim = cache[i];
                            }
                            else
                            {
                                anim = cache[i] = new AnimIdx(i, fileIndex, filetype);
                            }
                        }
                        else
                        {
                            anim = cache[i] = new AnimIdx(i, fileIndex, filetype);
                        }

                        if (anim == null)
                        {
                            bin.BaseStream.Seek(indexpos, SeekOrigin.Begin);
                            bin.Write((int)-1);
                            bin.Write((int)-1);
                            bin.Write((int)-1);
                            indexpos = bin.BaseStream.Position;
                        }
                        else
                        {
                            anim.ExportToVD(bin, ref indexpos, ref animpos);
                        }
                    }
                }
            }
        }
Пример #6
0
        public static AnimIdx GetAnimation(int fileType, int body, int action, int dir)
        {
            AnimIdx[] cache = GetCache(fileType);

            GetFileIndex(body, fileType, action, dir, out FileIndex fileIndex, out int index);

            if (cache?[index] != null)
            {
                return(cache[index]);
            }

            return(cache[index] = new AnimIdx(index, fileIndex));
        }
Пример #7
0
        public static AnimIdx GetAnimation(int filetype, int body, int action, int dir)
        {
            var cache = GetCache(filetype);

            GetFileIndex(body, filetype, action, dir, out var fileIndex, out var index);

            if (cache != null)
            {
                if (cache[index] != null)
                {
                    return(cache[index]);
                }
            }
            return(cache[index] = new AnimIdx(index, fileIndex, filetype));
        }
Пример #8
0
        public static void ExportToVD(int filetype, int body, BinaryWriter bin)
        {
            AnimIdx[] cache = GetCache(filetype);
            FileIndex fileIndex;
            int       index;

            GetFileIndex(body, filetype, 0, 0, out fileIndex, out index);

            int  animlength = Animations.GetAnimLength(body, filetype);
            long indexpos   = bin.BaseStream.Position;
            long animpos    = bin.BaseStream.Position + 12 * animlength * 5;

            for (int i = index; i < index + animlength * 5; i++)
            {
                AnimIdx anim;
                if (cache != null)
                {
                    if (cache[i] != null)
                    {
                        anim = cache[i];
                    }
                    else
                    {
                        anim = cache[i] = new AnimIdx(i, fileIndex, filetype);
                    }
                }
                else
                {
                    anim = cache[i] = new AnimIdx(i, fileIndex, filetype);
                }

                if (anim == null)
                {
                    bin.BaseStream.Seek(indexpos, SeekOrigin.Begin);
                    bin.Write((int)-1);
                    bin.Write((int)-1);
                    bin.Write((int)-1);
                    indexpos = bin.BaseStream.Position;
                }
                else
                {
                    anim.ExportToVD(bin, ref indexpos, ref animpos);
                }
            }
        }
Пример #9
0
        public static void ExportToVD(int filetype, int body, string file)
        {
            AnimIdx[] cache = GetCache(filetype);
            FileIndex fileIndex;
            int index;
            GetFileIndex(body, filetype, 0, 0, out fileIndex, out index);
            using (FileStream fs = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.Write))
            {
                using (BinaryWriter bin = new BinaryWriter(fs))
                {
                    bin.Write((short)6);
                    int animlength = Animations.GetAnimLength(body, filetype);
                    int currtype = animlength == 22 ? 0 : animlength == 13 ? 1 : 2;
                    bin.Write((short)currtype);
                    long indexpos = bin.BaseStream.Position;
                    long animpos = bin.BaseStream.Position + 12 * animlength * 5;
                    for (int i = index; i < index + animlength * 5; i++)
                    {
                        AnimIdx anim;
                        if (cache != null)
                        {
                            if (cache[i] != null)
                                anim = cache[i];
                            else
                                anim = cache[i] = new AnimIdx(i, fileIndex, filetype);
                        }
                        else
                            anim = cache[i] = new AnimIdx(i, fileIndex, filetype);

                        if (anim == null)
                        {
                            bin.BaseStream.Seek(indexpos, SeekOrigin.Begin);
                            bin.Write((int)-1);
                            bin.Write((int)-1);
                            bin.Write((int)-1);
                            indexpos = bin.BaseStream.Position;
                        }
                        else
                            anim.ExportToVD(bin, ref indexpos, ref animpos);
                    }
                }
            }
        }
Пример #10
0
        public static AnimIdx GetAnimation(int filetype, int body, int action, int dir)
        {
            AnimIdx[] cache = GetCache(filetype);
            FileIndex fileIndex;
            int index;
            GetFileIndex(body, filetype, action, dir, out fileIndex, out index);

            if (cache != null)
            {
                if (cache[index] != null)
                    return cache[index];
            }
            return cache[index] = new AnimIdx(index, fileIndex, filetype);
        }
Пример #11
0
        public static void Save(int filetype, string path)
        {
            string filename;
            AnimIdx[] cache;
            FileIndex fileindex;
            switch (filetype)
            {
                case 1: filename = "anim"; cache = animcache; fileindex = m_FileIndex; break;
                case 2: filename = "anim2"; cache = animcache2; fileindex = m_FileIndex2; break;
                case 3: filename = "anim3"; cache = animcache3; fileindex = m_FileIndex3; break;
                case 4: filename = "anim4"; cache = animcache4; fileindex = m_FileIndex4; break;
                case 5: filename = "anim5"; cache = animcache5; fileindex = m_FileIndex5; break;
                default: filename = "anim"; cache = animcache; fileindex = m_FileIndex; break;
            }
            string idx = Path.Combine(path, filename + ".idx");
            string mul = Path.Combine(path, filename + ".mul");
            using (FileStream fsidx = new FileStream(idx, FileMode.Create, FileAccess.Write, FileShare.Write),
                              fsmul = new FileStream(mul, FileMode.Create, FileAccess.Write, FileShare.Write))
            {
                using (BinaryWriter binidx = new BinaryWriter(fsidx),
                                    binmul = new BinaryWriter(fsmul))
                {
                    for (int idxc = 0; idxc < cache.Length; ++idxc)
                    {
                        AnimIdx anim;
                        if (cache != null)
                        {
                            if (cache[idxc] != null)
                                anim = cache[idxc];
                            else
                                anim = cache[idxc] = new AnimIdx(idxc, fileindex, filetype);
                        }
                        else
                            anim = cache[idxc] = new AnimIdx(idxc, fileindex, filetype);

                        if (anim == null)
                        {
                            binidx.Write((int)-1);
                            binidx.Write((int)-1);
                            binidx.Write((int)-1);
                        }
                        else
                            anim.Save(binmul, binidx);
                    }
                }
            }
        }
Пример #12
0
        public static void LoadFromVD(int filetype, int body, BinaryReader bin)
        {
            AnimIdx[] cache = GetCache(filetype);
            FileIndex fileIndex;
            int index;
            GetFileIndex(body, filetype, 0, 0, out fileIndex, out index);
            int animlength = Animations.GetAnimLength(body, filetype) * 5;
            Entry3D[] entries = new Entry3D[animlength];

            for (int i = 0; i < animlength; ++i)
            {
                entries[i].lookup = bin.ReadInt32();
                entries[i].length = bin.ReadInt32();
                entries[i].extra = bin.ReadInt32();
            }
            foreach (Entry3D entry in entries)
            {
                if ((entry.lookup > 0) && (entry.lookup < bin.BaseStream.Length) && (entry.length > 0))
                {
                    bin.BaseStream.Seek(entry.lookup, SeekOrigin.Begin);
                    cache[index] = new AnimIdx(bin, entry.extra);
                }
                ++index;
            }
        }
Пример #13
0
        public static void Save(int filetype, string path)
        {
            string filename;

            AnimIdx[] cache;
            FileIndex fileindex;

            switch (filetype)
            {
            case 1:
                filename  = "anim";
                cache     = animcache;
                fileindex = m_FileIndex;
                break;

            case 2:
                filename  = "anim2";
                cache     = animcache2;
                fileindex = m_FileIndex2;
                break;

            case 3:
                filename  = "anim3";
                cache     = animcache3;
                fileindex = m_FileIndex3;
                break;

            case 4:
                filename  = "anim4";
                cache     = animcache4;
                fileindex = m_FileIndex4;
                break;

            case 5:
                filename  = "anim5";
                cache     = animcache5;
                fileindex = m_FileIndex5;
                break;

            default:
                filename  = "anim";
                cache     = animcache;
                fileindex = m_FileIndex;
                break;
            }
            var idx = Path.Combine(path, filename + ".idx");
            var mul = Path.Combine(path, filename + ".mul");

            using (FileStream fsidx = new FileStream(idx, FileMode.Create, FileAccess.Write, FileShare.Write),
                   fsmul = new FileStream(mul, FileMode.Create, FileAccess.Write, FileShare.Write))
            {
                using (BinaryWriter binidx = new BinaryWriter(fsidx), binmul = new BinaryWriter(fsmul))
                {
                    for (var idxc = 0; idxc < cache.Length; ++idxc)
                    {
                        AnimIdx anim;
                        if (cache != null)
                        {
                            if (cache[idxc] != null)
                            {
                                anim = cache[idxc];
                            }
                            else
                            {
                                anim = cache[idxc] = new AnimIdx(idxc, fileindex, filetype);
                            }
                        }
                        else
                        {
                            anim = cache[idxc] = new AnimIdx(idxc, fileindex, filetype);
                        }

                        if (anim == null)
                        {
                            binidx.Write(-1);
                            binidx.Write(-1);
                            binidx.Write(-1);
                        }
                        else
                        {
                            anim.Save(binmul, binidx);
                        }
                    }
                }
            }
        }