コード例 #1
0
    private bool ShouldUseSidewaysSymbol(KBatchedAnimController controller)
    {
        KAnim.Anim currentAnim = controller.GetCurrentAnim();
        if (currentAnim == null)
        {
            return(false);
        }
        int currentFrameIndex = controller.GetCurrentFrameIndex();

        if (currentFrameIndex <= 0)
        {
            return(false);
        }
        KBatchGroupData batchGroupData = KAnimBatchManager.Instance().GetBatchGroupData(currentAnim.animFile.animBatchTag);

        KAnim.Anim.Frame frame = batchGroupData.GetFrame(currentFrameIndex);
        for (int i = 0; i < frame.numElements; i++)
        {
            KAnim.Anim.FrameElement frameElement = batchGroupData.GetFrameElement(frame.firstElementIdx + i);
            if (frameElement.symbol == HASH_SNAPTO_EYES && frameElement.frame >= FIRST_SIDEWAYS_FRAME)
            {
                return(true);
            }
        }
        return(false);
    }
コード例 #2
0
        /// <summary>
        /// Compares two animation frames.
        /// </summary>
        /// <param name="groupData">The group data to retrieve the frame elements.</param>
        /// <param name="a">The first frame.</param>
        /// <param name="b">The second frame.</param>
        /// <returns>true if they are equal, or false otherwise.</returns>
        private static bool CompareFrames(KBatchGroupData groupData, ref KAnim.Anim.Frame a,
                                          ref KAnim.Anim.Frame b)
        {
            // Each element specifies a frame from a particular symbol, position, tint, and
            // flags
            int  ne    = a.numElements;
            bool equal = ne == b.numElements;

            if (equal)
            {
                int startA = a.firstElementIdx, startB = b.firstElementIdx;
                // If they point to the same elements, they are automatically equal
                if (startA != startB)
                {
                    for (int i = 0; i < ne && equal; i++)
                    {
                        var   elementA = groupData.GetFrameElement(i + startA);
                        var   elementB = groupData.GetFrameElement(i + startB);
                        Color colorA = elementA.multColour, colorB = elementB.multColour;
                        equal = elementA.symbol == elementB.symbol && colorA == colorB &&
                                elementA.symbolIdx == elementB.symbolIdx && elementA.flags ==
                                elementB.flags && elementA.transform == elementB.transform &&
                                elementA.frame == elementB.frame;
                    }
                }
            }
            return(equal);
        }
コード例 #3
0
            public SymbolFrameInstance GetFrame(int frame)
            {
                int             frameIdx       = GetFrameIdx(frame);
                KBatchGroupData batchGroupData = KAnimBatchManager.Instance().GetBatchGroupData(build.batchTag);

                return(batchGroupData.GetSymbolFrameInstance(frameIdx));
            }
コード例 #4
0
        private static KBatchGroupData GetAnimBatchGroupData(KAnimFileData animFile)
        {
            if (!animFile.batchTag.IsValid)
            {
                Debug.LogErrorFormat("Invalid batchTag for anim [{0}]", animFile.name);
            }
            Debug.Assert(animFile.batchTag.IsValid, "Invalid batch tag");
            KAnimGroupFile.Group group = KAnimGroupFile.GetGroup(animFile.batchTag);
            if (group == null)
            {
                Debug.LogErrorFormat("Null group for tag [{0}]", animFile.batchTag);
            }
            HashedString    hashedString    = animFile.batchTag;
            KBatchGroupData kBatchGroupData = null;

            if (group.renderType == KAnimBatchGroup.RendererType.DontRender || group.renderType == KAnimBatchGroup.RendererType.AnimOnly)
            {
                if (!group.swapTarget.IsValid)
                {
                    Debug.LogErrorFormat("Invalid swap target for group [{0}]", group.id);
                }
                hashedString = group.swapTarget;
            }
            kBatchGroupData = KAnimBatchManager.Instance().GetBatchGroupData(hashedString);
            if (kBatchGroupData == null)
            {
                Debug.LogErrorFormat("Null batch group for tag [{0}]", hashedString);
            }
            return(kBatchGroupData);
        }
