示例#1
0
 public void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
 {
     if (firedEvents != null)
     {
         float[] frames = this.frames;
         int     length = frames.Length;
         if (lastTime > time)
         {
             this.Apply(skeleton, lastTime, 2.147484E+09f, firedEvents, alpha, pose, direction);
             lastTime = -1f;
         }
         else if (lastTime >= frames[length - 1])
         {
             return;
         }
         if (time >= frames[0])
         {
             int num2;
             if (lastTime < frames[0])
             {
                 num2 = 0;
             }
             else
             {
                 num2 = Animation.BinarySearch(frames, lastTime);
                 float num3 = frames[num2];
                 while (num2 > 0)
                 {
                     if (frames[num2 - 1] != num3)
                     {
                         break;
                     }
                     num2--;
                 }
             }
             while ((num2 < length) && (time >= frames[num2]))
             {
                 firedEvents.Add(this.events[num2]);
                 num2++;
             }
         }
     }
 }
示例#2
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            PathConstraint constraint = skeleton.pathConstraints.Items[this.pathConstraintIndex];

            float[] frames = this.frames;
            if (time < frames[0])
            {
                if (pose != MixPose.Setup)
                {
                    if (pose != MixPose.Current)
                    {
                        return;
                    }
                }
                else
                {
                    constraint.rotateMix    = constraint.data.rotateMix;
                    constraint.translateMix = constraint.data.translateMix;
                    return;
                }
                constraint.rotateMix    += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
                constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
            }
            else
            {
                float num;
                float num2;
                if (time >= frames[frames.Length - 3])
                {
                    num  = frames[frames.Length + -2];
                    num2 = frames[frames.Length + -1];
                }
                else
                {
                    int index = Animation.BinarySearch(frames, time, 3);
                    num  = frames[index + -2];
                    num2 = frames[index + -1];
                    float num4         = frames[index];
                    float curvePercent = base.GetCurvePercent((index / 3) - 1, 1f - ((time - num4) / (frames[index + -3] - num4)));
                    num  += (frames[index + 1] - num) * curvePercent;
                    num2 += (frames[index + 2] - num2) * curvePercent;
                }
                if (pose == MixPose.Setup)
                {
                    constraint.rotateMix    = constraint.data.rotateMix + ((num - constraint.data.rotateMix) * alpha);
                    constraint.translateMix = constraint.data.translateMix + ((num2 - constraint.data.translateMix) * alpha);
                }
                else
                {
                    constraint.rotateMix    += (num - constraint.rotateMix) * alpha;
                    constraint.translateMix += (num2 - constraint.translateMix) * alpha;
                }
            }
        }
示例#3
0
        public void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            ExposedList <Slot> drawOrder = skeleton.drawOrder;
            ExposedList <Slot> slots     = skeleton.slots;

            if (direction == MixDirection.Out && pose == MixPose.Setup)
            {
                Array.Copy(slots.Items, 0, drawOrder.Items, 0, slots.Count);
                return;
            }
            float[] array = frames;
            if (time < array[0])
            {
                if (pose == MixPose.Setup)
                {
                    Array.Copy(slots.Items, 0, drawOrder.Items, 0, slots.Count);
                }
                return;
            }
            int num = (!(time >= array[array.Length - 1])) ? (Animation.BinarySearch(array, time) - 1) : (array.Length - 1);

            int[] array2 = drawOrders[num];
            if (array2 == null)
            {
                drawOrder.Clear();
                int i = 0;
                for (int count = slots.Count; i < count; i++)
                {
                    drawOrder.Add(slots.Items[i]);
                }
                return;
            }
            Slot[] items  = drawOrder.Items;
            Slot[] items2 = slots.Items;
            int    j      = 0;

            for (int num2 = array2.Length; j < num2; j++)
            {
                items[j] = items2[array2[j]];
            }
        }
示例#4
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            TransformConstraint transformConstraint = skeleton.transformConstraints.Items[transformConstraintIndex];

            float[] array = frames;
            if (time < array[0])
            {
                TransformConstraintData data = transformConstraint.data;
                switch (pose)
                {
                case MixPose.Setup:
                    transformConstraint.rotateMix    = data.rotateMix;
                    transformConstraint.translateMix = data.translateMix;
                    transformConstraint.scaleMix     = data.scaleMix;
                    transformConstraint.shearMix     = data.shearMix;
                    break;

                case MixPose.Current:
                    transformConstraint.rotateMix    += (data.rotateMix - transformConstraint.rotateMix) * alpha;
                    transformConstraint.translateMix += (data.translateMix - transformConstraint.translateMix) * alpha;
                    transformConstraint.scaleMix     += (data.scaleMix - transformConstraint.scaleMix) * alpha;
                    transformConstraint.shearMix     += (data.shearMix - transformConstraint.shearMix) * alpha;
                    break;
                }
                return;
            }
            float num2;
            float num3;
            float num4;
            float num5;

            if (time >= array[array.Length - 5])
            {
                int num = array.Length;
                num2 = array[num + -4];
                num3 = array[num + -3];
                num4 = array[num + -2];
                num5 = array[num + -1];
            }
            else
            {
                int num6 = Animation.BinarySearch(array, time, 5);
                num2 = array[num6 + -4];
                num3 = array[num6 + -3];
                num4 = array[num6 + -2];
                num5 = array[num6 + -1];
                float num7         = array[num6];
                float curvePercent = GetCurvePercent(num6 / 5 - 1, 1f - (time - num7) / (array[num6 + -5] - num7));
                num2 += (array[num6 + 1] - num2) * curvePercent;
                num3 += (array[num6 + 2] - num3) * curvePercent;
                num4 += (array[num6 + 3] - num4) * curvePercent;
                num5 += (array[num6 + 4] - num5) * curvePercent;
            }
            if (pose == MixPose.Setup)
            {
                TransformConstraintData data2 = transformConstraint.data;
                transformConstraint.rotateMix    = data2.rotateMix + (num2 - data2.rotateMix) * alpha;
                transformConstraint.translateMix = data2.translateMix + (num3 - data2.translateMix) * alpha;
                transformConstraint.scaleMix     = data2.scaleMix + (num4 - data2.scaleMix) * alpha;
                transformConstraint.shearMix     = data2.shearMix + (num5 - data2.shearMix) * alpha;
            }
            else
            {
                transformConstraint.rotateMix    += (num2 - transformConstraint.rotateMix) * alpha;
                transformConstraint.translateMix += (num3 - transformConstraint.translateMix) * alpha;
                transformConstraint.scaleMix     += (num4 - transformConstraint.scaleMix) * alpha;
                transformConstraint.shearMix     += (num5 - transformConstraint.shearMix) * alpha;
            }
        }
示例#5
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            Slot slot = skeleton.slots.Items[slotIndex];

            float[] array = frames;
            if (time < array[0])
            {
                SlotData data = slot.data;
                switch (pose)
                {
                case MixPose.Setup:
                    slot.r = data.r;
                    slot.g = data.g;
                    slot.b = data.b;
                    slot.a = data.a;
                    break;

                case MixPose.Current:
                    slot.r += (slot.r - data.r) * alpha;
                    slot.g += (slot.g - data.g) * alpha;
                    slot.b += (slot.b - data.b) * alpha;
                    slot.a += (slot.a - data.a) * alpha;
                    break;
                }
                return;
            }
            float num2;
            float num3;
            float num4;
            float num5;

            if (time >= array[array.Length - 5])
            {
                int num = array.Length;
                num2 = array[num + -4];
                num3 = array[num + -3];
                num4 = array[num + -2];
                num5 = array[num + -1];
            }
            else
            {
                int num6 = Animation.BinarySearch(array, time, 5);
                num2 = array[num6 + -4];
                num3 = array[num6 + -3];
                num4 = array[num6 + -2];
                num5 = array[num6 + -1];
                float num7         = array[num6];
                float curvePercent = GetCurvePercent(num6 / 5 - 1, 1f - (time - num7) / (array[num6 + -5] - num7));
                num2 += (array[num6 + 1] - num2) * curvePercent;
                num3 += (array[num6 + 2] - num3) * curvePercent;
                num4 += (array[num6 + 3] - num4) * curvePercent;
                num5 += (array[num6 + 4] - num5) * curvePercent;
            }
            if (alpha == 1f)
            {
                slot.r = num2;
                slot.g = num3;
                slot.b = num4;
                slot.a = num5;
                return;
            }
            float r;
            float g;
            float b;
            float a;

            if (pose == MixPose.Setup)
            {
                r = slot.data.r;
                g = slot.data.g;
                b = slot.data.b;
                a = slot.data.a;
            }
            else
            {
                r = slot.r;
                g = slot.g;
                b = slot.b;
                a = slot.a;
            }
            slot.r = r + (num2 - r) * alpha;
            slot.g = g + (num3 - g) * alpha;
            slot.b = b + (num4 - b) * alpha;
            slot.a = a + (num5 - a) * alpha;
        }
