public KAnimFileData Load(KAnimFile anim_file)
    {
        KAnimFileData value      = null;
        int           instanceID = anim_file.GetInstanceID();

        if (!files.TryGetValue(instanceID, out value))
        {
            value = GetFile(anim_file);
        }
        return(value);
    }
    public KAnimFileData GetFile(KAnimFile anim_file)
    {
        KAnimFileData value      = null;
        int           instanceID = anim_file.GetInstanceID();

        if (!files.TryGetValue(instanceID, out value))
        {
            value             = new KAnimFileData(anim_file.name);
            files[instanceID] = value;
        }
        return(value);
    }
Exemplo n.º 3
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;
 }