コード例 #5
0
        public Texture2D GetTexture(int index)
        {
            if (index < 0 || index >= textureCount)
            {
                Debug.LogError("Invalid texture index:" + index);
            }
            KBatchGroupData batchGroupData = KAnimBatchManager.Instance().GetBatchGroupData(batchTag);

            return(batchGroupData.GetTexure(textureStartIdx + index));
        }
コード例 #6
0
    private void ApplyShape(KAnim.Build.Symbol variation_symbol, KBatchedAnimController controller, KAnimFile shapes_file, HashedString symbol_name_in_shape_file, bool should_use_sideways_symbol)
    {
        HashedString hashedString = HASH_NEUTRAL;

        if (currentExpression != null)
        {
            hashedString = currentExpression.face.hash;
        }
        KAnim.Anim anim = null;
        KAnim.Anim.FrameElement frameElement = default(KAnim.Anim.FrameElement);
        bool flag  = false;
        bool flag2 = false;

        for (int i = 0; i < shapes_file.GetData().animCount; i++)
        {
            if (flag)
            {
                break;
            }
            KAnim.Anim anim2 = shapes_file.GetData().GetAnim(i);
            if (anim2.hash == hashedString)
            {
                anim = anim2;
                KAnim.Anim.Frame frame = anim.GetFrame(shapes_file.GetData().build.batchTag, 0);
                for (int j = 0; j < frame.numElements; j++)
                {
                    KBatchGroupData batchGroupData = KAnimBatchManager.Instance().GetBatchGroupData(shapes_file.GetData().animBatchTag);
                    frameElement = batchGroupData.GetFrameElement(frame.firstElementIdx + j);
                    if (!(frameElement.symbol != symbol_name_in_shape_file))
                    {
                        if (flag2 || !should_use_sideways_symbol)
                        {
                            flag = true;
                        }
                        flag2 = true;
                        break;
                    }
                }
            }
        }
        if (anim == null)
        {
            DebugUtil.Assert(false, "Could not find shape for expression: " + HashCache.Get().Get(hashedString));
        }
        if (!flag2)
        {
            DebugUtil.Assert(false, "Could not find shape element for shape:" + HashCache.Get().Get(variation_symbol.hash));
        }
        KAnim.Build.Symbol symbol          = KAnimBatchManager.Instance().GetBatchGroupData(controller.batchGroupID).GetSymbol(symbol_name_in_shape_file);
        KBatchGroupData    batchGroupData2 = KAnimBatchManager.Instance().GetBatchGroupData(variation_symbol.build.batchTag);

        KAnim.Build.SymbolFrameInstance symbol_frame_instance = batchGroupData2.symbolFrameInstances[variation_symbol.firstFrameIdx + frameElement.frame];
        symbol_frame_instance.buildImageIdx = GetComponent <SymbolOverrideController>().GetAtlasIdx(variation_symbol.build.GetTexture(0));
        controller.SetSymbolOverride(symbol.firstFrameIdx, symbol_frame_instance);
    }
コード例 #7
0
    public override KAnim.Anim GetAnim(int index)
    {
        if (!batchGroupID.IsValid || !(batchGroupID != KAnimBatchManager.NO_BATCH))
        {
            Debug.LogError(base.name + " batch not ready");
        }
        KBatchGroupData batchGroupData = KAnimBatchManager.Instance().GetBatchGroupData(batchGroupID);

        Debug.Assert(batchGroupData != null);
        return(batchGroupData.GetAnim(index));
    }
コード例 #8
0
    public KAnim.Anim.FrameElement GetAnimFrameElement(int index)
    {
        Debug.Assert(index >= 0 && index < elementCount);
        KBatchGroupData batchGroupData = KAnimBatchManager.Instance().GetBatchGroupData(animBatchTag);

        if (batchGroupData == null)
        {
            Debug.LogErrorFormat("[{0}] No such batch group [{1}]", name, animBatchTag.ToString());
        }
        return(batchGroupData.GetFrameElement(firstElementIndex + index));
    }
コード例 #9
0
    public KAnim.Anim GetAnim(int index)
    {
        Debug.Assert(index >= 0 && index < animCount);
        KBatchGroupData batchGroupData = KAnimBatchManager.Instance().GetBatchGroupData(animBatchTag);

        if (batchGroupData == null)
        {
            Debug.LogError($"[{name}] No such batch group [{animBatchTag.ToString()}]");
        }
        return(batchGroupData.GetAnim(index + firstAnimIndex));
    }