示例#6
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            PathConstraint pathConstraint = skeleton.pathConstraints.Items[pathConstraintIndex];

            float[] frames = base.frames;
            if (time < frames[0])
            {
                switch (pose)
                {
                case MixPose.Setup:
                    pathConstraint.spacing = pathConstraint.data.spacing;
                    break;

                case MixPose.Current:
                    pathConstraint.spacing += (pathConstraint.data.spacing - pathConstraint.spacing) * alpha;
                    break;
                }
                return;
            }
            float num;

            if (time >= frames[frames.Length - 2])
            {
                num = frames[frames.Length + -1];
            }
            else
            {
                int num2 = Animation.BinarySearch(frames, time, 2);
                num = frames[num2 + -1];
                float num3         = frames[num2];
                float curvePercent = GetCurvePercent(num2 / 2 - 1, 1f - (time - num3) / (frames[num2 + -2] - num3));
                num += (frames[num2 + 1] - num) * curvePercent;
            }
            if (pose == MixPose.Setup)
            {
                pathConstraint.spacing = pathConstraint.data.spacing + (num - pathConstraint.data.spacing) * alpha;
            }
            else
            {
                pathConstraint.spacing += (num - pathConstraint.spacing) * alpha;
            }
        }
示例#7
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            IkConstraint constraint = skeleton.ikConstraints.Items[this.ikConstraintIndex];

            float[] frames = this.frames;
            if (time < frames[0])
            {
                if (pose != MixPose.Setup)
                {
                    if (pose != MixPose.Current)
                    {
                        return;
                    }
                }
                else
                {
                    constraint.mix           = constraint.data.mix;
                    constraint.bendDirection = constraint.data.bendDirection;
                    return;
                }
                constraint.mix          += (constraint.data.mix - constraint.mix) * alpha;
                constraint.bendDirection = constraint.data.bendDirection;
            }
            else if (time >= frames[frames.Length - 3])
            {
                if (pose == MixPose.Setup)
                {
                    constraint.mix           = constraint.data.mix + ((frames[frames.Length + -2] - constraint.data.mix) * alpha);
                    constraint.bendDirection = (direction != MixDirection.Out) ? ((int)frames[frames.Length + -1]) : constraint.data.bendDirection;
                }
                else
                {
                    constraint.mix += (frames[frames.Length + -2] - constraint.mix) * alpha;
                    if (direction == MixDirection.In)
                    {
                        constraint.bendDirection = (int)frames[frames.Length + -1];
                    }
                }
            }
            else
            {
                int   index        = Animation.BinarySearch(frames, time, 3);
                float num2         = frames[index + -2];
                float num3         = frames[index];
                float curvePercent = base.GetCurvePercent((index / 3) - 1, 1f - ((time - num3) / (frames[index + -3] - num3)));
                if (pose == MixPose.Setup)
                {
                    constraint.mix           = constraint.data.mix + (((num2 + ((frames[index + 1] - num2) * curvePercent)) - constraint.data.mix) * alpha);
                    constraint.bendDirection = (direction != MixDirection.Out) ? ((int)frames[index + -1]) : constraint.data.bendDirection;
                }
                else
                {
                    constraint.mix += ((num2 + ((frames[index + 1] - num2) * curvePercent)) - constraint.mix) * alpha;
                    if (direction == MixDirection.In)
                    {
                        constraint.bendDirection = (int)frames[index + -1];
                    }
                }
            }
        }
示例#8
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            PathConstraint pathConstraint = skeleton.pathConstraints.Items[pathConstraintIndex];

            float[] array = frames;
            if (time < array[0])
            {
                switch (pose)
                {
                case MixPose.Setup:
                    pathConstraint.rotateMix    = pathConstraint.data.rotateMix;
                    pathConstraint.translateMix = pathConstraint.data.translateMix;
                    break;

                case MixPose.Current:
                    pathConstraint.rotateMix    += (pathConstraint.data.rotateMix - pathConstraint.rotateMix) * alpha;
                    pathConstraint.translateMix += (pathConstraint.data.translateMix - pathConstraint.translateMix) * alpha;
                    break;
                }
                return;
            }
            float num;
            float num2;

            if (time >= array[array.Length - 3])
            {
                num  = array[array.Length + -2];
                num2 = array[array.Length + -1];
            }
            else
            {
                int num3 = Animation.BinarySearch(array, time, 3);
                num  = array[num3 + -2];
                num2 = array[num3 + -1];
                float num4         = array[num3];
                float curvePercent = GetCurvePercent(num3 / 3 - 1, 1f - (time - num4) / (array[num3 + -3] - num4));
                num  += (array[num3 + 1] - num) * curvePercent;
                num2 += (array[num3 + 2] - num2) * curvePercent;
            }
            if (pose == MixPose.Setup)
            {
                pathConstraint.rotateMix    = pathConstraint.data.rotateMix + (num - pathConstraint.data.rotateMix) * alpha;
                pathConstraint.translateMix = pathConstraint.data.translateMix + (num2 - pathConstraint.data.translateMix) * alpha;
            }
            else
            {
                pathConstraint.rotateMix    += (num - pathConstraint.rotateMix) * alpha;
                pathConstraint.translateMix += (num2 - pathConstraint.translateMix) * alpha;
            }
        }
示例#9
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            Bone bone = skeleton.bones.Items[boneIndex];

            float[] frames = base.frames;
            if (time < frames[0])
            {
                switch (pose)
                {
                case MixPose.Setup:
                    bone.shearX = bone.data.shearX;
                    bone.shearY = bone.data.shearY;
                    break;

                case MixPose.Current:
                    bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
                    bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
                    break;
                }
                return;
            }
            float num;
            float num2;

            if (time >= frames[frames.Length - 3])
            {
                num  = frames[frames.Length + -2];
                num2 = frames[frames.Length + -1];
            }
            else
            {
                int num3 = Animation.BinarySearch(frames, time, 3);
                num  = frames[num3 + -2];
                num2 = frames[num3 + -1];
                float num4         = frames[num3];
                float curvePercent = GetCurvePercent(num3 / 3 - 1, 1f - (time - num4) / (frames[num3 + -3] - num4));
                num  += (frames[num3 + 1] - num) * curvePercent;
                num2 += (frames[num3 + 2] - num2) * curvePercent;
            }
            if (pose == MixPose.Setup)
            {
                bone.shearX = bone.data.shearX + num * alpha;
                bone.shearY = bone.data.shearY + num2 * alpha;
            }
            else
            {
                bone.shearX += (bone.data.shearX + num - bone.shearX) * alpha;
                bone.shearY += (bone.data.shearY + num2 - bone.shearY) * alpha;
            }
        }
