AttachmentTimeline.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Spine
  4. {
  5. public class AttachmentTimeline : Timeline
  6. {
  7. public AttachmentTimeline(int frameCount)
  8. {
  9. this.frames = new float[frameCount];
  10. this.attachmentNames = new string[frameCount];
  11. }
  12. public int SlotIndex
  13. {
  14. get
  15. {
  16. return this.slotIndex;
  17. }
  18. set
  19. {
  20. this.slotIndex = value;
  21. }
  22. }
  23. public float[] Frames
  24. {
  25. get
  26. {
  27. return this.frames;
  28. }
  29. set
  30. {
  31. this.frames = value;
  32. }
  33. }
  34. public string[] AttachmentNames
  35. {
  36. get
  37. {
  38. return this.attachmentNames;
  39. }
  40. set
  41. {
  42. this.attachmentNames = value;
  43. }
  44. }
  45. public int FrameCount
  46. {
  47. get
  48. {
  49. return this.frames.Length;
  50. }
  51. }
  52. public void SetFrame(int frameIndex, float time, string attachmentName)
  53. {
  54. this.frames[frameIndex] = time;
  55. this.attachmentNames[frameIndex] = attachmentName;
  56. }
  57. public void Apply(Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha)
  58. {
  59. float[] array = this.frames;
  60. if (time < array[0])
  61. {
  62. if (lastTime > time)
  63. {
  64. this.Apply(skeleton, lastTime, 2.14748365E+09f, null, 0f);
  65. }
  66. return;
  67. }
  68. if (lastTime > time)
  69. {
  70. lastTime = -1f;
  71. }
  72. int num = ((time < array[array.Length - 1]) ? Animation.binarySearch(array, time) : array.Length) - 1;
  73. if (array[num] < lastTime)
  74. {
  75. return;
  76. }
  77. string text = this.attachmentNames[num];
  78. skeleton.slots[this.slotIndex].Attachment = ((text != null) ? skeleton.GetAttachment(this.slotIndex, text) : null);
  79. }
  80. internal int slotIndex;
  81. internal float[] frames;
  82. private string[] attachmentNames;
  83. }
  84. }