コード例 #10
0
    public KBatchGroupData GetBatchGroupData(HashedString groupID)
    {
        if (!groupID.IsValid || groupID == NO_BATCH || groupID == IGNORE)
        {
            return(null);
        }
        KBatchGroupData value = null;

        if (!batchGroupData.TryGetValue(groupID, out value))
        {
            value = new KBatchGroupData(groupID);
            batchGroupData[groupID] = value;
        }
        return(value);
    }
コード例 #11
0
 public void LoadAll()
 {
     Debug.Assert(!hasCompletedLoadAll, "You cannot load all the anim data twice!");
     fileData.Clear();
     for (int i = 0; i < groups.Count; i++)
     {
         if (!groups[i].id.IsValid)
         {
             Debug.LogErrorFormat("Group invalid groupIndex [{0}]", i);
         }
         KBatchGroupData kBatchGroupData = null;
         kBatchGroupData = ((!groups[i].target.IsValid) ? KAnimBatchManager.Instance().GetBatchGroupData(groups[i].id) : KAnimBatchManager.Instance().GetBatchGroupData(groups[i].target));
         HashedString batchTag = groups[i].id;
         if (groups[i].renderType == KAnimBatchGroup.RendererType.AnimOnly)
         {
             if (!groups[i].swapTarget.IsValid)
             {
                 continue;
             }
             kBatchGroupData = KAnimBatchManager.Instance().GetBatchGroupData(groups[i].swapTarget);
             batchTag        = groups[i].swapTarget;
         }
         for (int j = 0; j < groups[i].files.Count; j++)
         {
             KAnimFile kAnimFile = groups[i].files[j];
             if ((UnityEngine.Object)kAnimFile != (UnityEngine.Object)null && kAnimFile.buildBytes != null && !fileData.ContainsKey(kAnimFile.GetInstanceID()))
             {
                 if (kAnimFile.buildBytes.Length == 0)
                 {
                     Debug.LogWarning("Build File [" + kAnimFile.GetData().name + "] has 0 bytes");
                 }
                 else
                 {
                     HashedString hash = new HashedString(kAnimFile.name);
                     HashCache.Get().Add(hash.HashValue, kAnimFile.name);
                     KAnimFileData file = KGlobalAnimParser.Get().GetFile(kAnimFile);
                     file.maxVisSymbolFrames = 0;
                     file.batchTag           = batchTag;
                     file.buildIndex         = KGlobalAnimParser.ParseBuildData(kBatchGroupData, hash, new FastReader(kAnimFile.buildBytes), kAnimFile.textureList);
                     fileData.Add(kAnimFile.GetInstanceID(), file);
                 }
             }
         }
     }
     for (int k = 0; k < groups.Count; k++)
     {
         if (groups[k].renderType == KAnimBatchGroup.RendererType.AnimOnly)
         {
             KBatchGroupData batchGroupData  = KAnimBatchManager.Instance().GetBatchGroupData(groups[k].swapTarget);
             KBatchGroupData batchGroupData2 = KAnimBatchManager.Instance().GetBatchGroupData(groups[k].animTarget);
             for (int l = 0; l < batchGroupData.builds.Count; l++)
             {
                 KAnim.Build build = batchGroupData.builds[l];
                 if (build != null && build.symbols != null)
                 {
                     for (int m = 0; m < build.symbols.Length; m++)
                     {
                         KAnim.Build.Symbol symbol = build.symbols[m];
                         if (symbol != null && symbol.hash.IsValid() && batchGroupData2.GetFirstIndex(symbol.hash) == -1)
                         {
                             KAnim.Build.Symbol symbol2 = new KAnim.Build.Symbol();
                             symbol2.build                    = build;
                             symbol2.hash                     = symbol.hash;
                             symbol2.path                     = symbol.path;
                             symbol2.colourChannel            = symbol.colourChannel;
                             symbol2.flags                    = symbol.flags;
                             symbol2.firstFrameIdx            = batchGroupData2.symbolFrameInstances.Count;
                             symbol2.numFrames                = symbol.numFrames;
                             symbol2.symbolIndexInSourceBuild = batchGroupData2.frameElementSymbols.Count;
                             for (int n = 0; n < symbol2.numFrames; n++)
                             {
                                 KAnim.Build.SymbolFrameInstance symbolFrameInstance = batchGroupData.GetSymbolFrameInstance(n + symbol.firstFrameIdx);
                                 KAnim.Build.SymbolFrameInstance item = default(KAnim.Build.SymbolFrameInstance);
                                 item.symbolFrame   = symbolFrameInstance.symbolFrame;
                                 item.buildImageIdx = -1;
                                 item.symbolIdx     = batchGroupData2.GetSymbolCount();
                                 batchGroupData2.symbolFrameInstances.Add(item);
                             }
                             batchGroupData2.AddBuildSymbol(symbol2);
                         }
                     }
                 }
             }
         }
     }
     for (int num = 0; num < groups.Count; num++)
     {
         if (!groups[num].id.IsValid)
         {
             Debug.LogErrorFormat("Group invalid groupIndex [{0}]", num);
         }
         if (groups[num].renderType != KAnimBatchGroup.RendererType.DontRender)
         {
             KBatchGroupData kBatchGroupData2 = null;
             if (groups[num].animTarget.IsValid)
             {
                 kBatchGroupData2 = KAnimBatchManager.Instance().GetBatchGroupData(groups[num].animTarget);
                 if (kBatchGroupData2 == null)
                 {
                     Debug.LogErrorFormat("Anim group is null for [{0}] -> [{1}]", groups[num].id, groups[num].animTarget);
                 }
             }
             else
             {
                 kBatchGroupData2 = KAnimBatchManager.Instance().GetBatchGroupData(groups[num].id);
                 if (kBatchGroupData2 == null)
                 {
                     Debug.LogErrorFormat("Anim group is null for [{0}]", groups[num].id);
                 }
             }
             for (int num2 = 0; num2 < groups[num].files.Count; num2++)
             {
                 KAnimFile kAnimFile2 = groups[num].files[num2];
                 if ((UnityEngine.Object)kAnimFile2 != (UnityEngine.Object)null && kAnimFile2.animBytes != null)
                 {
                     if (kAnimFile2.animBytes.Length == 0)
                     {
                         Debug.LogWarning("Anim File [" + kAnimFile2.GetData().name + "] has 0 bytes");
                     }
                     else
                     {
                         if (!fileData.ContainsKey(kAnimFile2.GetInstanceID()))
                         {
                             KAnimFileData file2 = KGlobalAnimParser.Get().GetFile(kAnimFile2);
                             file2.maxVisSymbolFrames = 0;
                             file2.batchTag           = groups[num].id;
                             fileData.Add(kAnimFile2.GetInstanceID(), file2);
                         }
                         HashedString  fileNameHash = new HashedString(kAnimFile2.name);
                         FastReader    reader       = new FastReader(kAnimFile2.animBytes);
                         KAnimFileData animFile     = fileData[kAnimFile2.GetInstanceID()];
                         KGlobalAnimParser.ParseAnimData(kBatchGroupData2, fileNameHash, reader, animFile);
                     }
                 }
             }
         }
     }
     for (int num3 = 0; num3 < groups.Count; num3++)
     {
         if (!groups[num3].id.IsValid)
         {
             Debug.LogErrorFormat("Group invalid groupIndex [{0}]", num3);
         }
         KBatchGroupData kBatchGroupData3 = null;
         if (groups[num3].target.IsValid)
         {
             kBatchGroupData3 = KAnimBatchManager.Instance().GetBatchGroupData(groups[num3].target);
             if (kBatchGroupData3 == null)
             {
                 Debug.LogErrorFormat("Group is null for  [{0}] target [{1}]", groups[num3].id, groups[num3].target);
             }
         }
         else
         {
             kBatchGroupData3 = KAnimBatchManager.Instance().GetBatchGroupData(groups[num3].id);
             if (kBatchGroupData3 == null)
             {
                 Debug.LogErrorFormat("Group is null for [{0}]", groups[num3].id);
             }
         }
         KGlobalAnimParser.PostParse(kBatchGroupData3);
     }
     hasCompletedLoadAll = true;
 }