示例#10
0
        private float ApplyMixingFrom(TrackEntry to, Skeleton skeleton, MixPose currentPose)
        {
            float      num;
            TrackEntry mixingFrom = to.mixingFrom;

            if (mixingFrom.mixingFrom != null)
            {
                this.ApplyMixingFrom(mixingFrom, skeleton, currentPose);
            }
            if (to.mixDuration == 0f)
            {
                num         = 1f;
                currentPose = MixPose.Setup;
            }
            else
            {
                num = to.mixTime / to.mixDuration;
                if (num > 1f)
                {
                    num = 1f;
                }
            }
            ExposedList <Spine.Event> events = (num >= mixingFrom.eventThreshold) ? null : this.events;
            bool  flag          = num < mixingFrom.attachmentThreshold;
            bool  flag2         = num < mixingFrom.drawOrderThreshold;
            float animationLast = mixingFrom.animationLast;
            float animationTime = mixingFrom.AnimationTime;
            ExposedList <Timeline> timelines = mixingFrom.animation.timelines;
            int count = timelines.Count;

            Timeline[]   items      = timelines.Items;
            int[]        numArray   = mixingFrom.timelineData.Items;
            TrackEntry[] entryArray = mixingFrom.timelineDipMix.Items;
            bool         firstFrame = mixingFrom.timelinesRotation.Count == 0;

            if (firstFrame)
            {
                mixingFrom.timelinesRotation.Resize(timelines.Count << 1);
            }
            float[] timelinesRotation = mixingFrom.timelinesRotation.Items;
            float   num5 = mixingFrom.alpha * to.interruptAlpha;
            float   num6 = num5 * (1f - num);

            mixingFrom.totalAlpha = 0f;
            for (int i = 0; i < count; i++)
            {
                MixPose  setup;
                float    num7;
                Timeline timeline = items[i];
                switch (numArray[i])
                {
                case 0:
                {
                    if (flag || !(timeline is AttachmentTimeline))
                    {
                        break;
                    }
                    continue;
                }

                case 1:
                    setup = MixPose.Setup;
                    num7  = num6;
                    goto Label_01E3;

                case 2:
                    setup = MixPose.Setup;
                    num7  = num5;
                    goto Label_01E3;

                default:
                {
                    setup = MixPose.Setup;
                    TrackEntry entry2 = entryArray[i];
                    num7 = num5 * Math.Max((float)0f, (float)(1f - (entry2.mixTime / entry2.mixDuration)));
                    goto Label_01E3;
                }
                }
                if (!flag2 && (timeline is DrawOrderTimeline))
                {
                    continue;
                }
                setup = currentPose;
                num7  = num6;
Label_01E3:
                mixingFrom.totalAlpha += num7;
                RotateTimeline rotateTimeline = timeline as RotateTimeline;
                if (rotateTimeline != null)
                {
                    ApplyRotateTimeline(rotateTimeline, skeleton, animationTime, num7, setup, timelinesRotation, i << 1, firstFrame);
                }
                else
                {
                    timeline.Apply(skeleton, animationLast, animationTime, events, num7, setup, MixDirection.Out);
                }
            }
            if (to.mixDuration > 0f)
            {
                this.QueueEvents(mixingFrom, animationTime);
            }
            this.events.Clear(false);
            mixingFrom.nextAnimationLast = animationTime;
            mixingFrom.nextTrackLast     = mixingFrom.trackTime;
            return(num);
        }
示例#11
0
 private static void ApplyRotateTimeline(RotateTimeline rotateTimeline, Skeleton skeleton, float time, float alpha, MixPose pose, float[] timelinesRotation, int i, bool firstFrame)
 {
     if (firstFrame)
     {
         timelinesRotation[i] = 0f;
     }
     if (alpha == 1f)
     {
         rotateTimeline.Apply(skeleton, 0f, time, null, 1f, pose, MixDirection.In);
     }
     else
     {
         Bone    bone   = skeleton.bones.Items[rotateTimeline.boneIndex];
         float[] frames = rotateTimeline.frames;
         if (time < frames[0])
         {
             if (pose == MixPose.Setup)
             {
                 bone.rotation = bone.data.rotation;
             }
         }
         else
         {
             float num;
             float num7;
             if (time >= frames[frames.Length - 2])
             {
                 num = bone.data.rotation + frames[frames.Length + -1];
             }
             else
             {
                 int   index        = Animation.BinarySearch(frames, time, 2);
                 float num3         = frames[index + -1];
                 float num4         = frames[index];
                 float curvePercent = rotateTimeline.GetCurvePercent((index >> 1) - 1, 1f - ((time - num4) / (frames[index + -2] - num4)));
                 num  = frames[index + 1] - num3;
                 num -= (0x4000 - ((int)(16384.499999999996 - (num / 360f)))) * 360;
                 num  = (num3 + (num * curvePercent)) + bone.data.rotation;
                 num -= (0x4000 - ((int)(16384.499999999996 - (num / 360f)))) * 360;
             }
             float num6 = (pose != MixPose.Setup) ? bone.rotation : bone.data.rotation;
             float num8 = num - num6;
             if (num8 == 0f)
             {
                 num7 = timelinesRotation[i];
             }
             else
             {
                 float num9;
                 float num10;
                 num8 -= (0x4000 - ((int)(16384.499999999996 - (num8 / 360f)))) * 360;
                 if (firstFrame)
                 {
                     num9  = 0f;
                     num10 = num8;
                 }
                 else
                 {
                     num9  = timelinesRotation[i];
                     num10 = timelinesRotation[i + 1];
                 }
                 bool flag  = num8 > 0f;
                 bool flag2 = num9 >= 0f;
                 if ((Math.Sign(num10) != Math.Sign(num8)) && (Math.Abs(num10) <= 90f))
                 {
                     if (Math.Abs(num9) > 180f)
                     {
                         num9 += 360 * Math.Sign(num9);
                     }
                     flag2 = flag;
                 }
                 num7 = (num8 + num9) - (num9 % 360f);
                 if (flag2 != flag)
                 {
                     num7 += 360 * Math.Sign(num9);
                 }
                 timelinesRotation[i] = num7;
             }
             timelinesRotation[i + 1] = num8;
             num6         += num7 * alpha;
             bone.rotation = num6 - ((0x4000 - ((int)(16384.499999999996 - (num6 / 360f)))) * 360);
         }
     }
 }
示例#12
0
        public bool Apply(Skeleton skeleton)
        {
            if (skeleton == null)
            {
                throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
            }
            if (this.animationsChanged)
            {
                this.AnimationsChanged();
            }
            ExposedList <Spine.Event> events = this.events;
            bool flag = false;

            TrackEntry[] items = this.tracks.Items;
            int          index = 0;
            int          count = this.tracks.Count;

            while (index < count)
            {
                TrackEntry to = items[index];
                if ((to != null) && (to.delay <= 0f))
                {
                    flag = true;
                    MixPose currentPose = (index != 0) ? MixPose.CurrentLayered : MixPose.Current;
                    float   alpha       = to.alpha;
                    if (to.mixingFrom != null)
                    {
                        alpha *= this.ApplyMixingFrom(to, skeleton, currentPose);
                    }
                    else if ((to.trackTime >= to.trackEnd) && (to.next == null))
                    {
                        alpha = 0f;
                    }
                    float animationLast = to.animationLast;
                    float animationTime = to.AnimationTime;
                    int   num6          = to.animation.timelines.Count;
                    ExposedList <Timeline> timelines     = to.animation.timelines;
                    Timeline[]             timelineArray = timelines.Items;
                    if (alpha == 1f)
                    {
                        for (int i = 0; i < num6; i++)
                        {
                            timelineArray[i].Apply(skeleton, animationLast, animationTime, events, 1f, MixPose.Setup, MixDirection.In);
                        }
                    }
                    else
                    {
                        int[] numArray   = to.timelineData.Items;
                        bool  firstFrame = to.timelinesRotation.Count == 0;
                        if (firstFrame)
                        {
                            to.timelinesRotation.EnsureCapacity(timelines.Count << 1);
                        }
                        float[] timelinesRotation = to.timelinesRotation.Items;
                        for (int i = 0; i < num6; i++)
                        {
                            Timeline       timeline       = timelineArray[i];
                            MixPose        pose           = (numArray[i] < 1) ? currentPose : MixPose.Setup;
                            RotateTimeline rotateTimeline = timeline as RotateTimeline;
                            if (rotateTimeline != null)
                            {
                                ApplyRotateTimeline(rotateTimeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame);
                            }
                            else
                            {
                                timeline.Apply(skeleton, animationLast, animationTime, events, alpha, pose, MixDirection.In);
                            }
                        }
                    }
                    this.QueueEvents(to, animationTime);
                    events.Clear(false);
                    to.nextAnimationLast = animationTime;
                    to.nextTrackLast     = to.trackTime;
                }
                index++;
            }
            this.queue.Drain();
            return(flag);
        }
