protected void StartQueuedAnim()
    {
        StopAnimEventSequence();
        previousFrame = -1;
        currentFrame  = -1;
        SuspendUpdates(false);
        stopped = false;
        OnStartQueuedAnim();
        AnimData animData = animQueue.Dequeue();

        while (animData.mode == KAnim.PlayMode.Loop && animQueue.Count > 0)
        {
            animData = animQueue.Dequeue();
        }
        if (overrideAnims == null || !overrideAnims.TryGetValue(animData.anim, out AnimLookupData value))
        {
            if (!anims.TryGetValue(animData.anim, out value))
            {
                bool flag = true;
                if ((UnityEngine.Object)showWhenMissing != (UnityEngine.Object)null)
                {
                    showWhenMissing.SetActive(true);
                }
                if (flag)
                {
                    TriggerStop();
                    return;
                }
            }
            else if ((UnityEngine.Object)showWhenMissing != (UnityEngine.Object)null)
            {
                showWhenMissing.SetActive(false);
            }
        }
        curAnim = GetAnim(value.animIndex);
        int num = 0;

        if (animData.mode == KAnim.PlayMode.Loop && randomiseLoopedOffset)
        {
            num = UnityEngine.Random.Range(0, curAnim.numFrames - 1);
        }
        prevAnimFrame   = -1;
        curAnimFrameIdx = GetFrameIdxFromOffset(num);
        currentFrame    = curAnimFrameIdx;
        mode            = animData.mode;
        playSpeed       = animData.speed * PlaySpeedMultiplier;
        SetElapsedTime((float)num / curAnim.frameRate + animData.timeOffset);
        synchronizer.Sync();
        StartAnimEventSequence();
        AnimEnter(animData.anim);
    }
Exemple #2
0
 public void HideSymbols()
 {
     if (!((Object)EntityPrefabs.Instance == (Object)null) && !isForeground)
     {
         KAnimFile[] animFiles = controller.AnimFiles;
         bool        flag      = IsAnimLayered(animFiles);
         if (flag && (Object)foregroundController == (Object)null && layer != Grid.SceneLayer.NoLayer)
         {
             GameObject gameObject = Util.KInstantiate(EntityPrefabs.Instance.ForegroundLayer, controller.gameObject, null);
             gameObject.name                = controller.name + "_fg";
             foregroundController           = gameObject.GetComponent <KAnimControllerBase>();
             foregroundController.AnimFiles = animFiles;
             foregroundController.GetLayering().SetIsForeground(true);
             foregroundController.initialAnim = controller.initialAnim;
             link = new KAnimLink(controller, foregroundController);
             Dirty();
             KAnimSynchronizer synchronizer = controller.GetSynchronizer();
             synchronizer.Add(foregroundController);
             synchronizer.Sync(foregroundController);
             float   layerZ    = Grid.GetLayerZ(layer);
             Vector3 position  = controller.gameObject.transform.GetPosition();
             Vector3 position2 = new Vector3(0f, 0f, layerZ - position.z - 0.1f);
             gameObject.transform.SetLocalPosition(position2);
             gameObject.SetActive(true);
         }
         else if (!flag && (Object)foregroundController != (Object)null)
         {
             controller.GetSynchronizer().Remove(foregroundController);
             foregroundController.gameObject.DeleteObject();
             link = null;
         }
         if ((Object)foregroundController != (Object)null)
         {
             HideSymbolsInternal();
             foregroundController.GetLayering()?.HideSymbolsInternal();
         }
     }
 }