コード例 #12
0
    public static void ParseAnimData(KBatchGroupData data, HashedString fileNameHash, FastReader reader, KAnimFileData animFile)
    {
        CheckHeader("ANIM", reader);
        uint num = reader.ReadUInt32();

        Assert(num == 5, "Invalid anim.bytes version");
        reader.ReadInt32();
        reader.ReadInt32();
        int num2 = reader.ReadInt32();

        animFile.maxVisSymbolFrames = 0;
        animFile.animCount          = 0;
        animFile.frameCount         = 0;
        animFile.elementCount       = 0;
        animFile.firstAnimIndex     = data.anims.Count;
        animFile.animBatchTag       = data.groupID;
        data.animIndex.Add(fileNameHash, data.anims.Count);
        animFile.firstElementIndex = data.frameElements.Count;
        for (int i = 0; i < num2; i++)
        {
            KAnim.Anim anim = new KAnim.Anim(animFile, data.anims.Count);
            anim.name = reader.ReadKleiString();
            string text = animFile.name + "." + anim.name;
            anim.id = text;
            HashCache.Get().Add(anim.name);
            HashCache.Get().Add(text);
            anim.hash = anim.name;
            anim.rootSymbol.HashValue = reader.ReadInt32();
            anim.frameRate            = reader.ReadSingle();
            anim.firstFrameIdx        = data.animFrames.Count;
            anim.numFrames            = reader.ReadInt32();
            anim.totalTime            = (float)anim.numFrames / anim.frameRate;
            anim.scaledBoundingRadius = 0f;
            for (int j = 0; j < anim.numFrames; j++)
            {
                KAnim.Anim.Frame item = default(KAnim.Anim.Frame);
                float            num3 = reader.ReadSingle();
                float            num4 = reader.ReadSingle();
                float            num5 = reader.ReadSingle();
                float            num6 = reader.ReadSingle();
                item.bbox = new AABB3(new Vector3(num3 - num5 * 0.5f, 0f - (num4 + num6 * 0.5f), 0f) * 0.005f, new Vector3(num3 + num5 * 0.5f, 0f - (num4 - num6 * 0.5f), 0f) * 0.005f);
                float num7 = Math.Max(Math.Abs(item.bbox.max.x), Math.Abs(item.bbox.min.x));
                float num8 = Math.Max(Math.Abs(item.bbox.max.y), Math.Abs(item.bbox.min.y));
                float num9 = Math.Max(num7, num8);
                anim.unScaledSize.x       = Math.Max(anim.unScaledSize.x, num7 / 0.005f);
                anim.unScaledSize.y       = Math.Max(anim.unScaledSize.y, num8 / 0.005f);
                anim.scaledBoundingRadius = Math.Max(anim.scaledBoundingRadius, Mathf.Sqrt(num9 * num9 + num9 * num9));
                item.idx             = data.animFrames.Count;
                item.firstElementIdx = data.frameElements.Count;
                item.numElements     = reader.ReadInt32();
                int num10 = 0;
                for (int k = 0; k < item.numElements; k++)
                {
                    KAnim.Anim.FrameElement item2 = default(KAnim.Anim.FrameElement);
                    item2.fileHash = fileNameHash;
                    item2.symbol   = new KAnimHashedString(reader.ReadInt32());
                    item2.frame    = reader.ReadInt32();
                    item2.folder   = new KAnimHashedString(reader.ReadInt32());
                    item2.flags    = reader.ReadInt32();
                    float a = reader.ReadSingle();
                    float b = reader.ReadSingle();
                    float g = reader.ReadSingle();
                    float r = reader.ReadSingle();
                    item2.multColour = new Color(r, g, b, a);
                    float m  = reader.ReadSingle();
                    float m2 = reader.ReadSingle();
                    float m3 = reader.ReadSingle();
                    float m4 = reader.ReadSingle();
                    float m5 = reader.ReadSingle();
                    float m6 = reader.ReadSingle();
                    reader.ReadSingle();
                    item2.transform.m00 = m;
                    item2.transform.m01 = m3;
                    item2.transform.m02 = m5;
                    item2.transform.m10 = m2;
                    item2.transform.m11 = m4;
                    item2.transform.m12 = m6;
                    int symbolIndex = data.GetSymbolIndex(item2.symbol);
                    if (symbolIndex == -1)
                    {
                        num10++;
                        item2.symbol = MISSING_SYMBOL;
                    }
                    else
                    {
                        item2.symbolIdx = symbolIndex;
                        data.frameElements.Add(item2);
                        animFile.elementCount++;
                    }
                }
                item.numElements -= num10;
                data.animFrames.Add(item);
                animFile.frameCount++;
            }
            data.AddAnim(anim);
            animFile.animCount++;
        }
        Debug.Assert(num2 == animFile.animCount);
        data.animCount[fileNameHash] = animFile.animCount;
        animFile.maxVisSymbolFrames  = Math.Max(animFile.maxVisSymbolFrames, reader.ReadInt32());
        data.UpdateMaxVisibleSymbols(animFile.maxVisSymbolFrames);
        ParseHashTable(reader);
    }