示例#13
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            Slot slot = skeleton.slots.Items[slotIndex];

            float[] array = frames;
            if (time < array[0])
            {
                SlotData data = slot.data;
                switch (pose)
                {
                case MixPose.Setup:
                    slot.r  = data.r;
                    slot.g  = data.g;
                    slot.b  = data.b;
                    slot.a  = data.a;
                    slot.r2 = data.r2;
                    slot.g2 = data.g2;
                    slot.b2 = data.b2;
                    break;

                case MixPose.Current:
                    slot.r  += (slot.r - data.r) * alpha;
                    slot.g  += (slot.g - data.g) * alpha;
                    slot.b  += (slot.b - data.b) * alpha;
                    slot.a  += (slot.a - data.a) * alpha;
                    slot.r2 += (slot.r2 - data.r2) * alpha;
                    slot.g2 += (slot.g2 - data.g2) * alpha;
                    slot.b2 += (slot.b2 - data.b2) * alpha;
                    break;
                }
                return;
            }
            float num2;
            float num3;
            float num4;
            float num5;
            float num6;
            float num7;
            float num8;

            if (time >= array[array.Length - 8])
            {
                int num = array.Length;
                num2 = array[num + -7];
                num3 = array[num + -6];
                num4 = array[num + -5];
                num5 = array[num + -4];
                num6 = array[num + -3];
                num7 = array[num + -2];
                num8 = array[num + -1];
            }
            else
            {
                int num9 = Animation.BinarySearch(array, time, 8);
                num2 = array[num9 + -7];
                num3 = array[num9 + -6];
                num4 = array[num9 + -5];
                num5 = array[num9 + -4];
                num6 = array[num9 + -3];
                num7 = array[num9 + -2];
                num8 = array[num9 + -1];
                float num10        = array[num9];
                float curvePercent = GetCurvePercent(num9 / 8 - 1, 1f - (time - num10) / (array[num9 + -8] - num10));
                num2 += (array[num9 + 1] - num2) * curvePercent;
                num3 += (array[num9 + 2] - num3) * curvePercent;
                num4 += (array[num9 + 3] - num4) * curvePercent;
                num5 += (array[num9 + 4] - num5) * curvePercent;
                num6 += (array[num9 + 5] - num6) * curvePercent;
                num7 += (array[num9 + 6] - num7) * curvePercent;
                num8 += (array[num9 + 7] - num8) * curvePercent;
            }
            if (alpha == 1f)
            {
                slot.r  = num2;
                slot.g  = num3;
                slot.b  = num4;
                slot.a  = num5;
                slot.r2 = num6;
                slot.g2 = num7;
                slot.b2 = num8;
                return;
            }
            float r;
            float g;
            float b;
            float a;
            float r2;
            float g2;
            float b2;

            if (pose == MixPose.Setup)
            {
                r  = slot.data.r;
                g  = slot.data.g;
                b  = slot.data.b;
                a  = slot.data.a;
                r2 = slot.data.r2;
                g2 = slot.data.g2;
                b2 = slot.data.b2;
            }
            else
            {
                r  = slot.r;
                g  = slot.g;
                b  = slot.b;
                a  = slot.a;
                r2 = slot.r2;
                g2 = slot.g2;
                b2 = slot.b2;
            }
            slot.r  = r + (num2 - r) * alpha;
            slot.g  = g + (num3 - g) * alpha;
            slot.b  = b + (num4 - b) * alpha;
            slot.a  = a + (num5 - a) * alpha;
            slot.r2 = r2 + (num6 - r2) * alpha;
            slot.g2 = g2 + (num7 - g2) * alpha;
            slot.b2 = b2 + (num8 - b2) * alpha;
        }
        public void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            ExposedList <Slot> drawOrder = skeleton.drawOrder;
            ExposedList <Slot> slots     = skeleton.slots;

            if ((direction == MixDirection.Out) && (pose == MixPose.Setup))
            {
                Array.Copy(slots.Items, 0, drawOrder.Items, 0, slots.Count);
            }
            else
            {
                float[] frames = this.frames;
                if (time < frames[0])
                {
                    if (pose == MixPose.Setup)
                    {
                        Array.Copy(slots.Items, 0, drawOrder.Items, 0, slots.Count);
                    }
                }
                else
                {
                    int num;
                    if (time >= frames[frames.Length - 1])
                    {
                        num = frames.Length - 1;
                    }
                    else
                    {
                        num = Animation.BinarySearch(frames, time) - 1;
                    }
                    int[] numArray2 = this.drawOrders[num];
                    if (numArray2 == null)
                    {
                        drawOrder.Clear(true);
                        int index = 0;
                        int count = slots.Count;
                        while (index < count)
                        {
                            drawOrder.Add(slots.Items[index]);
                            index++;
                        }
                    }
                    else
                    {
                        Slot[] items      = drawOrder.Items;
                        Slot[] slotArray2 = slots.Items;
                        int    index      = 0;
                        int    length     = numArray2.Length;
                        while (index < length)
                        {
                            items[index] = slotArray2[numArray2[index]];
                            index++;
                        }
                    }
                }
            }
        }
示例#15
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            Bone bone = skeleton.bones.Items[base.boneIndex];

            float[] frames = base.frames;
            if (time < frames[0])
            {
                if (pose != MixPose.Setup)
                {
                    if (pose != MixPose.Current)
                    {
                        return;
                    }
                }
                else
                {
                    bone.shearX = bone.data.shearX;
                    bone.shearY = bone.data.shearY;
                    return;
                }
                bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
                bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
            }
            else
            {
                float num;
                float num2;
                if (time >= frames[frames.Length - 3])
                {
                    num  = frames[frames.Length + -2];
                    num2 = frames[frames.Length + -1];
                }
                else
                {
                    int index = Animation.BinarySearch(frames, time, 3);
                    num  = frames[index + -2];
                    num2 = frames[index + -1];
                    float num4         = frames[index];
                    float curvePercent = base.GetCurvePercent((index / 3) - 1, 1f - ((time - num4) / (frames[index + -3] - num4)));
                    num  += (frames[index + 1] - num) * curvePercent;
                    num2 += (frames[index + 2] - num2) * curvePercent;
                }
                if (pose == MixPose.Setup)
                {
                    bone.shearX = bone.data.shearX + (num * alpha);
                    bone.shearY = bone.data.shearY + (num2 * alpha);
                }
                else
                {
                    bone.shearX += ((bone.data.shearX + num) - bone.shearX) * alpha;
                    bone.shearY += ((bone.data.shearY + num2) - bone.shearY) * alpha;
                }
            }
        }
示例#16
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            Bone bone = skeleton.bones.Items[base.boneIndex];

            float[] frames = base.frames;
            if (time < frames[0])
            {
                if (pose != MixPose.Setup)
                {
                    if (pose != MixPose.Current)
                    {
                        return;
                    }
                }
                else
                {
                    bone.scaleX = bone.data.scaleX;
                    bone.scaleY = bone.data.scaleY;
                    return;
                }
                bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
                bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
            }
            else
            {
                float num;
                float num2;
                if (time >= frames[frames.Length - 3])
                {
                    num  = frames[frames.Length + -2] * bone.data.scaleX;
                    num2 = frames[frames.Length + -1] * bone.data.scaleY;
                }
                else
                {
                    int index = Animation.BinarySearch(frames, time, 3);
                    num  = frames[index + -2];
                    num2 = frames[index + -1];
                    float num4         = frames[index];
                    float curvePercent = base.GetCurvePercent((index / 3) - 1, 1f - ((time - num4) / (frames[index + -3] - num4)));
                    num  = (num + ((frames[index + 1] - num) * curvePercent)) * bone.data.scaleX;
                    num2 = (num2 + ((frames[index + 2] - num2) * curvePercent)) * bone.data.scaleY;
                }
                if (alpha == 1f)
                {
                    bone.scaleX = num;
                    bone.scaleY = num2;
                }
                else
                {
                    float scaleX;
                    float scaleY;
                    if (pose == MixPose.Setup)
                    {
                        scaleX = bone.data.scaleX;
                        scaleY = bone.data.scaleY;
                    }
                    else
                    {
                        scaleX = bone.scaleX;
                        scaleY = bone.scaleY;
                    }
                    if (direction == MixDirection.Out)
                    {
                        num  = ((num < 0f) ? -num : num) * ((scaleX < 0f) ? ((float)(-1)) : ((float)1));
                        num2 = ((num2 < 0f) ? -num2 : num2) * ((scaleY < 0f) ? ((float)(-1)) : ((float)1));
                    }
                    else
                    {
                        scaleX = ((scaleX < 0f) ? -scaleX : scaleX) * ((num < 0f) ? ((float)(-1)) : ((float)1));
                        scaleY = ((scaleY < 0f) ? -scaleY : scaleY) * ((num2 < 0f) ? ((float)(-1)) : ((float)1));
                    }
                    bone.scaleX = scaleX + ((num - scaleX) * alpha);
                    bone.scaleY = scaleY + ((num2 - scaleY) * alpha);
                }
            }
        }
