Exemplo n.º 1
0
        public static void Step(UpdateMode updateMode)
        {
            var elapsedNormal   = 0f;
            var elapsedUnscaled = 0f;

            switch (updateMode)
            {
            case NoZ.UpdateMode.FixedUpdate:
                elapsedNormal   = Time.FixedDeltaTime;
                elapsedUnscaled = Time.FixedUnscaledDeltaTime;
                break;

            case NoZ.UpdateMode.Update:
                elapsedNormal   = Time.DeltaTime;
                elapsedUnscaled = Time.UnscaledDeltaTime;
                break;

            default:
                throw new NotImplementedException();
            }

            Animation next = null;

            for (var anim = _root._firstChild; anim != null; anim = next)
            {
                next = anim._next;

                if (anim._updateMode != updateMode)
                {
                    continue;
                }

                // Handle node specific logic
                if (anim._target is Node node && !(anim._target is Scene))
                {
                    // If the node is destroyed then animation can finish
                    if (node.IsDestroyed)
                    {
                        Stop(anim);
                        continue;
                    }
                    // If node's scene is paused then pause the animation too
                    else if (node.Scene == null || node.Scene.IsPaused)
                    {
                        continue;
                    }
                }

                if ((anim._flags & Flags.UnscaledTime) == Flags.UnscaledTime)
                {
                    anim.UpdateInternal(elapsedUnscaled);
                }
                else
                {
                    anim.UpdateInternal(elapsedNormal);
                }

                // If the animation is no longer active then stop it
                if (!anim.IsActive)
                {
                    Stop(anim);
                }
            }

            // Pause the animation system if none are running
            if (_root._firstChild == null)
            {
                IsPaused = true;
            }
        }