コード例 #13
0
 public static void PostParse(KBatchGroupData data)
 {
     for (int i = 0; i < data.GetSymbolCount(); i++)
     {
         KAnim.Build.Symbol symbol = data.GetSymbol(i);
         if (symbol == null)
         {
             Debug.LogWarning("Symbol null for [" + data.groupID + "] idx: [" + i + "]");
         }
         else
         {
             if (symbol.numLookupFrames <= 0)
             {
                 int num = symbol.numFrames;
                 for (int j = symbol.firstFrameIdx; j < symbol.firstFrameIdx + symbol.numFrames; j++)
                 {
                     KAnim.Build.SymbolFrameInstance symbolFrameInstance = data.GetSymbolFrameInstance(j);
                     num = Mathf.Max(num, symbolFrameInstance.symbolFrame.sourceFrameNum + symbolFrameInstance.symbolFrame.duration);
                 }
                 symbol.numLookupFrames = num;
             }
             symbol.frameLookup = new int[symbol.numLookupFrames];
             if (symbol.numLookupFrames <= 0)
             {
                 Debug.LogWarning("No lookup frames for  [" + data.groupID + "] build: [" + symbol.build.name + "] idx: [" + i + "] id: [" + symbol.hash + "]");
             }
             else
             {
                 for (int k = 0; k < symbol.numLookupFrames; k++)
                 {
                     symbol.frameLookup[k] = -1;
                 }
                 for (int l = symbol.firstFrameIdx; l < symbol.firstFrameIdx + symbol.numFrames; l++)
                 {
                     KAnim.Build.SymbolFrameInstance symbolFrameInstance2 = data.GetSymbolFrameInstance(l);
                     if (symbolFrameInstance2.symbolFrame == null)
                     {
                         Debug.LogWarning("No symbol frame  [" + data.groupID + "] symFrameIdx: [" + l + "] id: [" + symbol.hash + "]");
                     }
                     else
                     {
                         for (int m = symbolFrameInstance2.symbolFrame.sourceFrameNum; m < symbolFrameInstance2.symbolFrame.sourceFrameNum + symbolFrameInstance2.symbolFrame.duration; m++)
                         {
                             if (m >= symbol.frameLookup.Length)
                             {
                                 Debug.LogWarning("Too many lookup frames [" + m + ">=" + symbol.frameLookup.Length + "] for  [" + data.groupID + "] idx: [" + i + "] id: [" + symbol.hash + "]");
                             }
                             else
                             {
                                 symbol.frameLookup[m] = l;
                             }
                         }
                     }
                 }
                 string text = HashCache.Get().Get(symbol.path);
                 if (!string.IsNullOrEmpty(text))
                 {
                     int num2 = text.IndexOf("/");
                     if (num2 != -1)
                     {
                         string text2 = text.Substring(0, num2);
                         symbol.folder = new KAnimHashedString(text2);
                         HashCache.Get().Add(symbol.folder.HashValue, text2);
                     }
                 }
             }
         }
     }
 }