示例#17
0
        public void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            string attachmentName;
            Slot   slot = skeleton.slots.Items[this.slotIndex];

            if ((direction == MixDirection.Out) && (pose == MixPose.Setup))
            {
                attachmentName  = slot.data.attachmentName;
                slot.Attachment = (attachmentName != null) ? skeleton.GetAttachment(this.slotIndex, attachmentName) : null;
            }
            else
            {
                float[] frames = this.frames;
                if (time < frames[0])
                {
                    if (pose == MixPose.Setup)
                    {
                        attachmentName  = slot.data.attachmentName;
                        slot.Attachment = (attachmentName != null) ? skeleton.GetAttachment(this.slotIndex, attachmentName) : null;
                    }
                }
                else
                {
                    int num;
                    if (time >= frames[frames.Length - 1])
                    {
                        num = frames.Length - 1;
                    }
                    else
                    {
                        num = Animation.BinarySearch(frames, time, 1) - 1;
                    }
                    attachmentName  = this.attachmentNames[num];
                    slot.Attachment = (attachmentName != null) ? skeleton.GetAttachment(this.slotIndex, attachmentName) : null;
                }
            }
        }
示例#18
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            Bone bone = skeleton.bones.Items[boneIndex];

            float[] array = frames;
            if (time < array[0])
            {
                switch (pose)
                {
                case MixPose.Setup:
                    bone.x = bone.data.x;
                    bone.y = bone.data.y;
                    break;

                case MixPose.Current:
                    bone.x += (bone.data.x - bone.x) * alpha;
                    bone.y += (bone.data.y - bone.y) * alpha;
                    break;
                }
                return;
            }
            float num;
            float num2;

            if (time >= array[array.Length - 3])
            {
                num  = array[array.Length + -2];
                num2 = array[array.Length + -1];
            }
            else
            {
                int num3 = Animation.BinarySearch(array, time, 3);
                num  = array[num3 + -2];
                num2 = array[num3 + -1];
                float num4         = array[num3];
                float curvePercent = GetCurvePercent(num3 / 3 - 1, 1f - (time - num4) / (array[num3 + -3] - num4));
                num  += (array[num3 + 1] - num) * curvePercent;
                num2 += (array[num3 + 2] - num2) * curvePercent;
            }
            if (pose == MixPose.Setup)
            {
                bone.x = bone.data.x + num * alpha;
                bone.y = bone.data.y + num2 * alpha;
            }
            else
            {
                bone.x += (bone.data.x + num - bone.x) * alpha;
                bone.y += (bone.data.y + num2 - bone.y) * alpha;
            }
        }
示例#19
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            Slot             slot       = skeleton.slots.Items[this.slotIndex];
            VertexAttachment attachment = slot.attachment as VertexAttachment;

            if ((attachment != null) && attachment.ApplyDeform(this.attachment))
            {
                float[]             items;
                ExposedList <float> attachmentVertices = slot.attachmentVertices;
                if (attachmentVertices.Count == 0)
                {
                    alpha = 1f;
                }
                float[][] frameVertices = this.frameVertices;
                int       length        = frameVertices[0].Length;
                float[]   frames        = this.frames;
                if (time < frames[0])
                {
                    if (pose != MixPose.Setup)
                    {
                        if (pose != MixPose.Current)
                        {
                            return;
                        }
                    }
                    else
                    {
                        attachmentVertices.Clear(true);
                        return;
                    }
                    if (alpha == 1f)
                    {
                        attachmentVertices.Clear(true);
                    }
                    else
                    {
                        if (attachmentVertices.Capacity < length)
                        {
                            attachmentVertices.Capacity = length;
                        }
                        attachmentVertices.Count = length;
                        items = attachmentVertices.Items;
                        if (attachment.bones == null)
                        {
                            float[] vertices = attachment.vertices;
                            for (int i = 0; i < length; i++)
                            {
                                items[i] += (vertices[i] - items[i]) * alpha;
                            }
                        }
                        else
                        {
                            alpha = 1f - alpha;
                            for (int i = 0; i < length; i++)
                            {
                                items[i] *= alpha;
                            }
                        }
                    }
                }
                else
                {
                    if (attachmentVertices.Capacity < length)
                    {
                        attachmentVertices.Capacity = length;
                    }
                    attachmentVertices.Count = length;
                    items = attachmentVertices.Items;
                    if (time >= frames[frames.Length - 1])
                    {
                        float[] sourceArray = frameVertices[frames.Length - 1];
                        if (alpha == 1f)
                        {
                            Array.Copy(sourceArray, 0, items, 0, length);
                        }
                        else if (pose == MixPose.Setup)
                        {
                            if (attachment.bones == null)
                            {
                                float[] vertices = attachment.vertices;
                                for (int i = 0; i < length; i++)
                                {
                                    float num5 = vertices[i];
                                    items[i] = num5 + ((sourceArray[i] - num5) * alpha);
                                }
                            }
                            else
                            {
                                for (int i = 0; i < length; i++)
                                {
                                    items[i] = sourceArray[i] * alpha;
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < length; i++)
                            {
                                items[i] += (sourceArray[i] - items[i]) * alpha;
                            }
                        }
                    }
                    else
                    {
                        int     index        = Animation.BinarySearch(frames, time);
                        float[] numArray7    = frameVertices[index - 1];
                        float[] numArray8    = frameVertices[index];
                        float   num9         = frames[index];
                        float   curvePercent = base.GetCurvePercent(index - 1, 1f - ((time - num9) / (frames[index - 1] - num9)));
                        if (alpha == 1f)
                        {
                            for (int i = 0; i < length; i++)
                            {
                                float num12 = numArray7[i];
                                items[i] = num12 + ((numArray8[i] - num12) * curvePercent);
                            }
                        }
                        else if (pose == MixPose.Setup)
                        {
                            if (attachment.bones == null)
                            {
                                float[] vertices = attachment.vertices;
                                for (int i = 0; i < length; i++)
                                {
                                    float num14 = numArray7[i];
                                    float num15 = vertices[i];
                                    items[i] = num15 + (((num14 + ((numArray8[i] - num14) * curvePercent)) - num15) * alpha);
                                }
                            }
                            else
                            {
                                for (int i = 0; i < length; i++)
                                {
                                    float num17 = numArray7[i];
                                    items[i] = (num17 + ((numArray8[i] - num17) * curvePercent)) * alpha;
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < length; i++)
                            {
                                float num19 = numArray7[i];
                                items[i] += ((num19 + ((numArray8[i] - num19) * curvePercent)) - items[i]) * alpha;
                            }
                        }
                    }
                }
            }
        }
示例#20
0
        public bool Apply(Skeleton skeleton)
        {
            if (skeleton == null)
            {
                throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
            }
            if (animationsChanged)
            {
                AnimationsChanged();
            }
            ExposedList <Event> exposedList = events;
            bool result = false;

            TrackEntry[] items = tracks.Items;
            int          i     = 0;

            for (int count = tracks.Count; i < count; i++)
            {
                TrackEntry trackEntry = items[i];
                if (trackEntry == null || trackEntry.delay > 0f)
                {
                    continue;
                }
                result = true;
                MixPose mixPose = (i == 0) ? MixPose.Current : MixPose.CurrentLayered;
                float   num     = trackEntry.alpha;
                if (trackEntry.mixingFrom != null)
                {
                    num *= ApplyMixingFrom(trackEntry, skeleton, mixPose);
                }
                else if (trackEntry.trackTime >= trackEntry.trackEnd && trackEntry.next == null)
                {
                    num = 0f;
                }
                float animationLast = trackEntry.animationLast;
                float animationTime = trackEntry.AnimationTime;
                int   count2        = trackEntry.animation.timelines.Count;
                ExposedList <Timeline> timelines = trackEntry.animation.timelines;
                Timeline[]             items2    = timelines.Items;
                if (num == 1f)
                {
                    for (int j = 0; j < count2; j++)
                    {
                        items2[j].Apply(skeleton, animationLast, animationTime, exposedList, 1f, MixPose.Setup, MixDirection.In);
                    }
                }
                else
                {
                    int[] items3 = trackEntry.timelineData.Items;
                    bool  flag   = trackEntry.timelinesRotation.Count == 0;
                    if (flag)
                    {
                        trackEntry.timelinesRotation.EnsureCapacity(timelines.Count << 1);
                    }
                    float[] items4 = trackEntry.timelinesRotation.Items;
                    for (int k = 0; k < count2; k++)
                    {
                        Timeline       timeline       = items2[k];
                        MixPose        pose           = (items3[k] < 1) ? mixPose : MixPose.Setup;
                        RotateTimeline rotateTimeline = timeline as RotateTimeline;
                        if (rotateTimeline != null)
                        {
                            ApplyRotateTimeline(rotateTimeline, skeleton, animationTime, num, pose, items4, k << 1, flag);
                        }
                        else
                        {
                            timeline.Apply(skeleton, animationLast, animationTime, exposedList, num, pose, MixDirection.In);
                        }
                    }
                }
                QueueEvents(trackEntry, animationTime);
                exposedList.Clear(clearArray: false);
                trackEntry.nextAnimationLast = animationTime;
                trackEntry.nextTrackLast     = trackEntry.trackTime;
            }
            queue.Drain();
            return(result);
        }
示例#21
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            IkConstraint ikConstraint = skeleton.ikConstraints.Items[ikConstraintIndex];

            float[] array = frames;
            if (time < array[0])
            {
                switch (pose)
                {
                case MixPose.Setup:
                    ikConstraint.mix           = ikConstraint.data.mix;
                    ikConstraint.bendDirection = ikConstraint.data.bendDirection;
                    break;

                case MixPose.Current:
                    ikConstraint.mix          += (ikConstraint.data.mix - ikConstraint.mix) * alpha;
                    ikConstraint.bendDirection = ikConstraint.data.bendDirection;
                    break;
                }
                return;
            }
            if (time >= array[array.Length - 3])
            {
                if (pose == MixPose.Setup)
                {
                    ikConstraint.mix           = ikConstraint.data.mix + (array[array.Length + -2] - ikConstraint.data.mix) * alpha;
                    ikConstraint.bendDirection = ((direction != MixDirection.Out) ? ((int)array[array.Length + -1]) : ikConstraint.data.bendDirection);
                    return;
                }
                ikConstraint.mix += (array[array.Length + -2] - ikConstraint.mix) * alpha;
                if (direction == MixDirection.In)
                {
                    ikConstraint.bendDirection = (int)array[array.Length + -1];
                }
                return;
            }
            int   num          = Animation.BinarySearch(array, time, 3);
            float num2         = array[num + -2];
            float num3         = array[num];
            float curvePercent = GetCurvePercent(num / 3 - 1, 1f - (time - num3) / (array[num + -3] - num3));

            if (pose == MixPose.Setup)
            {
                ikConstraint.mix           = ikConstraint.data.mix + (num2 + (array[num + 1] - num2) * curvePercent - ikConstraint.data.mix) * alpha;
                ikConstraint.bendDirection = ((direction != MixDirection.Out) ? ((int)array[num + -1]) : ikConstraint.data.bendDirection);
                return;
            }
            ikConstraint.mix += (num2 + (array[num + 1] - num2) * curvePercent - ikConstraint.mix) * alpha;
            if (direction == MixDirection.In)
            {
                ikConstraint.bendDirection = (int)array[num + -1];
            }
        }
