SkeletonData.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Spine
  4. {
  5. public class SkeletonData
  6. {
  7. public string Name
  8. {
  9. get
  10. {
  11. return this.name;
  12. }
  13. set
  14. {
  15. this.name = value;
  16. }
  17. }
  18. public List<BoneData> Bones
  19. {
  20. get
  21. {
  22. return this.bones;
  23. }
  24. }
  25. public List<SlotData> Slots
  26. {
  27. get
  28. {
  29. return this.slots;
  30. }
  31. }
  32. public List<Skin> Skins
  33. {
  34. get
  35. {
  36. return this.skins;
  37. }
  38. set
  39. {
  40. this.skins = value;
  41. }
  42. }
  43. public Skin DefaultSkin
  44. {
  45. get
  46. {
  47. return this.defaultSkin;
  48. }
  49. set
  50. {
  51. this.defaultSkin = value;
  52. }
  53. }
  54. public List<EventData> Events
  55. {
  56. get
  57. {
  58. return this.events;
  59. }
  60. set
  61. {
  62. this.events = value;
  63. }
  64. }
  65. public List<Animation> Animations
  66. {
  67. get
  68. {
  69. return this.animations;
  70. }
  71. set
  72. {
  73. this.animations = value;
  74. }
  75. }
  76. public List<IkConstraintData> IkConstraints
  77. {
  78. get
  79. {
  80. return this.ikConstraints;
  81. }
  82. set
  83. {
  84. this.ikConstraints = value;
  85. }
  86. }
  87. public float Width
  88. {
  89. get
  90. {
  91. return this.width;
  92. }
  93. set
  94. {
  95. this.width = value;
  96. }
  97. }
  98. public float Height
  99. {
  100. get
  101. {
  102. return this.height;
  103. }
  104. set
  105. {
  106. this.height = value;
  107. }
  108. }
  109. public string Version
  110. {
  111. get
  112. {
  113. return this.version;
  114. }
  115. set
  116. {
  117. this.version = value;
  118. }
  119. }
  120. public string Hash
  121. {
  122. get
  123. {
  124. return this.hash;
  125. }
  126. set
  127. {
  128. this.hash = value;
  129. }
  130. }
  131. public BoneData FindBone(string boneName)
  132. {
  133. if (boneName == null)
  134. {
  135. throw new ArgumentNullException("boneName cannot be null.");
  136. }
  137. List<BoneData> list = this.bones;
  138. int i = 0;
  139. int count = list.Count;
  140. while (i < count)
  141. {
  142. BoneData boneData = list[i];
  143. if (boneData.name == boneName)
  144. {
  145. return boneData;
  146. }
  147. i++;
  148. }
  149. return null;
  150. }
  151. public int FindBoneIndex(string boneName)
  152. {
  153. if (boneName == null)
  154. {
  155. throw new ArgumentNullException("boneName cannot be null.");
  156. }
  157. List<BoneData> list = this.bones;
  158. int i = 0;
  159. int count = list.Count;
  160. while (i < count)
  161. {
  162. if (list[i].name == boneName)
  163. {
  164. return i;
  165. }
  166. i++;
  167. }
  168. return -1;
  169. }
  170. public SlotData FindSlot(string slotName)
  171. {
  172. if (slotName == null)
  173. {
  174. throw new ArgumentNullException("slotName cannot be null.");
  175. }
  176. List<SlotData> list = this.slots;
  177. int i = 0;
  178. int count = list.Count;
  179. while (i < count)
  180. {
  181. SlotData slotData = list[i];
  182. if (slotData.name == slotName)
  183. {
  184. return slotData;
  185. }
  186. i++;
  187. }
  188. return null;
  189. }
  190. public int FindSlotIndex(string slotName)
  191. {
  192. if (slotName == null)
  193. {
  194. throw new ArgumentNullException("slotName cannot be null.");
  195. }
  196. List<SlotData> list = this.slots;
  197. int i = 0;
  198. int count = list.Count;
  199. while (i < count)
  200. {
  201. if (list[i].name == slotName)
  202. {
  203. return i;
  204. }
  205. i++;
  206. }
  207. return -1;
  208. }
  209. public Skin FindSkin(string skinName)
  210. {
  211. if (skinName == null)
  212. {
  213. throw new ArgumentNullException("skinName cannot be null.");
  214. }
  215. foreach (Skin skin in this.skins)
  216. {
  217. if (skin.name == skinName)
  218. {
  219. return skin;
  220. }
  221. }
  222. return null;
  223. }
  224. public EventData FindEvent(string eventDataName)
  225. {
  226. if (eventDataName == null)
  227. {
  228. throw new ArgumentNullException("eventDataName cannot be null.");
  229. }
  230. foreach (EventData eventData in this.events)
  231. {
  232. if (eventData.name == eventDataName)
  233. {
  234. return eventData;
  235. }
  236. }
  237. return null;
  238. }
  239. public Animation FindAnimation(string animationName)
  240. {
  241. if (animationName == null)
  242. {
  243. throw new ArgumentNullException("animationName cannot be null.");
  244. }
  245. List<Animation> list = this.animations;
  246. int i = 0;
  247. int count = list.Count;
  248. while (i < count)
  249. {
  250. Animation animation = list[i];
  251. if (animation.name == animationName)
  252. {
  253. return animation;
  254. }
  255. i++;
  256. }
  257. return null;
  258. }
  259. public IkConstraintData FindIkConstraint(string ikConstraintName)
  260. {
  261. if (ikConstraintName == null)
  262. {
  263. throw new ArgumentNullException("ikConstraintName cannot be null.");
  264. }
  265. List<IkConstraintData> list = this.ikConstraints;
  266. int i = 0;
  267. int count = list.Count;
  268. while (i < count)
  269. {
  270. IkConstraintData ikConstraintData = list[i];
  271. if (ikConstraintData.name == ikConstraintName)
  272. {
  273. return ikConstraintData;
  274. }
  275. i++;
  276. }
  277. return null;
  278. }
  279. public override string ToString()
  280. {
  281. return this.name ?? base.ToString();
  282. }
  283. internal string name;
  284. internal List<BoneData> bones = new List<BoneData>();
  285. internal List<SlotData> slots = new List<SlotData>();
  286. internal List<Skin> skins = new List<Skin>();
  287. internal Skin defaultSkin;
  288. internal List<EventData> events = new List<EventData>();
  289. internal List<Animation> animations = new List<Animation>();
  290. internal List<IkConstraintData> ikConstraints = new List<IkConstraintData>();
  291. internal float width;
  292. internal float height;
  293. internal string version;
  294. internal string hash;
  295. internal string imagesPath;
  296. }
  297. }