GetAnimLength() public static method

Actioncount of given Body in given anim file
public static GetAnimLength ( int body, int fileType ) : int
body int
fileType int
return int
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
0
        public bool IsActionDefinied(int filetype, int body, int action)
        {
            AnimIdx[] cache = GetCache(filetype);
            FileIndex fileIndex;
            int       index;

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

            if (cache != null)
            {
                if (cache[index] != null)
                {
                    if ((cache[index].Frames != null) && (cache[index].Frames.Count > 0))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            int AnimCount = _Animations.GetAnimLength(body, filetype);

            if (AnimCount < action)
            {
                return(false);
            }

            int  length, extra;
            bool patched;
            bool valid = fileIndex.Valid(index, out length, out extra, out patched);

            if ((!valid) || (length < 1))
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static void ExportToVD(int filetype, int body, string file)
        {
            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);

                    ExportToVD(filetype, body, bin);
                }
            }
        }
Ejemplo n.º 5
0
 public static bool IsAnimDefinied(int body, int fileType)
 {
     for (int a = 0; a < Animations.GetAnimLength(body, fileType); ++a)
     {
         for (int d = 0; d < 5; ++d)
         {
             if (IsAnimDefinied(body, a, d, fileType))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 6
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);
                }
            }
        }
Ejemplo n.º 7
0
        public static bool IsActionDefined(int fileType, int body, int action)
        {
            AnimIdx[] cache = GetCache(fileType);

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

            if (cache?[index] != null)
            {
                return(cache[index].Frames?.Count > 0);
            }

            int animCount = Animations.GetAnimLength(body, fileType);

            if (animCount < action)
            {
                return(false);
            }

            bool valid = fileIndex.Valid(index, out int length, out int _, out bool _);

            return(valid && length >= 1);
        }
Ejemplo n.º 8
0
        public static bool IsActionDefinied(int filetype, int body, int action)
        {
            var cache = GetCache(filetype);

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

            if (cache != null)
            {
                if (cache[index] != null)
                {
                    if ((cache[index].Frames != null) && (cache[index].Frames.Count > 0))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            var AnimCount = Animations.GetAnimLength(body, filetype);

            if (AnimCount < action)
            {
                return(false);
            }

            var valid = fileIndex.Valid(index, out var length, out var extra, out var patched);

            if ((!valid) || (length < 1))
            {
                return(false);
            }

            return(true);
        }