示例#22
0
        private float ApplyMixingFrom(TrackEntry to, Skeleton skeleton, MixPose currentPose)
        {
            TrackEntry mixingFrom = to.mixingFrom;

            if (mixingFrom.mixingFrom != null)
            {
                ApplyMixingFrom(mixingFrom, skeleton, currentPose);
            }
            float num;

            if (to.mixDuration == 0f)
            {
                num = 1f;
            }
            else
            {
                num = to.mixTime / to.mixDuration;
                if (num > 1f)
                {
                    num = 1f;
                }
            }
            ExposedList <Event> exposedList = (!(num < mixingFrom.eventThreshold)) ? null : events;
            bool  flag          = num < mixingFrom.attachmentThreshold;
            bool  flag2         = num < mixingFrom.drawOrderThreshold;
            float animationLast = mixingFrom.animationLast;
            float animationTime = mixingFrom.AnimationTime;
            ExposedList <Timeline> timelines = mixingFrom.animation.timelines;
            int count = timelines.Count;

            Timeline[]   items  = timelines.Items;
            int[]        items2 = mixingFrom.timelineData.Items;
            TrackEntry[] items3 = mixingFrom.timelineDipMix.Items;
            bool         flag3  = mixingFrom.timelinesRotation.Count == 0;

            if (flag3)
            {
                mixingFrom.timelinesRotation.Resize(timelines.Count << 1);
            }
            float[] items4 = mixingFrom.timelinesRotation.Items;
            float   num2   = mixingFrom.alpha * to.interruptAlpha;
            float   num3   = num2 * (1f - num);

            mixingFrom.totalAlpha = 0f;
            for (int i = 0; i < count; i++)
            {
                Timeline timeline = items[i];
                MixPose  pose;
                float    num4;
                switch (items2[i])
                {
                case 0:
                    if ((!flag && timeline is AttachmentTimeline) || (!flag2 && timeline is DrawOrderTimeline))
                    {
                        continue;
                    }
                    pose = currentPose;
                    num4 = num3;
                    break;

                case 1:
                    pose = MixPose.Setup;
                    num4 = num3;
                    break;

                case 2:
                    pose = MixPose.Setup;
                    num4 = num2;
                    break;

                default:
                {
                    pose = MixPose.Setup;
                    num4 = num2;
                    TrackEntry trackEntry = items3[i];
                    num4 *= Math.Max(0f, 1f - trackEntry.mixTime / trackEntry.mixDuration);
                    break;
                }
                }
                mixingFrom.totalAlpha += num4;
                RotateTimeline rotateTimeline = timeline as RotateTimeline;
                if (rotateTimeline != null)
                {
                    ApplyRotateTimeline(rotateTimeline, skeleton, animationTime, num4, pose, items4, i << 1, flag3);
                }
                else
                {
                    timeline.Apply(skeleton, animationLast, animationTime, exposedList, num4, pose, MixDirection.Out);
                }
            }
            if (to.mixDuration > 0f)
            {
                QueueEvents(mixingFrom, animationTime);
            }
            events.Clear(clearArray: false);
            mixingFrom.nextAnimationLast = animationTime;
            mixingFrom.nextTrackLast     = mixingFrom.trackTime;
            return(num);
        }
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            PathConstraint constraint = skeleton.pathConstraints.Items[this.pathConstraintIndex];

            float[] frames = this.frames;
            if (time < frames[0])
            {
                if (pose != MixPose.Setup)
                {
                    if (pose != MixPose.Current)
                    {
                        return;
                    }
                }
                else
                {
                    constraint.position = constraint.data.position;
                    return;
                }
                constraint.position += (constraint.data.position - constraint.position) * alpha;
            }
            else
            {
                float num;
                if (time >= frames[frames.Length - 2])
                {
                    num = frames[frames.Length + -1];
                }
                else
                {
                    int index = Animation.BinarySearch(frames, time, 2);
                    num = frames[index + -1];
                    float num3         = frames[index];
                    float curvePercent = base.GetCurvePercent((index / 2) - 1, 1f - ((time - num3) / (frames[index + -2] - num3)));
                    num += (frames[index + 1] - num) * curvePercent;
                }
                if (pose == MixPose.Setup)
                {
                    constraint.position = constraint.data.position + ((num - constraint.data.position) * alpha);
                }
                else
                {
                    constraint.position += (num - constraint.position) * alpha;
                }
            }
        }
