Slot.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using System;
  2. namespace Spine
  3. {
  4. public class Slot
  5. {
  6. public Slot(SlotData data, Bone bone)
  7. {
  8. if (data == null)
  9. {
  10. throw new ArgumentNullException("data cannot be null.");
  11. }
  12. if (bone == null)
  13. {
  14. throw new ArgumentNullException("bone cannot be null.");
  15. }
  16. this.data = data;
  17. this.bone = bone;
  18. this.SetToSetupPose();
  19. }
  20. public SlotData Data
  21. {
  22. get
  23. {
  24. return this.data;
  25. }
  26. }
  27. public Bone Bone
  28. {
  29. get
  30. {
  31. return this.bone;
  32. }
  33. }
  34. public Skeleton Skeleton
  35. {
  36. get
  37. {
  38. return this.bone.skeleton;
  39. }
  40. }
  41. public float R
  42. {
  43. get
  44. {
  45. return this.r;
  46. }
  47. set
  48. {
  49. this.r = value;
  50. }
  51. }
  52. public float G
  53. {
  54. get
  55. {
  56. return this.g;
  57. }
  58. set
  59. {
  60. this.g = value;
  61. }
  62. }
  63. public float B
  64. {
  65. get
  66. {
  67. return this.b;
  68. }
  69. set
  70. {
  71. this.b = value;
  72. }
  73. }
  74. public float A
  75. {
  76. get
  77. {
  78. return this.a;
  79. }
  80. set
  81. {
  82. this.a = value;
  83. }
  84. }
  85. public Attachment Attachment
  86. {
  87. get
  88. {
  89. return this.attachment;
  90. }
  91. set
  92. {
  93. this.attachment = value;
  94. this.attachmentTime = this.bone.skeleton.time;
  95. this.attachmentVerticesCount = 0;
  96. }
  97. }
  98. public float AttachmentTime
  99. {
  100. get
  101. {
  102. return this.bone.skeleton.time - this.attachmentTime;
  103. }
  104. set
  105. {
  106. this.attachmentTime = this.bone.skeleton.time - value;
  107. }
  108. }
  109. public float[] AttachmentVertices
  110. {
  111. get
  112. {
  113. return this.attachmentVertices;
  114. }
  115. set
  116. {
  117. this.attachmentVertices = value;
  118. }
  119. }
  120. public int AttachmentVerticesCount
  121. {
  122. get
  123. {
  124. return this.attachmentVerticesCount;
  125. }
  126. set
  127. {
  128. this.attachmentVerticesCount = value;
  129. }
  130. }
  131. internal void SetToSetupPose(int slotIndex)
  132. {
  133. this.r = this.data.r;
  134. this.g = this.data.g;
  135. this.b = this.data.b;
  136. this.a = this.data.a;
  137. this.Attachment = ((this.data.attachmentName != null) ? this.bone.skeleton.GetAttachment(slotIndex, this.data.attachmentName) : null);
  138. }
  139. public void SetToSetupPose()
  140. {
  141. this.SetToSetupPose(this.bone.skeleton.data.slots.IndexOf(this.data));
  142. }
  143. public override string ToString()
  144. {
  145. return this.data.name;
  146. }
  147. internal SlotData data;
  148. internal Bone bone;
  149. internal float r;
  150. internal float g;
  151. internal float b;
  152. internal float a;
  153. internal Attachment attachment;
  154. internal float attachmentTime;
  155. internal float[] attachmentVertices = new float[0];
  156. internal int attachmentVerticesCount;
  157. }
  158. }