private void ReadAnimation(string name, Stream input, SkeletonData skeletonData) { ExposedList <Timeline> exposedList = new ExposedList <Timeline>(); float scale = Scale; float num = 0f; int i = 0; for (int num2 = ReadVarint(input, optimizePositive: true); i < num2; i++) { int slotIndex = ReadVarint(input, optimizePositive: true); int j = 0; for (int num3 = ReadVarint(input, optimizePositive: true); j < num3; j++) { int num4 = input.ReadByte(); int num5 = ReadVarint(input, optimizePositive: true); switch (num4) { case 0: { AttachmentTimeline attachmentTimeline = new AttachmentTimeline(num5); attachmentTimeline.slotIndex = slotIndex; for (int m = 0; m < num5; m++) { attachmentTimeline.SetFrame(m, ReadFloat(input), ReadString(input)); } exposedList.Add(attachmentTimeline); num = Math.Max(num, attachmentTimeline.frames[num5 - 1]); break; } case 1: { ColorTimeline colorTimeline = new ColorTimeline(num5); colorTimeline.slotIndex = slotIndex; for (int l = 0; l < num5; l++) { float time2 = ReadFloat(input); int num8 = ReadInt(input); float r3 = (float)((num8 & 4278190080u) >> 24) / 255f; float g3 = (float)((num8 & 0xFF0000) >> 16) / 255f; float b3 = (float)((num8 & 0xFF00) >> 8) / 255f; float a2 = (float)(num8 & 0xFF) / 255f; colorTimeline.SetFrame(l, time2, r3, g3, b3, a2); if (l < num5 - 1) { ReadCurve(input, l, colorTimeline); } } exposedList.Add(colorTimeline); num = Math.Max(num, colorTimeline.frames[(colorTimeline.FrameCount - 1) * 5]); break; } case 2: { TwoColorTimeline twoColorTimeline = new TwoColorTimeline(num5); twoColorTimeline.slotIndex = slotIndex; for (int k = 0; k < num5; k++) { float time = ReadFloat(input); int num6 = ReadInt(input); float r = (float)((num6 & 4278190080u) >> 24) / 255f; float g = (float)((num6 & 0xFF0000) >> 16) / 255f; float b = (float)((num6 & 0xFF00) >> 8) / 255f; float a = (float)(num6 & 0xFF) / 255f; int num7 = ReadInt(input); float r2 = (float)((num7 & 0xFF0000) >> 16) / 255f; float g2 = (float)((num7 & 0xFF00) >> 8) / 255f; float b2 = (float)(num7 & 0xFF) / 255f; twoColorTimeline.SetFrame(k, time, r, g, b, a, r2, g2, b2); if (k < num5 - 1) { ReadCurve(input, k, twoColorTimeline); } } exposedList.Add(twoColorTimeline); num = Math.Max(num, twoColorTimeline.frames[(twoColorTimeline.FrameCount - 1) * 8]); break; } } } } int n = 0; for (int num9 = ReadVarint(input, optimizePositive: true); n < num9; n++) { int boneIndex = ReadVarint(input, optimizePositive: true); int num10 = 0; for (int num11 = ReadVarint(input, optimizePositive: true); num10 < num11; num10++) { int num12 = input.ReadByte(); int num13 = ReadVarint(input, optimizePositive: true); switch (num12) { case 0: { RotateTimeline rotateTimeline = new RotateTimeline(num13); rotateTimeline.boneIndex = boneIndex; for (int num16 = 0; num16 < num13; num16++) { rotateTimeline.SetFrame(num16, ReadFloat(input), ReadFloat(input)); if (num16 < num13 - 1) { ReadCurve(input, num16, rotateTimeline); } } exposedList.Add(rotateTimeline); num = Math.Max(num, rotateTimeline.frames[(num13 - 1) * 2]); break; } case 1: case 2: case 3: { float num14 = 1f; TranslateTimeline translateTimeline; switch (num12) { case 2: translateTimeline = new ScaleTimeline(num13); break; case 3: translateTimeline = new ShearTimeline(num13); break; default: translateTimeline = new TranslateTimeline(num13); num14 = scale; break; } translateTimeline.boneIndex = boneIndex; for (int num15 = 0; num15 < num13; num15++) { translateTimeline.SetFrame(num15, ReadFloat(input), ReadFloat(input) * num14, ReadFloat(input) * num14); if (num15 < num13 - 1) { ReadCurve(input, num15, translateTimeline); } } exposedList.Add(translateTimeline); num = Math.Max(num, translateTimeline.frames[(num13 - 1) * 3]); break; } } } } int num17 = 0; for (int num18 = ReadVarint(input, optimizePositive: true); num17 < num18; num17++) { int ikConstraintIndex = ReadVarint(input, optimizePositive: true); int num19 = ReadVarint(input, optimizePositive: true); IkConstraintTimeline ikConstraintTimeline = new IkConstraintTimeline(num19); ikConstraintTimeline.ikConstraintIndex = ikConstraintIndex; for (int num20 = 0; num20 < num19; num20++) { ikConstraintTimeline.SetFrame(num20, ReadFloat(input), ReadFloat(input), ReadSByte(input)); if (num20 < num19 - 1) { ReadCurve(input, num20, ikConstraintTimeline); } } exposedList.Add(ikConstraintTimeline); num = Math.Max(num, ikConstraintTimeline.frames[(num19 - 1) * 3]); } int num21 = 0; for (int num22 = ReadVarint(input, optimizePositive: true); num21 < num22; num21++) { int transformConstraintIndex = ReadVarint(input, optimizePositive: true); int num23 = ReadVarint(input, optimizePositive: true); TransformConstraintTimeline transformConstraintTimeline = new TransformConstraintTimeline(num23); transformConstraintTimeline.transformConstraintIndex = transformConstraintIndex; for (int num24 = 0; num24 < num23; num24++) { transformConstraintTimeline.SetFrame(num24, ReadFloat(input), ReadFloat(input), ReadFloat(input), ReadFloat(input), ReadFloat(input)); if (num24 < num23 - 1) { ReadCurve(input, num24, transformConstraintTimeline); } } exposedList.Add(transformConstraintTimeline); num = Math.Max(num, transformConstraintTimeline.frames[(num23 - 1) * 5]); } int num25 = 0; for (int num26 = ReadVarint(input, optimizePositive: true); num25 < num26; num25++) { int num27 = ReadVarint(input, optimizePositive: true); PathConstraintData pathConstraintData = skeletonData.pathConstraints.Items[num27]; int num28 = 0; for (int num29 = ReadVarint(input, optimizePositive: true); num28 < num29; num28++) { int num30 = ReadSByte(input); int num31 = ReadVarint(input, optimizePositive: true); switch (num30) { case 0: case 1: { float num33 = 1f; PathConstraintPositionTimeline pathConstraintPositionTimeline; if (num30 == 1) { pathConstraintPositionTimeline = new PathConstraintSpacingTimeline(num31); if (pathConstraintData.spacingMode == SpacingMode.Length || pathConstraintData.spacingMode == SpacingMode.Fixed) { num33 = scale; } } else { pathConstraintPositionTimeline = new PathConstraintPositionTimeline(num31); if (pathConstraintData.positionMode == PositionMode.Fixed) { num33 = scale; } } pathConstraintPositionTimeline.pathConstraintIndex = num27; for (int num34 = 0; num34 < num31; num34++) { pathConstraintPositionTimeline.SetFrame(num34, ReadFloat(input), ReadFloat(input) * num33); if (num34 < num31 - 1) { ReadCurve(input, num34, pathConstraintPositionTimeline); } } exposedList.Add(pathConstraintPositionTimeline); num = Math.Max(num, pathConstraintPositionTimeline.frames[(num31 - 1) * 2]); break; } case 2: { PathConstraintMixTimeline pathConstraintMixTimeline = new PathConstraintMixTimeline(num31); pathConstraintMixTimeline.pathConstraintIndex = num27; for (int num32 = 0; num32 < num31; num32++) { pathConstraintMixTimeline.SetFrame(num32, ReadFloat(input), ReadFloat(input), ReadFloat(input)); if (num32 < num31 - 1) { ReadCurve(input, num32, pathConstraintMixTimeline); } } exposedList.Add(pathConstraintMixTimeline); num = Math.Max(num, pathConstraintMixTimeline.frames[(num31 - 1) * 3]); break; } } } } int num35 = 0; for (int num36 = ReadVarint(input, optimizePositive: true); num35 < num36; num35++) { Skin skin = skeletonData.skins.Items[ReadVarint(input, optimizePositive: true)]; int num37 = 0; for (int num38 = ReadVarint(input, optimizePositive: true); num37 < num38; num37++) { int slotIndex2 = ReadVarint(input, optimizePositive: true); int num39 = 0; for (int num40 = ReadVarint(input, optimizePositive: true); num39 < num40; num39++) { VertexAttachment vertexAttachment = (VertexAttachment)skin.GetAttachment(slotIndex2, ReadString(input)); bool flag = vertexAttachment.bones != null; float[] vertices = vertexAttachment.vertices; int num41 = (!flag) ? vertices.Length : (vertices.Length / 3 * 2); int num42 = ReadVarint(input, optimizePositive: true); DeformTimeline deformTimeline = new DeformTimeline(num42); deformTimeline.slotIndex = slotIndex2; deformTimeline.attachment = vertexAttachment; for (int num43 = 0; num43 < num42; num43++) { float time3 = ReadFloat(input); int num44 = ReadVarint(input, optimizePositive: true); float[] array; if (num44 == 0) { array = ((!flag) ? vertices : new float[num41]); } else { array = new float[num41]; int num45 = ReadVarint(input, optimizePositive: true); num44 += num45; if (scale == 1f) { for (int num46 = num45; num46 < num44; num46++) { array[num46] = ReadFloat(input); } } else { for (int num47 = num45; num47 < num44; num47++) { array[num47] = ReadFloat(input) * scale; } } if (!flag) { int num48 = 0; for (int num49 = array.Length; num48 < num49; num48++) { array[num48] += vertices[num48]; } } } deformTimeline.SetFrame(num43, time3, array); if (num43 < num42 - 1) { ReadCurve(input, num43, deformTimeline); } } exposedList.Add(deformTimeline); num = Math.Max(num, deformTimeline.frames[num42 - 1]); } } } int num50 = ReadVarint(input, optimizePositive: true); if (num50 > 0) { DrawOrderTimeline drawOrderTimeline = new DrawOrderTimeline(num50); int count = skeletonData.slots.Count; for (int num51 = 0; num51 < num50; num51++) { float time4 = ReadFloat(input); int num52 = ReadVarint(input, optimizePositive: true); int[] array2 = new int[count]; for (int num53 = count - 1; num53 >= 0; num53--) { array2[num53] = -1; } int[] array3 = new int[count - num52]; int num54 = 0; int num55 = 0; for (int num56 = 0; num56 < num52; num56++) { int num57 = ReadVarint(input, optimizePositive: true); while (num54 != num57) { array3[num55++] = num54++; } array2[num54 + ReadVarint(input, optimizePositive: true)] = num54++; } while (num54 < count) { array3[num55++] = num54++; } for (int num63 = count - 1; num63 >= 0; num63--) { if (array2[num63] == -1) { array2[num63] = array3[--num55]; } } drawOrderTimeline.SetFrame(num51, time4, array2); } exposedList.Add(drawOrderTimeline); num = Math.Max(num, drawOrderTimeline.frames[num50 - 1]); } int num64 = ReadVarint(input, optimizePositive: true); if (num64 > 0) { EventTimeline eventTimeline = new EventTimeline(num64); for (int num65 = 0; num65 < num64; num65++) { float time5 = ReadFloat(input); EventData eventData = skeletonData.events.Items[ReadVarint(input, optimizePositive: true)]; Event @event = new Event(time5, eventData); @event.Int = ReadVarint(input, optimizePositive: false); @event.Float = ReadFloat(input); @event.String = ((!ReadBoolean(input)) ? eventData.String : ReadString(input)); eventTimeline.SetFrame(num65, @event); } exposedList.Add(eventTimeline); num = Math.Max(num, eventTimeline.frames[num64 - 1]); } exposedList.TrimExcess(); skeletonData.animations.Add(new Animation(name, exposedList, num)); }
private void ReadAnimation(String name, Stream input, SkeletonData skeletonData) { var timelines = new ExposedList <Timeline>(); float scale = Scale; float duration = 0; // Slot timelines. for (int i = 0, n = ReadVarint(input, true); i < n; i++) { int slotIndex = ReadVarint(input, true); for (int ii = 0, nn = ReadVarint(input, true); ii < nn; ii++) { int timelineType = input.ReadByte(); int frameCount = ReadVarint(input, true); switch (timelineType) { case SLOT_ATTACHMENT: { AttachmentTimeline timeline = new AttachmentTimeline(frameCount); timeline.slotIndex = slotIndex; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { timeline.SetFrame(frameIndex, ReadFloat(input), ReadString(input)); } timelines.Add(timeline); duration = Math.Max(duration, timeline.frames[frameCount - 1]); break; } case SLOT_COLOR: { ColorTimeline timeline = new ColorTimeline(frameCount); timeline.slotIndex = slotIndex; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { float time = ReadFloat(input); int color = ReadInt(input); float r = ((color & 0xff000000) >> 24) / 255f; float g = ((color & 0x00ff0000) >> 16) / 255f; float b = ((color & 0x0000ff00) >> 8) / 255f; float a = ((color & 0x000000ff)) / 255f; timeline.SetFrame(frameIndex, time, r, g, b, a); if (frameIndex < frameCount - 1) { ReadCurve(input, frameIndex, timeline); } } timelines.Add(timeline); duration = Math.Max(duration, timeline.frames[(timeline.FrameCount - 1) * ColorTimeline.ENTRIES]); break; } case SLOT_TWO_COLOR: { TwoColorTimeline timeline = new TwoColorTimeline(frameCount); timeline.slotIndex = slotIndex; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { float time = ReadFloat(input); int color = ReadInt(input); float r = ((color & 0xff000000) >> 24) / 255f; float g = ((color & 0x00ff0000) >> 16) / 255f; float b = ((color & 0x0000ff00) >> 8) / 255f; float a = ((color & 0x000000ff)) / 255f; int color2 = ReadInt(input); // 0x00rrggbb float r2 = ((color2 & 0x00ff0000) >> 16) / 255f; float g2 = ((color2 & 0x0000ff00) >> 8) / 255f; float b2 = ((color2 & 0x000000ff)) / 255f; timeline.SetFrame(frameIndex, time, r, g, b, a, r2, g2, b2); if (frameIndex < frameCount - 1) { ReadCurve(input, frameIndex, timeline); } } timelines.Add(timeline); duration = Math.Max(duration, timeline.frames[(timeline.FrameCount - 1) * TwoColorTimeline.ENTRIES]); break; } } } } // Bone timelines. for (int i = 0, n = ReadVarint(input, true); i < n; i++) { int boneIndex = ReadVarint(input, true); for (int ii = 0, nn = ReadVarint(input, true); ii < nn; ii++) { int timelineType = input.ReadByte(); int frameCount = ReadVarint(input, true); switch (timelineType) { case BONE_ROTATE: { RotateTimeline timeline = new RotateTimeline(frameCount); timeline.boneIndex = boneIndex; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { timeline.SetFrame(frameIndex, ReadFloat(input), ReadFloat(input)); if (frameIndex < frameCount - 1) { ReadCurve(input, frameIndex, timeline); } } timelines.Add(timeline); duration = Math.Max(duration, timeline.frames[(frameCount - 1) * RotateTimeline.ENTRIES]); break; } case BONE_TRANSLATE: case BONE_SCALE: case BONE_SHEAR: { TranslateTimeline timeline; float timelineScale = 1; if (timelineType == BONE_SCALE) { timeline = new ScaleTimeline(frameCount); } else if (timelineType == BONE_SHEAR) { timeline = new ShearTimeline(frameCount); } else { timeline = new TranslateTimeline(frameCount); timelineScale = scale; } timeline.boneIndex = boneIndex; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { timeline.SetFrame(frameIndex, ReadFloat(input), ReadFloat(input) * timelineScale, ReadFloat(input) * timelineScale); if (frameIndex < frameCount - 1) { ReadCurve(input, frameIndex, timeline); } } timelines.Add(timeline); duration = Math.Max(duration, timeline.frames[(frameCount - 1) * TranslateTimeline.ENTRIES]); break; } } } } // IK timelines. for (int i = 0, n = ReadVarint(input, true); i < n; i++) { int index = ReadVarint(input, true); int frameCount = ReadVarint(input, true); IkConstraintTimeline timeline = new IkConstraintTimeline(frameCount); timeline.ikConstraintIndex = index; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { timeline.SetFrame(frameIndex, ReadFloat(input), ReadFloat(input), ReadSByte(input)); if (frameIndex < frameCount - 1) { ReadCurve(input, frameIndex, timeline); } } timelines.Add(timeline); duration = Math.Max(duration, timeline.frames[(frameCount - 1) * IkConstraintTimeline.ENTRIES]); } // Transform constraint timelines. for (int i = 0, n = ReadVarint(input, true); i < n; i++) { int index = ReadVarint(input, true); int frameCount = ReadVarint(input, true); TransformConstraintTimeline timeline = new TransformConstraintTimeline(frameCount); timeline.transformConstraintIndex = index; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { timeline.SetFrame(frameIndex, ReadFloat(input), ReadFloat(input), ReadFloat(input), ReadFloat(input), ReadFloat(input)); if (frameIndex < frameCount - 1) { ReadCurve(input, frameIndex, timeline); } } timelines.Add(timeline); duration = Math.Max(duration, timeline.frames[(frameCount - 1) * TransformConstraintTimeline.ENTRIES]); } // Path constraint timelines. for (int i = 0, n = ReadVarint(input, true); i < n; i++) { int index = ReadVarint(input, true); PathConstraintData data = skeletonData.pathConstraints.Items[index]; for (int ii = 0, nn = ReadVarint(input, true); ii < nn; ii++) { int timelineType = ReadSByte(input); int frameCount = ReadVarint(input, true); switch (timelineType) { case PATH_POSITION: case PATH_SPACING: { PathConstraintPositionTimeline timeline; float timelineScale = 1; if (timelineType == PATH_SPACING) { timeline = new PathConstraintSpacingTimeline(frameCount); if (data.spacingMode == SpacingMode.Length || data.spacingMode == SpacingMode.Fixed) { timelineScale = scale; } } else { timeline = new PathConstraintPositionTimeline(frameCount); if (data.positionMode == PositionMode.Fixed) { timelineScale = scale; } } timeline.pathConstraintIndex = index; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { timeline.SetFrame(frameIndex, ReadFloat(input), ReadFloat(input) * timelineScale); if (frameIndex < frameCount - 1) { ReadCurve(input, frameIndex, timeline); } } timelines.Add(timeline); duration = Math.Max(duration, timeline.frames[(frameCount - 1) * PathConstraintPositionTimeline.ENTRIES]); break; } case PATH_MIX: { PathConstraintMixTimeline timeline = new PathConstraintMixTimeline(frameCount); timeline.pathConstraintIndex = index; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { timeline.SetFrame(frameIndex, ReadFloat(input), ReadFloat(input), ReadFloat(input)); if (frameIndex < frameCount - 1) { ReadCurve(input, frameIndex, timeline); } } timelines.Add(timeline); duration = Math.Max(duration, timeline.frames[(frameCount - 1) * PathConstraintMixTimeline.ENTRIES]); break; } } } } // Deform timelines. for (int i = 0, n = ReadVarint(input, true); i < n; i++) { Skin skin = skeletonData.skins.Items[ReadVarint(input, true)]; for (int ii = 0, nn = ReadVarint(input, true); ii < nn; ii++) { int slotIndex = ReadVarint(input, true); for (int iii = 0, nnn = ReadVarint(input, true); iii < nnn; iii++) { VertexAttachment attachment = (VertexAttachment)skin.GetAttachment(slotIndex, ReadString(input)); bool weighted = attachment.bones != null; float[] vertices = attachment.vertices; int deformLength = weighted ? vertices.Length / 3 * 2 : vertices.Length; int frameCount = ReadVarint(input, true); DeformTimeline timeline = new DeformTimeline(frameCount); timeline.slotIndex = slotIndex; timeline.attachment = attachment; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { float time = ReadFloat(input); float[] deform; int end = ReadVarint(input, true); if (end == 0) { deform = weighted ? new float[deformLength] : vertices; } else { deform = new float[deformLength]; int start = ReadVarint(input, true); end += start; if (scale == 1) { for (int v = start; v < end; v++) { deform[v] = ReadFloat(input); } } else { for (int v = start; v < end; v++) { deform[v] = ReadFloat(input) * scale; } } if (!weighted) { for (int v = 0, vn = deform.Length; v < vn; v++) { deform[v] += vertices[v]; } } } timeline.SetFrame(frameIndex, time, deform); if (frameIndex < frameCount - 1) { ReadCurve(input, frameIndex, timeline); } } timelines.Add(timeline); duration = Math.Max(duration, timeline.frames[frameCount - 1]); } } } // Draw order timeline. int drawOrderCount = ReadVarint(input, true); if (drawOrderCount > 0) { DrawOrderTimeline timeline = new DrawOrderTimeline(drawOrderCount); int slotCount = skeletonData.slots.Count; for (int i = 0; i < drawOrderCount; i++) { float time = ReadFloat(input); int offsetCount = ReadVarint(input, true); int[] drawOrder = new int[slotCount]; for (int ii = slotCount - 1; ii >= 0; ii--) { drawOrder[ii] = -1; } int[] unchanged = new int[slotCount - offsetCount]; int originalIndex = 0, unchangedIndex = 0; for (int ii = 0; ii < offsetCount; ii++) { int slotIndex = ReadVarint(input, true); // Collect unchanged items. while (originalIndex != slotIndex) { unchanged[unchangedIndex++] = originalIndex++; } // Set changed items. drawOrder[originalIndex + ReadVarint(input, true)] = originalIndex++; } // Collect remaining unchanged items. while (originalIndex < slotCount) { unchanged[unchangedIndex++] = originalIndex++; } // Fill in unchanged items. for (int ii = slotCount - 1; ii >= 0; ii--) { if (drawOrder[ii] == -1) { drawOrder[ii] = unchanged[--unchangedIndex]; } } timeline.SetFrame(i, time, drawOrder); } timelines.Add(timeline); duration = Math.Max(duration, timeline.frames[drawOrderCount - 1]); } // Event timeline. int eventCount = ReadVarint(input, true); if (eventCount > 0) { EventTimeline timeline = new EventTimeline(eventCount); for (int i = 0; i < eventCount; i++) { float time = ReadFloat(input); EventData eventData = skeletonData.events.Items[ReadVarint(input, true)]; Event e = new Event(time, eventData); e.Int = ReadVarint(input, false); e.Float = ReadFloat(input); e.String = ReadBoolean(input) ? ReadString(input) : eventData.String; timeline.SetFrame(i, e); } timelines.Add(timeline); duration = Math.Max(duration, timeline.frames[eventCount - 1]); } timelines.TrimExcess(); skeletonData.animations.Add(new Animation(name, timelines, duration)); }
private void ReadAnimation(Dictionary <string, object> map, string name, SkeletonData skeletonData) { float scale = Scale; ExposedList <Timeline> exposedList = new ExposedList <Timeline>(); float num = 0f; if (map.ContainsKey("slots")) { foreach (KeyValuePair <string, object> item3 in (Dictionary <string, object>)map["slots"]) { string key = item3.Key; int slotIndex = skeletonData.FindSlotIndex(key); Dictionary <string, object> dictionary = (Dictionary <string, object>)item3.Value; foreach (KeyValuePair <string, object> item4 in dictionary) { List <object> list = (List <object>)item4.Value; string key2 = item4.Key; if (key2 == "attachment") { AttachmentTimeline attachmentTimeline = new AttachmentTimeline(list.Count); attachmentTimeline.slotIndex = slotIndex; int num2 = 0; foreach (Dictionary <string, object> item5 in list) { float time = (float)item5["time"]; attachmentTimeline.SetFrame(num2++, time, (string)item5["name"]); } exposedList.Add(attachmentTimeline); num = Math.Max(num, attachmentTimeline.frames[attachmentTimeline.FrameCount - 1]); } else if (key2 == "color") { ColorTimeline colorTimeline = new ColorTimeline(list.Count); colorTimeline.slotIndex = slotIndex; int num4 = 0; foreach (Dictionary <string, object> item6 in list) { float time2 = (float)item6["time"]; string hexString = (string)item6["color"]; colorTimeline.SetFrame(num4, time2, ToColor(hexString, 0), ToColor(hexString, 1), ToColor(hexString, 2), ToColor(hexString, 3)); ReadCurve(item6, colorTimeline, num4); num4++; } exposedList.Add(colorTimeline); num = Math.Max(num, colorTimeline.frames[(colorTimeline.FrameCount - 1) * 5]); } else { if (!(key2 == "twoColor")) { throw new Exception("Invalid timeline type for a slot: " + key2 + " (" + key + ")"); } TwoColorTimeline twoColorTimeline = new TwoColorTimeline(list.Count); twoColorTimeline.slotIndex = slotIndex; int num5 = 0; foreach (Dictionary <string, object> item7 in list) { float time3 = (float)item7["time"]; string hexString2 = (string)item7["light"]; string hexString3 = (string)item7["dark"]; twoColorTimeline.SetFrame(num5, time3, ToColor(hexString2, 0), ToColor(hexString2, 1), ToColor(hexString2, 2), ToColor(hexString2, 3), ToColor(hexString3, 0, 6), ToColor(hexString3, 1, 6), ToColor(hexString3, 2, 6)); ReadCurve(item7, twoColorTimeline, num5); num5++; } exposedList.Add(twoColorTimeline); num = Math.Max(num, twoColorTimeline.frames[(twoColorTimeline.FrameCount - 1) * 8]); } } } } if (map.ContainsKey("bones")) { foreach (KeyValuePair <string, object> item8 in (Dictionary <string, object>)map["bones"]) { string key3 = item8.Key; int num6 = skeletonData.FindBoneIndex(key3); if (num6 == -1) { throw new Exception("Bone not found: " + key3); } Dictionary <string, object> dictionary5 = (Dictionary <string, object>)item8.Value; foreach (KeyValuePair <string, object> item9 in dictionary5) { List <object> list2 = (List <object>)item9.Value; string key4 = item9.Key; if (key4 == "rotate") { RotateTimeline rotateTimeline = new RotateTimeline(list2.Count); rotateTimeline.boneIndex = num6; int num7 = 0; foreach (Dictionary <string, object> item10 in list2) { rotateTimeline.SetFrame(num7, (float)item10["time"], (float)item10["angle"]); ReadCurve(item10, rotateTimeline, num7); num7++; } exposedList.Add(rotateTimeline); num = Math.Max(num, rotateTimeline.frames[(rotateTimeline.FrameCount - 1) * 2]); } else { if (!(key4 == "translate") && !(key4 == "scale") && !(key4 == "shear")) { throw new Exception("Invalid timeline type for a bone: " + key4 + " (" + key3 + ")"); } float num8 = 1f; TranslateTimeline translateTimeline; if (key4 == "scale") { translateTimeline = new ScaleTimeline(list2.Count); } else if (key4 == "shear") { translateTimeline = new ShearTimeline(list2.Count); } else { translateTimeline = new TranslateTimeline(list2.Count); num8 = scale; } translateTimeline.boneIndex = num6; int num9 = 0; foreach (Dictionary <string, object> item11 in list2) { float time4 = (float)item11["time"]; float @float = GetFloat(item11, "x", 0f); float float2 = GetFloat(item11, "y", 0f); translateTimeline.SetFrame(num9, time4, @float * num8, float2 * num8); ReadCurve(item11, translateTimeline, num9); num9++; } exposedList.Add(translateTimeline); num = Math.Max(num, translateTimeline.frames[(translateTimeline.FrameCount - 1) * 3]); } } } } if (map.ContainsKey("ik")) { foreach (KeyValuePair <string, object> item12 in (Dictionary <string, object>)map["ik"]) { IkConstraintData item = skeletonData.FindIkConstraint(item12.Key); List <object> list3 = (List <object>)item12.Value; IkConstraintTimeline ikConstraintTimeline = new IkConstraintTimeline(list3.Count); ikConstraintTimeline.ikConstraintIndex = skeletonData.ikConstraints.IndexOf(item); int num10 = 0; foreach (Dictionary <string, object> item13 in list3) { float time5 = (float)item13["time"]; float float3 = GetFloat(item13, "mix", 1f); bool boolean = GetBoolean(item13, "bendPositive", defaultValue: true); ikConstraintTimeline.SetFrame(num10, time5, float3, boolean ? 1 : (-1)); ReadCurve(item13, ikConstraintTimeline, num10); num10++; } exposedList.Add(ikConstraintTimeline); num = Math.Max(num, ikConstraintTimeline.frames[(ikConstraintTimeline.FrameCount - 1) * 3]); } } if (map.ContainsKey("transform")) { foreach (KeyValuePair <string, object> item14 in (Dictionary <string, object>)map["transform"]) { TransformConstraintData item2 = skeletonData.FindTransformConstraint(item14.Key); List <object> list4 = (List <object>)item14.Value; TransformConstraintTimeline transformConstraintTimeline = new TransformConstraintTimeline(list4.Count); transformConstraintTimeline.transformConstraintIndex = skeletonData.transformConstraints.IndexOf(item2); int num11 = 0; foreach (Dictionary <string, object> item15 in list4) { float time6 = (float)item15["time"]; float float4 = GetFloat(item15, "rotateMix", 1f); float float5 = GetFloat(item15, "translateMix", 1f); float float6 = GetFloat(item15, "scaleMix", 1f); float float7 = GetFloat(item15, "shearMix", 1f); transformConstraintTimeline.SetFrame(num11, time6, float4, float5, float6, float7); ReadCurve(item15, transformConstraintTimeline, num11); num11++; } exposedList.Add(transformConstraintTimeline); num = Math.Max(num, transformConstraintTimeline.frames[(transformConstraintTimeline.FrameCount - 1) * 5]); } } if (map.ContainsKey("paths")) { foreach (KeyValuePair <string, object> item16 in (Dictionary <string, object>)map["paths"]) { int num12 = skeletonData.FindPathConstraintIndex(item16.Key); if (num12 == -1) { throw new Exception("Path constraint not found: " + item16.Key); } PathConstraintData pathConstraintData = skeletonData.pathConstraints.Items[num12]; Dictionary <string, object> dictionary10 = (Dictionary <string, object>)item16.Value; foreach (KeyValuePair <string, object> item17 in dictionary10) { List <object> list5 = (List <object>)item17.Value; string key5 = item17.Key; switch (key5) { case "position": case "spacing": { float num14 = 1f; PathConstraintPositionTimeline pathConstraintPositionTimeline; if (key5 == "spacing") { pathConstraintPositionTimeline = new PathConstraintSpacingTimeline(list5.Count); if (pathConstraintData.spacingMode == SpacingMode.Length || pathConstraintData.spacingMode == SpacingMode.Fixed) { num14 = scale; } } else { pathConstraintPositionTimeline = new PathConstraintPositionTimeline(list5.Count); if (pathConstraintData.positionMode == PositionMode.Fixed) { num14 = scale; } } pathConstraintPositionTimeline.pathConstraintIndex = num12; int num15 = 0; foreach (Dictionary <string, object> item18 in list5) { pathConstraintPositionTimeline.SetFrame(num15, (float)item18["time"], GetFloat(item18, key5, 0f) * num14); ReadCurve(item18, pathConstraintPositionTimeline, num15); num15++; } exposedList.Add(pathConstraintPositionTimeline); num = Math.Max(num, pathConstraintPositionTimeline.frames[(pathConstraintPositionTimeline.FrameCount - 1) * 2]); break; } case "mix": { PathConstraintMixTimeline pathConstraintMixTimeline = new PathConstraintMixTimeline(list5.Count); pathConstraintMixTimeline.pathConstraintIndex = num12; int num13 = 0; foreach (Dictionary <string, object> item19 in list5) { pathConstraintMixTimeline.SetFrame(num13, (float)item19["time"], GetFloat(item19, "rotateMix", 1f), GetFloat(item19, "translateMix", 1f)); ReadCurve(item19, pathConstraintMixTimeline, num13); num13++; } exposedList.Add(pathConstraintMixTimeline); num = Math.Max(num, pathConstraintMixTimeline.frames[(pathConstraintMixTimeline.FrameCount - 1) * 3]); break; } } } } } if (map.ContainsKey("deform")) { foreach (KeyValuePair <string, object> item20 in (Dictionary <string, object>)map["deform"]) { Skin skin = skeletonData.FindSkin(item20.Key); foreach (KeyValuePair <string, object> item21 in (Dictionary <string, object>)item20.Value) { int num16 = skeletonData.FindSlotIndex(item21.Key); if (num16 == -1) { throw new Exception("Slot not found: " + item21.Key); } foreach (KeyValuePair <string, object> item22 in (Dictionary <string, object>)item21.Value) { List <object> list6 = (List <object>)item22.Value; VertexAttachment vertexAttachment = (VertexAttachment)skin.GetAttachment(num16, item22.Key); if (vertexAttachment == null) { throw new Exception("Deform attachment not found: " + item22.Key); } bool flag = vertexAttachment.bones != null; float[] vertices = vertexAttachment.vertices; int num17 = (!flag) ? vertices.Length : (vertices.Length / 3 * 2); DeformTimeline deformTimeline = new DeformTimeline(list6.Count); deformTimeline.slotIndex = num16; deformTimeline.attachment = vertexAttachment; int num18 = 0; foreach (Dictionary <string, object> item23 in list6) { float[] array; if (!item23.ContainsKey("vertices")) { array = ((!flag) ? vertices : new float[num17]); } else { array = new float[num17]; int @int = GetInt(item23, "offset", 0); float[] floatArray = GetFloatArray(item23, "vertices", 1f); Array.Copy(floatArray, 0, array, @int, floatArray.Length); if (scale != 1f) { int i = @int; for (int num19 = i + floatArray.Length; i < num19; i++) { array[i] *= scale; } } if (!flag) { for (int j = 0; j < num17; j++) { array[j] += vertices[j]; } } } deformTimeline.SetFrame(num18, (float)item23["time"], array); ReadCurve(item23, deformTimeline, num18); num18++; } exposedList.Add(deformTimeline); num = Math.Max(num, deformTimeline.frames[deformTimeline.FrameCount - 1]); } } } } if (map.ContainsKey("drawOrder") || map.ContainsKey("draworder")) { List <object> list7 = (List <object>)map[(!map.ContainsKey("drawOrder")) ? "draworder" : "drawOrder"]; DrawOrderTimeline drawOrderTimeline = new DrawOrderTimeline(list7.Count); int count = skeletonData.slots.Count; int num20 = 0; foreach (Dictionary <string, object> item24 in list7) { int[] array2 = null; if (item24.ContainsKey("offsets")) { array2 = new int[count]; for (int num21 = count - 1; num21 >= 0; num21--) { array2[num21] = -1; } List <object> list8 = (List <object>)item24["offsets"]; int[] array3 = new int[count - list8.Count]; int num22 = 0; int num23 = 0; foreach (Dictionary <string, object> item25 in list8) { int num24 = skeletonData.FindSlotIndex((string)item25["slot"]); if (num24 == -1) { throw new Exception("Slot not found: " + item25["slot"]); } while (num22 != num24) { array3[num23++] = num22++; } int num27 = num22 + (int)(float)item25["offset"]; array2[num27] = num22++; } while (num22 < count) { array3[num23++] = num22++; } for (int num31 = count - 1; num31 >= 0; num31--) { if (array2[num31] == -1) { array2[num31] = array3[--num23]; } } } drawOrderTimeline.SetFrame(num20++, (float)item24["time"], array2); } exposedList.Add(drawOrderTimeline); num = Math.Max(num, drawOrderTimeline.frames[drawOrderTimeline.FrameCount - 1]); } if (map.ContainsKey("events")) { List <object> list9 = (List <object>)map["events"]; EventTimeline eventTimeline = new EventTimeline(list9.Count); int num33 = 0; foreach (Dictionary <string, object> item26 in list9) { EventData eventData = skeletonData.FindEvent((string)item26["name"]); if (eventData == null) { throw new Exception("Event not found: " + item26["name"]); } Event @event = new Event((float)item26["time"], eventData); @event.Int = GetInt(item26, "int", eventData.Int); @event.Float = GetFloat(item26, "float", eventData.Float); @event.String = GetString(item26, "string", eventData.String); eventTimeline.SetFrame(num33++, @event); } exposedList.Add(eventTimeline); num = Math.Max(num, eventTimeline.frames[eventTimeline.FrameCount - 1]); } exposedList.TrimExcess(); skeletonData.animations.Add(new Animation(name, exposedList, num)); }