FSO.Vitaboy.AnimationHandle.Update C# (CSharp) Method

Update() public method

public Update ( GameTime time ) : void
time Microsoft.Xna.Framework.GameTime
return void
        public void Update(GameTime time)
        {
            var now = time.ElapsedGameTime.Milliseconds;
            if (this.Status == AnimationStatus.WAITING_TO_START){
                StartTime = now;
                this.Status = AnimationStatus.IN_PROGRESS;
            }

            var fps = 30.0f * Speed;
            var fpms = fps / 1000;

            var runTime = now - StartTime;
            uint frame = (uint)(runTime * fpms);
            var fraction = (runTime * fpms) - frame;

            int numDone = 0;

            /** Speed is 30fps by default **/
            foreach (var motion in Animation.Motions)
            {
                var bone = Avatar.Skeleton.GetBone(motion.BoneName);
                var motionFrame = frame;
                if (frame >= motion.FrameCount)
                {
                    numDone++;
                    motionFrame = motion.FrameCount - 1;
                }

                if (motion.HasTranslation)
                {
                    bone.Translation = Animation.Translations[motion.FirstTranslationIndex + motionFrame];
                }
                if (motion.HasRotation)
                {
                    bone.Rotation = Animation.Rotations[motion.FirstRotationIndex + motionFrame];
                }
            }

            if (numDone == Animation.Motions.Length)
            {
                /** Completed! **/
                this.Status = AnimationStatus.COMPLETED;
            }
            else
            {
                Avatar.ReloadSkeleton();
            }
        }