コード例 #14
0
    public static int ParseBuildData(KBatchGroupData data, KAnimHashedString fileNameHash, FastReader reader, List <Texture2D> textures)
    {
        CheckHeader("BILD", reader);
        int num = reader.ReadInt32();

        if (num != 10 && num != 9)
        {
            Debug.LogError(fileNameHash + " has invalid build.bytes version [" + num + "]");
            return(-1);
        }
        KAnimGroupFile.Group group = KAnimGroupFile.GetGroup(data.groupID);
        if (group == null)
        {
            Debug.LogErrorFormat("[{1}] Failed to get group [{0}]", data.groupID, fileNameHash.DebuggerDisplay);
        }
        KAnim.Build build = null;
        int         num2  = reader.ReadInt32();
        int         num3  = reader.ReadInt32();

        build = data.AddNewBuildFile(fileNameHash);
        build.textureCount = textures.Count;
        if (textures.Count > 0)
        {
            data.AddTextures(textures);
        }
        build.symbols  = new KAnim.Build.Symbol[num2];
        build.frames   = new KAnim.Build.SymbolFrame[num3];
        build.name     = reader.ReadKleiString();
        build.batchTag = ((!group.swapTarget.IsValid) ? data.groupID : group.target);
        build.fileHash = fileNameHash;
        int num4 = 0;

        for (int i = 0; i < build.symbols.Length; i++)
        {
            KAnimHashedString  hash   = new KAnimHashedString(reader.ReadInt32());
            KAnim.Build.Symbol symbol = new KAnim.Build.Symbol();
            symbol.build = build;
            symbol.hash  = hash;
            if (num > 9)
            {
                symbol.path = new KAnimHashedString(reader.ReadInt32());
            }
            symbol.colourChannel            = new KAnimHashedString(reader.ReadInt32());
            symbol.flags                    = reader.ReadInt32();
            symbol.firstFrameIdx            = data.symbolFrameInstances.Count;
            symbol.numFrames                = reader.ReadInt32();
            symbol.symbolIndexInSourceBuild = i;
            int num5 = 0;
            for (int j = 0; j < symbol.numFrames; j++)
            {
                KAnim.Build.SymbolFrame         symbolFrame = new KAnim.Build.SymbolFrame();
                KAnim.Build.SymbolFrameInstance item        = default(KAnim.Build.SymbolFrameInstance);
                item.symbolFrame           = symbolFrame;
                symbolFrame.fileNameHash   = fileNameHash;
                symbolFrame.sourceFrameNum = reader.ReadInt32();
                symbolFrame.duration       = reader.ReadInt32();
                item.buildImageIdx         = data.textureStartIndex[fileNameHash] + reader.ReadInt32();
                if (item.buildImageIdx >= textures.Count + data.textureStartIndex[fileNameHash])
                {
                    Debug.LogErrorFormat("{0} Symbol: [{1}] tex count: [{2}] buildImageIdx: [{3}] group total [{4}]", fileNameHash.ToString(), symbol.hash, textures.Count, item.buildImageIdx, data.textureStartIndex[fileNameHash]);
                }
                item.symbolIdx = data.GetSymbolCount();
                num5           = Math.Max(symbolFrame.sourceFrameNum + symbolFrame.duration, num5);
                float num6 = reader.ReadSingle();
                float num7 = reader.ReadSingle();
                float num8 = reader.ReadSingle();
                float num9 = reader.ReadSingle();
                symbolFrame.bboxMin = new Vector2(num6 - num8 * 0.5f, num7 - num9 * 0.5f);
                symbolFrame.bboxMax = new Vector2(num6 + num8 * 0.5f, num7 + num9 * 0.5f);
                float x     = reader.ReadSingle();
                float num10 = reader.ReadSingle();
                float x2    = reader.ReadSingle();
                float num11 = reader.ReadSingle();
                symbolFrame.uvMin  = new Vector2(x, 1f - num10);
                symbolFrame.uvMax  = new Vector2(x2, 1f - num11);
                build.frames[num4] = symbolFrame;
                data.symbolFrameInstances.Add(item);
                num4++;
            }
            symbol.numLookupFrames = num5;
            data.AddBuildSymbol(symbol);
            build.symbols[i] = symbol;
        }
        ParseHashTable(reader);
        return(build.index);
    }
コード例 #15
0
        public Frame GetFrame(HashedString batchTag, int idx)
        {
            KBatchGroupData batchGroupData = KAnimBatchManager.Instance().GetBatchGroupData(batchTag);

            return(batchGroupData.GetFrame(idx + firstFrameIdx));
        }
コード例 #16
0
    public KAnim.Anim.FrameElement FindAnimFrameElement(KAnimHashedString symbolName)
    {
        KBatchGroupData batchGroupData = KAnimBatchManager.Instance().GetBatchGroupData(animBatchTag);

        return(batchGroupData.frameElements.Find((KAnim.Anim.FrameElement match) => match.symbol == symbolName));
    }