示例#24
0
        private static void ApplyRotateTimeline(RotateTimeline rotateTimeline, Skeleton skeleton, float time, float alpha, MixPose pose, float[] timelinesRotation, int i, bool firstFrame)
        {
            if (firstFrame)
            {
                timelinesRotation[i] = 0f;
            }
            if (alpha == 1f)
            {
                rotateTimeline.Apply(skeleton, 0f, time, null, 1f, pose, MixDirection.In);
                return;
            }
            Bone bone = skeleton.bones.Items[rotateTimeline.boneIndex];

            float[] frames = rotateTimeline.frames;
            if (time < frames[0])
            {
                if (pose == MixPose.Setup)
                {
                    bone.rotation = bone.data.rotation;
                }
                return;
            }
            float num;

            if (time >= frames[frames.Length - 2])
            {
                num = bone.data.rotation + frames[frames.Length + -1];
            }
            else
            {
                int   num2         = Animation.BinarySearch(frames, time, 2);
                float num3         = frames[num2 + -1];
                float num4         = frames[num2];
                float curvePercent = rotateTimeline.GetCurvePercent((num2 >> 1) - 1, 1f - (time - num4) / (frames[num2 + -2] - num4));
                num  = frames[num2 + 1] - num3;
                num -= (float)((16384 - (int)(16384.499999999996 - (double)(num / 360f))) * 360);
                num  = num3 + num * curvePercent + bone.data.rotation;
                num -= (float)((16384 - (int)(16384.499999999996 - (double)(num / 360f))) * 360);
            }
            float num5 = (pose != 0) ? bone.rotation : bone.data.rotation;
            float num6 = num - num5;
            float num7;

            if (num6 == 0f)
            {
                num7 = timelinesRotation[i];
            }
            else
            {
                num6 -= (float)((16384 - (int)(16384.499999999996 - (double)(num6 / 360f))) * 360);
                float num8;
                float value;
                if (firstFrame)
                {
                    num8  = 0f;
                    value = num6;
                }
                else
                {
                    num8  = timelinesRotation[i];
                    value = timelinesRotation[i + 1];
                }
                bool flag  = num6 > 0f;
                bool flag2 = num8 >= 0f;
                if (Math.Sign(value) != Math.Sign(num6) && Math.Abs(value) <= 90f)
                {
                    if (Math.Abs(num8) > 180f)
                    {
                        num8 += (float)(360 * Math.Sign(num8));
                    }
                    flag2 = flag;
                }
                num7 = num6 + num8 - num8 % 360f;
                if (flag2 != flag)
                {
                    num7 += (float)(360 * Math.Sign(num8));
                }
                timelinesRotation[i] = num7;
            }
            timelinesRotation[i + 1] = num6;
            num5         += num7 * alpha;
            bone.rotation = num5 - (float)((16384 - (int)(16384.499999999996 - (double)(num5 / 360f))) * 360);
        }
示例#25
0
        public void Apply(Skeleton skeleton, float lastTime, float time, bool loop, ExposedList <Event> events, float alpha, MixPose pose, MixDirection direction)
        {
            if (skeleton == null)
            {
                throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
            }
            if (loop && duration != 0f)
            {
                time %= duration;
                if (lastTime > 0f)
                {
                    lastTime %= duration;
                }
            }
            ExposedList <Timeline> exposedList = timelines;
            int i = 0;

            for (int count = exposedList.Count; i < count; i++)
            {
                exposedList.Items[i].Apply(skeleton, lastTime, time, events, alpha, pose, direction);
            }
        }
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            Slot slot = skeleton.slots.Items[this.slotIndex];

            float[] frames = this.frames;
            if (time < frames[0])
            {
                SlotData data = slot.data;
                if (pose != MixPose.Setup)
                {
                    if (pose != MixPose.Current)
                    {
                        return;
                    }
                }
                else
                {
                    slot.r  = data.r;
                    slot.g  = data.g;
                    slot.b  = data.b;
                    slot.a  = data.a;
                    slot.r2 = data.r2;
                    slot.g2 = data.g2;
                    slot.b2 = data.b2;
                    return;
                }
                slot.r  += (slot.r - data.r) * alpha;
                slot.g  += (slot.g - data.g) * alpha;
                slot.b  += (slot.b - data.b) * alpha;
                slot.a  += (slot.a - data.a) * alpha;
                slot.r2 += (slot.r2 - data.r2) * alpha;
                slot.g2 += (slot.g2 - data.g2) * alpha;
                slot.b2 += (slot.b2 - data.b2) * alpha;
            }
            else
            {
                float num;
                float num2;
                float num3;
                float num4;
                float num5;
                float num6;
                float num7;
                if (time >= frames[frames.Length - 8])
                {
                    int length = frames.Length;
                    num  = frames[length + -7];
                    num2 = frames[length + -6];
                    num3 = frames[length + -5];
                    num4 = frames[length + -4];
                    num5 = frames[length + -3];
                    num6 = frames[length + -2];
                    num7 = frames[length + -1];
                }
                else
                {
                    int index = Animation.BinarySearch(frames, time, 8);
                    num  = frames[index + -7];
                    num2 = frames[index + -6];
                    num3 = frames[index + -5];
                    num4 = frames[index + -4];
                    num5 = frames[index + -3];
                    num6 = frames[index + -2];
                    num7 = frames[index + -1];
                    float num10        = frames[index];
                    float curvePercent = base.GetCurvePercent((index / 8) - 1, 1f - ((time - num10) / (frames[index + -8] - num10)));
                    num  += (frames[index + 1] - num) * curvePercent;
                    num2 += (frames[index + 2] - num2) * curvePercent;
                    num3 += (frames[index + 3] - num3) * curvePercent;
                    num4 += (frames[index + 4] - num4) * curvePercent;
                    num5 += (frames[index + 5] - num5) * curvePercent;
                    num6 += (frames[index + 6] - num6) * curvePercent;
                    num7 += (frames[index + 7] - num7) * curvePercent;
                }
                if (alpha == 1f)
                {
                    slot.r  = num;
                    slot.g  = num2;
                    slot.b  = num3;
                    slot.a  = num4;
                    slot.r2 = num5;
                    slot.g2 = num6;
                    slot.b2 = num7;
                }
                else
                {
                    float r;
                    float g;
                    float b;
                    float a;
                    float num16;
                    float num17;
                    float num18;
                    if (pose == MixPose.Setup)
                    {
                        r     = slot.data.r;
                        g     = slot.data.g;
                        b     = slot.data.b;
                        a     = slot.data.a;
                        num16 = slot.data.r2;
                        num17 = slot.data.g2;
                        num18 = slot.data.b2;
                    }
                    else
                    {
                        r     = slot.r;
                        g     = slot.g;
                        b     = slot.b;
                        a     = slot.a;
                        num16 = slot.r2;
                        num17 = slot.g2;
                        num18 = slot.b2;
                    }
                    slot.r  = r + ((num - r) * alpha);
                    slot.g  = g + ((num2 - g) * alpha);
                    slot.b  = b + ((num3 - b) * alpha);
                    slot.a  = a + ((num4 - a) * alpha);
                    slot.r2 = num16 + ((num5 - num16) * alpha);
                    slot.g2 = num17 + ((num6 - num17) * alpha);
                    slot.b2 = num18 + ((num7 - num18) * alpha);
                }
            }
        }
