TimelineData.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using System.Collections.Generic;
  2. namespace DragonBones
  3. {
  4. /**
  5. * @private
  6. */
  7. public abstract class TimelineData<T> : BaseObject where T : FrameData<T>
  8. {
  9. public float scale;
  10. /**
  11. * @private
  12. */
  13. public float offset;
  14. /**
  15. * @private
  16. */
  17. public readonly List<T> frames = new List<T>();
  18. /**
  19. * @private
  20. */
  21. public TimelineData()
  22. {
  23. }
  24. /**
  25. * @private
  26. */
  27. protected override void _onClear()
  28. {
  29. T prevFrame = null;
  30. foreach (var frame in frames)
  31. {
  32. if (prevFrame != null && frame != prevFrame) // Find key frame data.
  33. {
  34. prevFrame.ReturnToPool();
  35. }
  36. prevFrame = frame;
  37. }
  38. scale = 1.0f;
  39. offset = 0.0f;
  40. frames.Clear();
  41. }
  42. }
  43. /**
  44. * @private
  45. */
  46. public class ZOrderTimelineData : TimelineData<ZOrderFrameData>
  47. {
  48. }
  49. /**
  50. * @private
  51. */
  52. public class BoneTimelineData : TimelineData<BoneFrameData>
  53. {
  54. public BoneData bone;
  55. public readonly Transform originTransform = new Transform();
  56. public BoneTimelineData()
  57. {
  58. }
  59. protected override void _onClear()
  60. {
  61. base._onClear();
  62. bone = null;
  63. originTransform.Identity();
  64. }
  65. }
  66. /**
  67. * @private
  68. */
  69. public class SlotTimelineData : TimelineData<SlotFrameData>
  70. {
  71. public SlotData slot;
  72. public SlotTimelineData()
  73. {
  74. }
  75. protected override void _onClear()
  76. {
  77. base._onClear();
  78. slot = null;
  79. }
  80. }
  81. /**
  82. * @private
  83. */
  84. public class FFDTimelineData : TimelineData<ExtensionFrameData>
  85. {
  86. public SkinData skin;
  87. public SkinSlotData slot;
  88. public DisplayData display;
  89. public FFDTimelineData()
  90. {
  91. }
  92. protected override void _onClear()
  93. {
  94. base._onClear();
  95. skin = null;
  96. slot = null;
  97. display = null;
  98. }
  99. }
  100. }