public void Sync(KAnimControllerBase controller)
 {
     if (!((Object)masterController == (Object)null) && !((Object)controller == (Object)null))
     {
         KAnim.Anim currentAnim = masterController.GetCurrentAnim();
         if (currentAnim != null)
         {
             KAnim.PlayMode mode        = masterController.GetMode();
             float          playSpeed   = masterController.GetPlaySpeed();
             float          elapsedTime = masterController.GetElapsedTime();
             controller.Play(currentAnim.name, mode, playSpeed, elapsedTime);
             Facing component = controller.GetComponent <Facing>();
             if ((Object)component != (Object)null)
             {
                 Vector3 position = component.transform.GetPosition();
                 float   x        = position.x;
                 x += ((!masterController.FlipX) ? 0.5f : (-0.5f));
                 component.Face(x);
             }
             else
             {
                 controller.FlipX = masterController.FlipX;
                 controller.FlipY = masterController.FlipY;
             }
         }
     }
 }
示例#2
0
        /// <summary>
        /// Applied before IsStopped runs.
        /// </summary>
        internal static bool Prefix(KAnimControllerBase __instance, ref bool __result)
        {
            bool stopped = __instance.stopped;

            if (stopped)
            {
                var anim = __instance.GetCurrentAnim();
                var mode = __instance.GetMode();
                var inst = KAnimLoopOptimizer.Instance;
                // The desalinator is the stress test for this, it does an anim queue complete
                // wait on a trivial kanim... Clay please!
                if (anim != null && mode == KAnim.PlayMode.Paused && anim.numFrames > 0 &&
                    __instance.currentFrame == 0 && inst != null && inst.GetAnimState(anim,
                                                                                      KAnim.PlayMode.Loop) == mode)
                {
                    stopped = false;
                }
            }
            __result = stopped;
            return(false);
        }
示例#3
0
        /// <summary>
        /// Adjusts the play mode if the anim is trivial.
        /// </summary>
        internal static KAnim.PlayMode UpdateMode(KAnim.PlayMode mode,
                                                  KAnimControllerBase controller)
        {
            var anim = controller.GetCurrentAnim();
            var inst = KAnimLoopOptimizer.Instance;

            if (anim != null && mode == KAnim.PlayMode.Loop && inst != null && controller.
                animQueue.Count == 0)
            {
                // Will set "paused" only if the anim is so short as to be unnoticeable
                mode = inst.GetAnimState(anim, mode);
                if (mode == KAnim.PlayMode.Paused)
                {
                    // Trigger an instant stop
                    controller.Stop();
                    controller.currentFrame = 0;
                    controller.SetElapsedTime(0.0f);
                    PathPatches.DeferAnimQueueTrigger.TriggerAndQueue(controller,
                                                                      (int)GameHashes.AnimQueueComplete, null);
                }
            }
            return(mode);
        }