示例#27
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            TransformConstraint constraint = skeleton.transformConstraints.Items[this.transformConstraintIndex];

            float[] frames = this.frames;
            if (time < frames[0])
            {
                TransformConstraintData data = constraint.data;
                if (pose != MixPose.Setup)
                {
                    if (pose != MixPose.Current)
                    {
                        return;
                    }
                }
                else
                {
                    constraint.rotateMix    = data.rotateMix;
                    constraint.translateMix = data.translateMix;
                    constraint.scaleMix     = data.scaleMix;
                    constraint.shearMix     = data.shearMix;
                    return;
                }
                constraint.rotateMix    += (data.rotateMix - constraint.rotateMix) * alpha;
                constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
                constraint.scaleMix     += (data.scaleMix - constraint.scaleMix) * alpha;
                constraint.shearMix     += (data.shearMix - constraint.shearMix) * alpha;
            }
            else
            {
                float num;
                float num2;
                float num3;
                float num4;
                if (time >= frames[frames.Length - 5])
                {
                    int length = frames.Length;
                    num  = frames[length + -4];
                    num2 = frames[length + -3];
                    num3 = frames[length + -2];
                    num4 = frames[length + -1];
                }
                else
                {
                    int index = Animation.BinarySearch(frames, time, 5);
                    num  = frames[index + -4];
                    num2 = frames[index + -3];
                    num3 = frames[index + -2];
                    num4 = frames[index + -1];
                    float num7         = frames[index];
                    float curvePercent = base.GetCurvePercent((index / 5) - 1, 1f - ((time - num7) / (frames[index + -5] - num7)));
                    num  += (frames[index + 1] - num) * curvePercent;
                    num2 += (frames[index + 2] - num2) * curvePercent;
                    num3 += (frames[index + 3] - num3) * curvePercent;
                    num4 += (frames[index + 4] - num4) * curvePercent;
                }
                if (pose == MixPose.Setup)
                {
                    TransformConstraintData data = constraint.data;
                    constraint.rotateMix    = data.rotateMix + ((num - data.rotateMix) * alpha);
                    constraint.translateMix = data.translateMix + ((num2 - data.translateMix) * alpha);
                    constraint.scaleMix     = data.scaleMix + ((num3 - data.scaleMix) * alpha);
                    constraint.shearMix     = data.shearMix + ((num4 - data.shearMix) * alpha);
                }
                else
                {
                    constraint.rotateMix    += (num - constraint.rotateMix) * alpha;
                    constraint.translateMix += (num2 - constraint.translateMix) * alpha;
                    constraint.scaleMix     += (num3 - constraint.scaleMix) * alpha;
                    constraint.shearMix     += (num4 - constraint.shearMix) * alpha;
                }
            }
        }
示例#28
0
        public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction)
        {
            Slot             slot             = skeleton.slots.Items[slotIndex];
            VertexAttachment vertexAttachment = slot.attachment as VertexAttachment;

            if (vertexAttachment == null || !vertexAttachment.ApplyDeform(attachment))
            {
                return;
            }
            ExposedList <float> attachmentVertices = slot.attachmentVertices;

            float[][] array = frameVertices;
            int       num   = array[0].Length;

            if (attachmentVertices.Capacity < num)
            {
                attachmentVertices.Capacity = num;
            }
            attachmentVertices.Count = num;
            float[] items  = attachmentVertices.Items;
            float[] array2 = frames;
            if (time < array2[0])
            {
                switch (pose)
                {
                case MixPose.Setup:
                {
                    float[] array3;
                    if (vertexAttachment.bones == null)
                    {
                        array3 = vertexAttachment.vertices;
                    }
                    else
                    {
                        array3 = zeros;
                        if (array3.Length < num)
                        {
                            array3 = (zeros = new float[num]);
                        }
                    }
                    Array.Copy(array3, 0, items, 0, num);
                    break;
                }

                case MixPose.Current:
                    if (alpha == 1f)
                    {
                        break;
                    }
                    if (vertexAttachment.bones == null)
                    {
                        float[] vertices = vertexAttachment.vertices;
                        for (int i = 0; i < num; i++)
                        {
                            items[i] += (vertices[i] - items[i]) * alpha;
                        }
                    }
                    else
                    {
                        alpha = 1f - alpha;
                        for (int j = 0; j < num; j++)
                        {
                            items[j] *= alpha;
                        }
                    }
                    break;
                }
                return;
            }
            if (time >= array2[array2.Length - 1])
            {
                float[] array4 = array[array2.Length - 1];
                if (alpha == 1f)
                {
                    Array.Copy(array4, 0, items, 0, num);
                }
                else if (pose == MixPose.Setup)
                {
                    if (vertexAttachment.bones == null)
                    {
                        float[] vertices2 = vertexAttachment.vertices;
                        for (int k = 0; k < num; k++)
                        {
                            float num2 = vertices2[k];
                            items[k] = num2 + (array4[k] - num2) * alpha;
                        }
                    }
                    else
                    {
                        for (int l = 0; l < num; l++)
                        {
                            items[l] = array4[l] * alpha;
                        }
                    }
                }
                else
                {
                    for (int m = 0; m < num; m++)
                    {
                        items[m] += (array4[m] - items[m]) * alpha;
                    }
                }
                return;
            }
            int num3 = Animation.BinarySearch(array2, time);

            float[] array5       = array[num3 - 1];
            float[] array6       = array[num3];
            float   num4         = array2[num3];
            float   curvePercent = GetCurvePercent(num3 - 1, 1f - (time - num4) / (array2[num3 - 1] - num4));

            if (alpha == 1f)
            {
                for (int n = 0; n < num; n++)
                {
                    float num5 = array5[n];
                    items[n] = num5 + (array6[n] - num5) * curvePercent;
                }
            }
            else if (pose == MixPose.Setup)
            {
                if (vertexAttachment.bones == null)
                {
                    float[] vertices3 = vertexAttachment.vertices;
                    for (int num6 = 0; num6 < num; num6++)
                    {
                        float num7 = array5[num6];
                        float num8 = vertices3[num6];
                        items[num6] = num8 + (num7 + (array6[num6] - num7) * curvePercent - num8) * alpha;
                    }
                }
                else
                {
                    for (int num9 = 0; num9 < num; num9++)
                    {
                        float num10 = array5[num9];
                        items[num9] = (num10 + (array6[num9] - num10) * curvePercent) * alpha;
                    }
                }
            }
            else
            {
                for (int num11 = 0; num11 < num; num11++)
                {
                    float num12 = array5[num11];
                    items[num11] += (num12 + (array6[num11] - num12) * curvePercent - items[num11]) * alpha;
                }
            }
        }
示例#29
0
 public abstract void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction);
        // NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties.
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            trackBindingSkeletonAnimation = playerData as SkeletonAnimation;
            if (!trackBindingSkeletonAnimation)
            {
                return;
            }

            int inputCount = playable.GetInputCount();

            if (trackBindingSkeleton == null)
            {
                trackBindingSkeleton = trackBindingSkeletonAnimation.Skeleton;
            }

            //trackBindingSkeleton.SetToSetupPose();
            for (int i = 0; i < inputCount; i++)
            {
                var inputPlayable     = (ScriptPlayable <SpineAnimationBehaviour>)playable.GetInput(i); // The clip
                var clipBehaviourData = inputPlayable.GetBehaviour();                                   // the stateless data

                clipBehaviourData.EnsureInitialize(trackBindingSkeleton.Data);
                var animation = clipBehaviourData.animation;
                if (animation != null)
                {
                    animation.SetKeyedItemsToSetupPose(trackBindingSkeleton);
                }
            }

            float totalWeight   = 0f;
            int   currentInputs = 0;

            for (int i = 0; i < inputCount; i++)
            {
                float inputWeight       = playable.GetInputWeight(i);
                var   inputPlayable     = (ScriptPlayable <SpineAnimationBehaviour>)playable.GetInput(i); // The clip
                var   clipBehaviourData = inputPlayable.GetBehaviour();                                   // the stateless data

                float time = (float)inputPlayable.GetTime();                                              // clip time.

                totalWeight += inputWeight;
//				clipBehaviourData.EnsureInitialize(trackBindingSkeleton.Data);
                var animation = clipBehaviourData.animation;
                if (animation != null)
                {
                    if (!Mathf.Approximately(inputWeight, 0f))
                    {
                        MixPose      mixPose      = currentInputs == 0 ? MixPose.Setup : MixPose.Current;
                        MixDirection mixDirection = MixDirection.In;

                        if (inputWeight < 1 && currentInputs > 1)
                        {
                            mixDirection = MixDirection.Out;
                        }

                        animation.Apply(trackBindingSkeleton, 0f, time, clipBehaviourData.loop, null, inputWeight, mixPose, mixDirection);
                        Debug.LogFormat("Applying {0} at {1} as input [{2}] using {3} {4}", animation.Name, inputWeight, i, mixPose, mixDirection);

                        currentInputs++;
                    }
                    else
                    {
                        //animation.Apply(trackBindingSkeleton, 0f, time, clipBehaviourData.loop, null, 0, MixPose.Current, MixDirection.Out);
                        continue;
                    }
                }
                // SPINETODO: Translate AnimationState into MixerBehaviour for robustness.
            }
        }