AMTake.cs 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. using UnityEngine;
  6. [Serializable]
  7. public class AMTake : ScriptableObject
  8. {
  9. public AMTake(string name)
  10. {
  11. this.name = name;
  12. }
  13. public void selectTrack(int index, bool isShiftDown, bool isControlDown)
  14. {
  15. bool flag = false;
  16. if (this.contextSelectionTracks != null)
  17. {
  18. flag = this.contextSelectionTracks.Contains(index);
  19. if (!isShiftDown && !isControlDown)
  20. {
  21. if (this.selectedTrack != index)
  22. {
  23. this.selectedTrack = index;
  24. if (!flag)
  25. {
  26. this.contextSelection = new List<int>();
  27. this.contextSelectionTracks = new List<int>();
  28. }
  29. }
  30. if (index > -1)
  31. {
  32. this.selectGroup(this.getTrackGroup(index), false, false, true);
  33. }
  34. }
  35. }
  36. else
  37. {
  38. this.contextSelectionTracks = new List<int>();
  39. }
  40. if (!flag)
  41. {
  42. this.contextSelectionTracks.Add(index);
  43. }
  44. else if (isControlDown && this.selectedTrack != index && !isShiftDown)
  45. {
  46. this.contextSelectionTracks.Remove(index);
  47. }
  48. if ((this.selectedTrack != -1 || this.selectedGroup != 0) && isShiftDown)
  49. {
  50. List<int> trackIDsForRange = this.getTrackIDsForRange((this.selectedTrack == -1) ? this.selectedGroup : this.selectedTrack, index);
  51. foreach (int item in trackIDsForRange)
  52. {
  53. if (!this.contextSelectionTracks.Contains(item))
  54. {
  55. this.contextSelectionTracks.Add(item);
  56. }
  57. }
  58. }
  59. }
  60. public AMTrack getSelectedTrack()
  61. {
  62. return this.getTrack(this.selectedTrack);
  63. }
  64. public void addTranslationTrack(GameObject obj)
  65. {
  66. AMTranslationTrack amtranslationTrack = ScriptableObject.CreateInstance<AMTranslationTrack>();
  67. amtranslationTrack.setName(this.getTrackCount());
  68. amtranslationTrack.id = this.getUniqueTrackID();
  69. if (obj)
  70. {
  71. amtranslationTrack.obj = obj.transform;
  72. }
  73. this.addTrack(amtranslationTrack);
  74. }
  75. public void addRotationTrack(GameObject obj)
  76. {
  77. AMRotationTrack amrotationTrack = ScriptableObject.CreateInstance<AMRotationTrack>();
  78. amrotationTrack.setName(this.getTrackCount());
  79. amrotationTrack.id = this.getUniqueTrackID();
  80. if (obj)
  81. {
  82. amrotationTrack.obj = obj.transform;
  83. }
  84. this.addTrack(amrotationTrack);
  85. }
  86. public void addOrientationTrack(GameObject obj)
  87. {
  88. AMOrientationTrack amorientationTrack = ScriptableObject.CreateInstance<AMOrientationTrack>();
  89. amorientationTrack.setName(this.getTrackCount());
  90. amorientationTrack.id = this.getUniqueTrackID();
  91. if (obj)
  92. {
  93. amorientationTrack.obj = obj.transform;
  94. }
  95. this.addTrack(amorientationTrack);
  96. }
  97. public void addAnimationTrack(GameObject obj)
  98. {
  99. AMAnimationTrack amanimationTrack = ScriptableObject.CreateInstance<AMAnimationTrack>();
  100. amanimationTrack.setName(this.getTrackCount());
  101. amanimationTrack.id = this.getUniqueTrackID();
  102. if (obj && obj.GetComponent(typeof(Animation)))
  103. {
  104. amanimationTrack.obj = obj;
  105. }
  106. this.addTrack(amanimationTrack);
  107. }
  108. public void addAudioTrack(GameObject obj)
  109. {
  110. AMAudioTrack amaudioTrack = ScriptableObject.CreateInstance<AMAudioTrack>();
  111. amaudioTrack.setName(this.getTrackCount());
  112. amaudioTrack.id = this.getUniqueTrackID();
  113. if (obj && obj.GetComponent(typeof(AudioSource)))
  114. {
  115. amaudioTrack.audioSource = (AudioSource)obj.GetComponent(typeof(AudioSource));
  116. }
  117. this.addTrack(amaudioTrack);
  118. }
  119. public void addPropertyTrack(GameObject obj)
  120. {
  121. AMPropertyTrack ampropertyTrack = ScriptableObject.CreateInstance<AMPropertyTrack>();
  122. ampropertyTrack.setName(this.getTrackCount());
  123. ampropertyTrack.id = this.getUniqueTrackID();
  124. if (obj)
  125. {
  126. ampropertyTrack.obj = obj;
  127. }
  128. this.addTrack(ampropertyTrack);
  129. }
  130. public void addEventTrack(GameObject obj)
  131. {
  132. AMEventTrack ameventTrack = ScriptableObject.CreateInstance<AMEventTrack>();
  133. ameventTrack.setName(this.getTrackCount());
  134. ameventTrack.id = this.getUniqueTrackID();
  135. if (obj)
  136. {
  137. ameventTrack.obj = obj;
  138. }
  139. this.addTrack(ameventTrack);
  140. }
  141. public void addCameraSwitcherTrack(GameObject obj)
  142. {
  143. if (this.cameraSwitcher)
  144. {
  145. Camera camera = obj.AddComponent<Camera>();
  146. if (camera)
  147. {
  148. this.cameraSwitcher.addKey(this.selectedFrame, camera, null);
  149. }
  150. return;
  151. }
  152. AMCameraSwitcherTrack amcameraSwitcherTrack = ScriptableObject.CreateInstance<AMCameraSwitcherTrack>();
  153. amcameraSwitcherTrack.setName(this.getTrackCount());
  154. amcameraSwitcherTrack.id = this.getUniqueTrackID();
  155. if (obj && obj.GetComponent(typeof(Camera)))
  156. {
  157. amcameraSwitcherTrack.addKey(1, (Camera)obj.GetComponent(typeof(Camera)), null);
  158. }
  159. this.addTrack(amcameraSwitcherTrack);
  160. this.cameraSwitcher = amcameraSwitcherTrack;
  161. }
  162. public void deleteTrack(int id, bool deleteFromGroup = true)
  163. {
  164. int trackIndex = this.getTrackIndex(id);
  165. if (trackIndex < 0 || trackIndex >= this.trackKeys.Count || trackIndex >= this.trackValues.Count)
  166. {
  167. Debug.LogError("Animator: Track id " + id + " not found");
  168. return;
  169. }
  170. if (this.cameraSwitcher == this.trackValues[trackIndex])
  171. {
  172. this.cameraSwitcher = null;
  173. }
  174. this.trackKeys.RemoveAt(trackIndex);
  175. this.trackValues.RemoveAt(trackIndex);
  176. if (deleteFromGroup)
  177. {
  178. this.deleteTrackFromGroups(id);
  179. }
  180. }
  181. public List<int> getTrackIDsForRange(int start_id, int end_id)
  182. {
  183. if (start_id == end_id)
  184. {
  185. return new List<int>();
  186. }
  187. int elementLocationIndex = this.getElementLocationIndex(start_id);
  188. if (elementLocationIndex == 0)
  189. {
  190. return new List<int>();
  191. }
  192. int elementLocationIndex2 = this.getElementLocationIndex(end_id);
  193. if (elementLocationIndex2 == 0)
  194. {
  195. return new List<int>();
  196. }
  197. if (elementLocationIndex > elementLocationIndex2)
  198. {
  199. int num = start_id;
  200. start_id = end_id;
  201. end_id = num;
  202. }
  203. List<int> list = new List<int>();
  204. bool flag = false;
  205. bool flag2 = false;
  206. return this.getTrackIDsForGroup(0, start_id, end_id, ref flag, ref flag2);
  207. }
  208. private List<int> getTrackIDsForGroup(int group_id, int start_id, int end_id, ref bool foundStartID, ref bool foundEndID)
  209. {
  210. List<int> list = new List<int>();
  211. AMGroup group = this.getGroup(group_id);
  212. int i = 0;
  213. while (i < group.elements.Count)
  214. {
  215. if (group.elements[i] == start_id)
  216. {
  217. foundStartID = true;
  218. if (group.elements[i] <= 0)
  219. {
  220. goto IL_5D;
  221. }
  222. }
  223. else
  224. {
  225. if (group.elements[i] == end_id)
  226. {
  227. foundEndID = true;
  228. goto IL_5D;
  229. }
  230. goto IL_5D;
  231. }
  232. IL_C1:
  233. i++;
  234. continue;
  235. IL_5D:
  236. if (!foundEndID)
  237. {
  238. if (group.elements[i] > 0)
  239. {
  240. if (foundStartID)
  241. {
  242. list.Add(group.elements[i]);
  243. }
  244. }
  245. else
  246. {
  247. list.AddRange(this.getTrackIDsForGroup(group.elements[i], start_id, end_id, ref foundStartID, ref foundEndID));
  248. }
  249. }
  250. if (foundEndID)
  251. {
  252. break;
  253. }
  254. goto IL_C1;
  255. }
  256. return list;
  257. }
  258. public int getElementLocationIndex(int element_id)
  259. {
  260. int result = 0;
  261. bool flag = false;
  262. this.getElementLocationIndexForGroup(0, element_id, ref result, ref flag);
  263. return result;
  264. }
  265. private void getElementLocationIndexForGroup(int group_id, int element_id, ref int count, ref bool found)
  266. {
  267. AMGroup group = this.getGroup(group_id);
  268. foreach (int num in group.elements)
  269. {
  270. count++;
  271. if (num == element_id)
  272. {
  273. found = true;
  274. break;
  275. }
  276. if (num <= 0)
  277. {
  278. this.getElementLocationIndexForGroup(num, element_id, ref count, ref found);
  279. if (found)
  280. {
  281. break;
  282. }
  283. }
  284. }
  285. }
  286. public void selectGroup(int group_id, bool isShiftDown, bool isControlDown, bool softSelect = false)
  287. {
  288. if (isShiftDown || isControlDown)
  289. {
  290. this.contextSelectGroup(group_id, isControlDown);
  291. if ((this.selectedTrack != -1 || this.selectedGroup != 0) && isShiftDown)
  292. {
  293. List<int> trackIDsForRange = this.getTrackIDsForRange((this.selectedTrack == -1) ? this.selectedGroup : this.selectedTrack, group_id);
  294. foreach (int item in trackIDsForRange)
  295. {
  296. if (!this.contextSelectionTracks.Contains(item))
  297. {
  298. this.contextSelectionTracks.Add(item);
  299. }
  300. }
  301. }
  302. }
  303. else if (!softSelect && this.contextSelectionTracks.Count == 1)
  304. {
  305. this.contextSelectionTracks = new List<int>();
  306. }
  307. this.selectedGroup = group_id;
  308. }
  309. public void contextSelectGroup(int group_id, bool isControlDown)
  310. {
  311. AMGroup group = this.getGroup(group_id);
  312. int num = 0;
  313. bool flag = isControlDown && this.isGroupSelected(group_id, ref num);
  314. for (int i = 0; i < group.elements.Count; i++)
  315. {
  316. if (group.elements[i] > 0)
  317. {
  318. bool flag2 = this.contextSelectionTracks.Contains(group.elements[i]);
  319. if (flag)
  320. {
  321. if (flag2)
  322. {
  323. this.contextSelectionTracks.Remove(group.elements[i]);
  324. }
  325. }
  326. else if (!flag2)
  327. {
  328. this.contextSelectionTracks.Add(group.elements[i]);
  329. }
  330. }
  331. else
  332. {
  333. this.contextSelectGroup(group.elements[i], flag);
  334. }
  335. }
  336. }
  337. public bool isGroupSelected(int group_id, ref int numTracks)
  338. {
  339. AMGroup group = this.getGroup(group_id);
  340. for (int i = 0; i < group.elements.Count; i++)
  341. {
  342. if (group.elements[i] > 0)
  343. {
  344. if (!this.contextSelectionTracks.Contains(group.elements[i]))
  345. {
  346. return false;
  347. }
  348. numTracks++;
  349. }
  350. else if (!this.isGroupSelected(group.elements[i], ref numTracks))
  351. {
  352. return false;
  353. }
  354. }
  355. return true;
  356. }
  357. public void deleteGroup(int group_id, bool deleteContents)
  358. {
  359. if (group_id >= 0)
  360. {
  361. return;
  362. }
  363. AMGroup group = this.getGroup(group_id);
  364. if (deleteContents)
  365. {
  366. for (int i = 0; i < group.elements.Count; i++)
  367. {
  368. if (group.elements[i] > 0)
  369. {
  370. this.deleteTrack(group.elements[i], false);
  371. }
  372. else if (group.elements[i] < 0)
  373. {
  374. this.deleteGroup(group.elements[i], deleteContents);
  375. }
  376. }
  377. }
  378. else
  379. {
  380. AMGroup group2 = this.getGroup(this.getElementGroup(group_id));
  381. for (int j = 0; j < group2.elements.Count; j++)
  382. {
  383. if (group2.elements[j] == group_id)
  384. {
  385. group2.elements.InsertRange(j, group.elements);
  386. break;
  387. }
  388. }
  389. }
  390. this.removeFromGroup(group.group_id);
  391. bool flag = false;
  392. int k;
  393. for (k = 0; k < this.groupValues.Count; k++)
  394. {
  395. if (this.groupValues[k] == group)
  396. {
  397. flag = true;
  398. this.groupValues.Remove(group);
  399. break;
  400. }
  401. }
  402. if (flag)
  403. {
  404. this.groupKeys.RemoveAt(k);
  405. }
  406. group.destroy();
  407. }
  408. public void deleteSelectedGroup(bool deleteContents)
  409. {
  410. this.deleteGroup(this.selectedGroup, deleteContents);
  411. this.selectedGroup = 0;
  412. }
  413. public int getUniqueTrackID()
  414. {
  415. this.track_count++;
  416. foreach (int num in this.trackKeys)
  417. {
  418. if (num >= this.track_count)
  419. {
  420. this.track_count = num + 1;
  421. }
  422. }
  423. return this.track_count;
  424. }
  425. public int getUniqueGroupID()
  426. {
  427. this.group_count--;
  428. foreach (int num in this.groupKeys)
  429. {
  430. if (num <= this.group_count)
  431. {
  432. this.group_count = num - 1;
  433. }
  434. }
  435. return this.group_count;
  436. }
  437. public int getTrackIndex(int id)
  438. {
  439. int result = -1;
  440. for (int i = 0; i < this.trackKeys.Count; i++)
  441. {
  442. if (this.trackKeys[i] == id)
  443. {
  444. result = i;
  445. break;
  446. }
  447. }
  448. return result;
  449. }
  450. public AMTrack getTrack(int id)
  451. {
  452. int trackIndex = this.getTrackIndex(id);
  453. if (trackIndex == -1 || trackIndex >= this.trackValues.Count)
  454. {
  455. Debug.LogError("Animator: Track id " + id + " not found.");
  456. return new AMTrack();
  457. }
  458. return this.trackValues[trackIndex];
  459. }
  460. public AMAnimationTrack findAnimationTrack(GameObject go)
  461. {
  462. return this.trackValues.Find((AMTrack a) => a is AMAnimationTrack && (a as AMAnimationTrack).obj == go) as AMAnimationTrack;
  463. }
  464. public AMAnimationTrack findAnimationTrack(string name)
  465. {
  466. return this.trackValues.Find((AMTrack a) => a is AMAnimationTrack && (a as AMAnimationTrack).name == name) as AMAnimationTrack;
  467. }
  468. public AMTranslationTrack findTranslationTrack(Transform tr)
  469. {
  470. return this.trackValues.Find((AMTrack a) => a is AMTranslationTrack && (a as AMTranslationTrack).obj == tr) as AMTranslationTrack;
  471. }
  472. public AMTranslationTrack[] findTranslationTrack(string objName)
  473. {
  474. List<AMTrack> source = this.trackValues.FindAll((AMTrack a) => a is AMTranslationTrack && (a as AMTranslationTrack).objName == objName);
  475. return (from i in source
  476. select (AMTranslationTrack)i).ToArray<AMTranslationTrack>();
  477. }
  478. public AMRotationTrack findRotationTrack(Transform tr)
  479. {
  480. return this.trackValues.Find((AMTrack a) => a is AMRotationTrack && (a as AMRotationTrack).obj == tr) as AMRotationTrack;
  481. }
  482. public AMRotationTrack[] findRotationTrack(string objName)
  483. {
  484. List<AMTrack> source = this.trackValues.FindAll((AMTrack a) => a is AMRotationTrack && (a as AMRotationTrack).objName == objName);
  485. return (from i in source
  486. select (AMRotationTrack)i).ToArray<AMRotationTrack>();
  487. }
  488. public AMPropertyTrack findPropertyTrack(GameObject go)
  489. {
  490. return this.trackValues.Find((AMTrack a) => a is AMPropertyTrack && (a as AMPropertyTrack).obj == go) as AMPropertyTrack;
  491. }
  492. public AMPropertyTrack[] findPropertyTrack(string objName)
  493. {
  494. List<AMTrack> source = this.trackValues.FindAll((AMTrack a) => a is AMPropertyTrack && (a as AMPropertyTrack).objName == objName);
  495. return (from i in source
  496. select (AMPropertyTrack)i).ToArray<AMPropertyTrack>();
  497. }
  498. public AMAudioTrack[] findAudioTrack(string objName)
  499. {
  500. List<AMTrack> source = this.trackValues.FindAll((AMTrack a) => a is AMAudioTrack && (a as AMAudioTrack).asName == objName);
  501. return (from i in source
  502. select (AMAudioTrack)i).ToArray<AMAudioTrack>();
  503. }
  504. public int getElementGroup(int id)
  505. {
  506. foreach (int num in this.rootGroup.elements)
  507. {
  508. if (num == id)
  509. {
  510. return 0;
  511. }
  512. }
  513. foreach (AMGroup amgroup in this.groupValues)
  514. {
  515. foreach (int num2 in amgroup.elements)
  516. {
  517. if (num2 == id)
  518. {
  519. return amgroup.group_id;
  520. }
  521. }
  522. }
  523. Debug.LogError("Animator: Group not found for element " + id);
  524. return 0;
  525. }
  526. public bool replaceElement(int source_id, int new_id)
  527. {
  528. for (int i = 0; i < this.rootGroup.elements.Count; i++)
  529. {
  530. if (this.rootGroup.elements[i] == source_id)
  531. {
  532. this.rootGroup.elements[i] = new_id;
  533. return true;
  534. }
  535. }
  536. for (int j = 0; j < this.groupValues.Count; j++)
  537. {
  538. AMGroup amgroup = this.groupValues[j];
  539. for (int k = 0; k < amgroup.elements.Count; k++)
  540. {
  541. if (amgroup.elements[k] == source_id)
  542. {
  543. amgroup.elements[k] = new_id;
  544. return true;
  545. }
  546. }
  547. }
  548. return false;
  549. }
  550. public void addTrack(AMTrack track)
  551. {
  552. this.trackKeys.Add(track.id);
  553. this.trackValues.Add(track);
  554. this.addToGroup(track.id, this.selectedGroup, false, -1);
  555. track.parentTake = this;
  556. }
  557. public void moveToGroup(int source_id, int dest_group_id, bool first = false, int dest_track_id = -1)
  558. {
  559. this.initGroups();
  560. bool flag = true;
  561. if (source_id < 0)
  562. {
  563. int elementRootGroup = this.getElementRootGroup(dest_group_id, source_id);
  564. if (elementRootGroup < 1)
  565. {
  566. this.removeFromGroup(elementRootGroup);
  567. this.replaceElement(source_id, elementRootGroup);
  568. flag = false;
  569. }
  570. else if (elementRootGroup == 2)
  571. {
  572. this.removeFromGroup(dest_group_id);
  573. this.replaceElement(source_id, dest_group_id);
  574. flag = false;
  575. }
  576. }
  577. if (flag)
  578. {
  579. this.removeFromGroup(source_id);
  580. }
  581. this.addToGroup(source_id, dest_group_id, first, dest_track_id);
  582. }
  583. public bool isElementInGroup(int id, int group_id)
  584. {
  585. if (group_id > 0)
  586. {
  587. return false;
  588. }
  589. AMGroup group = this.getGroup(group_id);
  590. foreach (int num in group.elements)
  591. {
  592. if (num == id)
  593. {
  594. return true;
  595. }
  596. if (this.isElementInGroup(id, num))
  597. {
  598. return true;
  599. }
  600. }
  601. return false;
  602. }
  603. public int getElementRootGroup(int element_id, int group_id)
  604. {
  605. if (group_id > 0)
  606. {
  607. return 1;
  608. }
  609. AMGroup group = this.getGroup(group_id);
  610. foreach (int num in group.elements)
  611. {
  612. if (num == element_id)
  613. {
  614. return 2;
  615. }
  616. if (num <= 0 && this.isElementInGroup(element_id, num))
  617. {
  618. return num;
  619. }
  620. }
  621. return 1;
  622. }
  623. public void moveGroupElement(int source_id, int dest_id)
  624. {
  625. this.initGroups();
  626. this.removeFromGroup(source_id);
  627. bool flag = false;
  628. for (int i = 0; i < this.rootGroup.elements.Count; i++)
  629. {
  630. if (this.rootGroup.elements[i] == dest_id)
  631. {
  632. if (i < this.rootGroup.elements.Count)
  633. {
  634. this.rootGroup.elements.Insert(i + 1, source_id);
  635. }
  636. else
  637. {
  638. this.rootGroup.elements.Add(source_id);
  639. }
  640. flag = true;
  641. break;
  642. }
  643. }
  644. if (!flag)
  645. {
  646. foreach (AMGroup amgroup in this.groupValues)
  647. {
  648. for (int j = 0; j < amgroup.elements.Count; j++)
  649. {
  650. if (amgroup.elements[j] == dest_id)
  651. {
  652. if (j < amgroup.elements.Count - 1)
  653. {
  654. amgroup.elements.Insert(j + 1, source_id);
  655. }
  656. else
  657. {
  658. amgroup.elements.Add(source_id);
  659. }
  660. flag = true;
  661. break;
  662. }
  663. }
  664. if (flag)
  665. {
  666. break;
  667. }
  668. }
  669. }
  670. if (!flag)
  671. {
  672. Debug.LogWarning("Animator: No group found for element id " + dest_id);
  673. this.rootGroup.elements.Add(source_id);
  674. }
  675. }
  676. public void addGroup()
  677. {
  678. this.initGroups();
  679. AMGroup amgroup = ScriptableObject.CreateInstance<AMGroup>();
  680. amgroup.init(this.getUniqueGroupID(), null);
  681. this.groupKeys.Add(amgroup.group_id);
  682. this.groupValues.Add(amgroup);
  683. this.rootGroup.elements.Add(amgroup.group_id);
  684. this.selectedGroup = amgroup.group_id;
  685. }
  686. public int getTrackCount()
  687. {
  688. return this.trackKeys.Count;
  689. }
  690. public int getGroupIndex(int id)
  691. {
  692. int result = -1;
  693. for (int i = 0; i < this.groupKeys.Count; i++)
  694. {
  695. if (this.groupKeys[i] == id)
  696. {
  697. result = i;
  698. break;
  699. }
  700. }
  701. return result;
  702. }
  703. public AMGroup getGroup(int id)
  704. {
  705. this.initGroups();
  706. if (id == 0)
  707. {
  708. return this.rootGroup;
  709. }
  710. int groupIndex = this.getGroupIndex(id);
  711. if (groupIndex == -1 || groupIndex >= this.groupValues.Count)
  712. {
  713. Debug.LogError("Animator: Group id " + id + " not found.");
  714. return new AMGroup();
  715. }
  716. return this.groupValues[groupIndex];
  717. }
  718. public void initGroups()
  719. {
  720. if (this.rootGroup == null)
  721. {
  722. AMGroup amgroup = ScriptableObject.CreateInstance<AMGroup>();
  723. amgroup.init(0, null);
  724. this.rootGroup = amgroup;
  725. }
  726. }
  727. public int getTrackGroup(int track_id)
  728. {
  729. foreach (int num in this.rootGroup.elements)
  730. {
  731. if (num == track_id)
  732. {
  733. return 0;
  734. }
  735. }
  736. foreach (AMGroup amgroup in this.groupValues)
  737. {
  738. foreach (int num2 in amgroup.elements)
  739. {
  740. if (num2 == track_id)
  741. {
  742. return amgroup.group_id;
  743. }
  744. }
  745. }
  746. Debug.LogWarning("Animator: No group found for Track " + track_id);
  747. return 0;
  748. }
  749. public void removeFromGroup(int source_id)
  750. {
  751. foreach (int num in this.rootGroup.elements)
  752. {
  753. if (num == source_id)
  754. {
  755. this.rootGroup.elements.Remove(num);
  756. return;
  757. }
  758. }
  759. foreach (AMGroup amgroup in this.groupValues)
  760. {
  761. foreach (int num2 in amgroup.elements)
  762. {
  763. if (num2 == source_id)
  764. {
  765. amgroup.elements.Remove(num2);
  766. return;
  767. }
  768. }
  769. }
  770. }
  771. public void addToGroup(int source_id, int group_id, bool first = false, int dest_track_id = -1)
  772. {
  773. this.initGroups();
  774. bool flag = false;
  775. if (group_id == 0)
  776. {
  777. if (dest_track_id != -1)
  778. {
  779. for (int i = 0; i < this.rootGroup.elements.Count - 1; i++)
  780. {
  781. if (this.rootGroup.elements[i] == dest_track_id)
  782. {
  783. this.rootGroup.elements.Insert(i + 1, source_id);
  784. flag = true;
  785. break;
  786. }
  787. }
  788. }
  789. if (!flag)
  790. {
  791. if (first)
  792. {
  793. this.rootGroup.elements.Insert(0, source_id);
  794. }
  795. else
  796. {
  797. this.rootGroup.elements.Add(source_id);
  798. }
  799. }
  800. }
  801. else
  802. {
  803. int groupIndex = this.getGroupIndex(group_id);
  804. if (groupIndex == -1)
  805. {
  806. Debug.LogError("Animator: Group " + group_id + " not found.");
  807. return;
  808. }
  809. AMGroup group = this.getGroup(group_id);
  810. if (dest_track_id != -1)
  811. {
  812. for (int j = 0; j < group.elements.Count; j++)
  813. {
  814. if (group.elements[j] == dest_track_id)
  815. {
  816. if (j < group.elements.Count - 1)
  817. {
  818. group.elements.Insert(j + 1, source_id);
  819. }
  820. else
  821. {
  822. group.elements.Add(source_id);
  823. }
  824. flag = true;
  825. break;
  826. }
  827. }
  828. }
  829. if (!flag)
  830. {
  831. if (first)
  832. {
  833. group.elements.Insert(0, source_id);
  834. }
  835. else
  836. {
  837. group.elements.Add(source_id);
  838. }
  839. }
  840. if (!group.foldout)
  841. {
  842. group.foldout = true;
  843. }
  844. }
  845. }
  846. public void deleteTrackFromGroups(int _id)
  847. {
  848. bool flag = false;
  849. foreach (int num in this.rootGroup.elements)
  850. {
  851. if (num == _id)
  852. {
  853. this.rootGroup.elements.Remove(num);
  854. flag = true;
  855. break;
  856. }
  857. }
  858. if (!flag)
  859. {
  860. foreach (AMGroup amgroup in this.groupValues)
  861. {
  862. foreach (int num2 in amgroup.elements)
  863. {
  864. if (num2 == _id)
  865. {
  866. amgroup.elements.Remove(num2);
  867. flag = true;
  868. break;
  869. }
  870. }
  871. }
  872. }
  873. if (!flag)
  874. {
  875. Debug.LogWarning("Animator: Deleted track " + _id + " not found in groups.");
  876. }
  877. }
  878. public void selectFrame(int track, int num, float numFramesToRender, bool isShiftDown, bool isControlDown)
  879. {
  880. this.selectedFrame = num;
  881. this.selectTrack(track, isShiftDown, isControlDown);
  882. if ((float)this.selectedFrame < this.startFrame || (float)this.selectedFrame > this.endFrame)
  883. {
  884. this.startFrame = (float)this.selectedFrame;
  885. this.endFrame = this.startFrame + (float)((int)numFramesToRender) - 1f;
  886. }
  887. }
  888. public void addMorph(GameObject obj, MethodInfo methodInfo, Component component, List<float> morph)
  889. {
  890. foreach (AMTake.Morph morph2 in this.morphs)
  891. {
  892. if (morph2.obj == obj && morph2.component == component)
  893. {
  894. morph2.blendMorph(morph);
  895. return;
  896. }
  897. }
  898. AMTake.Morph item = new AMTake.Morph(obj, methodInfo, component, morph);
  899. this.morphs.Add(item);
  900. }
  901. public void previewFrame(float _frame, bool orientationOnly = false, bool renderStill = true, bool skipCameraSwitcher = false, bool quickPreview = false)
  902. {
  903. if (!skipCameraSwitcher && renderStill)
  904. {
  905. this.renderCameraSwitcherStill(_frame);
  906. }
  907. List<AMOrientationTrack> list = new List<AMOrientationTrack>();
  908. List<AMRotationTrack> list2 = new List<AMRotationTrack>();
  909. this.morphs = new List<AMTake.Morph>();
  910. foreach (AMTrack amtrack in this.trackValues)
  911. {
  912. if (!skipCameraSwitcher || !(amtrack is AMCameraSwitcherTrack))
  913. {
  914. if (!(amtrack is AMAudioTrack))
  915. {
  916. if (amtrack is AMOrientationTrack)
  917. {
  918. list.Add(amtrack as AMOrientationTrack);
  919. }
  920. else if (!orientationOnly)
  921. {
  922. if (amtrack is AMRotationTrack)
  923. {
  924. list2.Add(amtrack as AMRotationTrack);
  925. }
  926. if (amtrack is AMAnimationTrack)
  927. {
  928. (amtrack as AMAnimationTrack).previewFrame(_frame, (float)this.frameRate);
  929. }
  930. else if (amtrack is AMPropertyTrack)
  931. {
  932. (amtrack as AMPropertyTrack).previewFrame(_frame, quickPreview);
  933. }
  934. else
  935. {
  936. amtrack.previewFrame(_frame, null);
  937. }
  938. }
  939. }
  940. }
  941. }
  942. foreach (AMOrientationTrack amorientationTrack in list)
  943. {
  944. amorientationTrack.cachedTranslationTrackStartTarget = this.getTranslationTrackForTransform(amorientationTrack.getStartTargetForFrame(_frame));
  945. amorientationTrack.cachedTranslationTrackEndTarget = this.getTranslationTrackForTransform(amorientationTrack.getEndTargetForFrame(_frame));
  946. amorientationTrack.previewFrame(_frame, null);
  947. }
  948. if (list.Count > 0)
  949. {
  950. foreach (AMRotationTrack amrotationTrack in list2)
  951. {
  952. amrotationTrack.previewFrame(_frame, null);
  953. }
  954. }
  955. foreach (AMTake.Morph m in this.morphs)
  956. {
  957. this.previewMorph(m);
  958. }
  959. }
  960. public void previewMorph(AMTake.Morph m)
  961. {
  962. for (int i = 0; i < m.morph.Count; i++)
  963. {
  964. if (i >= m.morph.Count)
  965. {
  966. break;
  967. }
  968. m.methodInfo.Invoke(m.component, new object[]
  969. {
  970. i,
  971. m.morph[i]
  972. });
  973. }
  974. if (!Application.isPlaying)
  975. {
  976. m.obj.transform.position = new Vector3(m.obj.transform.position.x, m.obj.transform.position.y, m.obj.transform.position.z);
  977. }
  978. }
  979. private void renderCameraSwitcherStill(float _frame)
  980. {
  981. if (!this.cameraSwitcher)
  982. {
  983. return;
  984. }
  985. AMCameraSwitcherTrack.cfTuple cameraFadeTupleForFrame = this.cameraSwitcher.getCameraFadeTupleForFrame((int)_frame);
  986. if (cameraFadeTupleForFrame.frame != 0)
  987. {
  988. AMCameraFade cameraFade = AMCameraFade.getCameraFade(true);
  989. cameraFade.isReset = false;
  990. bool flag = AMTake.isProLicense;
  991. if (!cameraFade.tex2d || cameraFade.shouldUpdateStill || (flag && cameraFade.cachedStillFrame != cameraFadeTupleForFrame.frame))
  992. {
  993. if (flag)
  994. {
  995. int num = (!cameraFadeTupleForFrame.isReversed) ? cameraFadeTupleForFrame.type1 : cameraFadeTupleForFrame.type2;
  996. int num2 = (!cameraFadeTupleForFrame.isReversed) ? cameraFadeTupleForFrame.type2 : cameraFadeTupleForFrame.type1;
  997. if (num == 0)
  998. {
  999. if (cameraFade.tex2d)
  1000. {
  1001. UnityEngine.Object.DestroyImmediate(cameraFade.tex2d);
  1002. }
  1003. this.previewFrame((float)cameraFadeTupleForFrame.frame, false, false, false, false);
  1004. Camera camera = (!cameraFadeTupleForFrame.isReversed) ? cameraFadeTupleForFrame.camera1 : cameraFadeTupleForFrame.camera2;
  1005. AMTween.SetTopCamera(camera, this.cameraSwitcher.getAllCameras());
  1006. if (cameraFade.width <= 0 || cameraFade.height <= 0)
  1007. {
  1008. if (Application.isPlaying)
  1009. {
  1010. cameraFade.width = Screen.width;
  1011. cameraFade.height = Screen.height;
  1012. }
  1013. else
  1014. {
  1015. cameraFade.width = 200;
  1016. cameraFade.height = 100;
  1017. cameraFade.shouldUpdateStill = true;
  1018. }
  1019. }
  1020. else
  1021. {
  1022. cameraFade.shouldUpdateStill = false;
  1023. }
  1024. RenderTexture temporary = RenderTexture.GetTemporary(cameraFade.width, cameraFade.height, 24);
  1025. camera.targetTexture = temporary;
  1026. camera.Render();
  1027. Texture2D texture2D = new Texture2D(temporary.width, temporary.height, TextureFormat.RGB24, false);
  1028. RenderTexture.active = temporary;
  1029. texture2D.ReadPixels(new Rect(0f, 0f, (float)temporary.width, (float)temporary.height), 0, 0);
  1030. texture2D.Apply();
  1031. cameraFade.tex2d = texture2D;
  1032. cameraFade.cachedStillFrame = cameraFadeTupleForFrame.frame;
  1033. RenderTexture.active = null;
  1034. RenderTexture.ReleaseTemporary(temporary);
  1035. camera.targetTexture = null;
  1036. if (cameraFade.placeholder)
  1037. {
  1038. cameraFade.placeholder = false;
  1039. }
  1040. if (num2 == 0)
  1041. {
  1042. Camera top = (!cameraFadeTupleForFrame.isReversed) ? cameraFadeTupleForFrame.camera2 : cameraFadeTupleForFrame.camera1;
  1043. AMTween.SetTopCamera(top, this.cameraSwitcher.getAllCameras());
  1044. }
  1045. }
  1046. }
  1047. else
  1048. {
  1049. cameraFade.tex2d = (Texture2D)Resources.Load("am_indie_placeholder");
  1050. if (!cameraFade.placeholder)
  1051. {
  1052. cameraFade.placeholder = true;
  1053. }
  1054. }
  1055. }
  1056. cameraFade.useRenderTexture = false;
  1057. }
  1058. }
  1059. public void sampleAudioAtFrame(int frame, float speed)
  1060. {
  1061. foreach (AMTrack amtrack in this.trackValues)
  1062. {
  1063. if (amtrack is AMAudioTrack)
  1064. {
  1065. (amtrack as AMAudioTrack).sampleAudioAtFrame(frame, speed, this.frameRate);
  1066. }
  1067. }
  1068. }
  1069. public AMTranslationTrack getTranslationTrackForTransform(Transform obj)
  1070. {
  1071. if (!obj)
  1072. {
  1073. return null;
  1074. }
  1075. foreach (AMTrack amtrack in this.trackValues)
  1076. {
  1077. if (amtrack is AMTranslationTrack && (amtrack as AMTranslationTrack).obj == obj)
  1078. {
  1079. return amtrack as AMTranslationTrack;
  1080. }
  1081. }
  1082. return null;
  1083. }
  1084. public void deleteKeysAfter(int frame)
  1085. {
  1086. foreach (AMTrack amtrack in this.trackValues)
  1087. {
  1088. bool flag = false;
  1089. for (int i = 0; i < amtrack.keys.Count; i++)
  1090. {
  1091. if (amtrack.keys[i].frame > frame)
  1092. {
  1093. amtrack.keys[i].destroy();
  1094. amtrack.keys.RemoveAt(i);
  1095. flag = true;
  1096. i--;
  1097. }
  1098. if (flag)
  1099. {
  1100. amtrack.updateCache();
  1101. }
  1102. }
  1103. }
  1104. }
  1105. public void deleteKeysBefore(int frame)
  1106. {
  1107. foreach (AMTrack amtrack in this.trackValues)
  1108. {
  1109. bool flag = false;
  1110. for (int i = 0; i < amtrack.keys.Count; i++)
  1111. {
  1112. if (amtrack.keys[i].frame < frame)
  1113. {
  1114. amtrack.keys[i].destroy();
  1115. amtrack.keys.RemoveAt(i);
  1116. flag = true;
  1117. i--;
  1118. }
  1119. if (flag)
  1120. {
  1121. amtrack.updateCache();
  1122. }
  1123. }
  1124. }
  1125. }
  1126. public void shiftOutOfBoundsKeysOnSelectedTrack()
  1127. {
  1128. int num = this.getSelectedTrack().shiftOutOfBoundsKeys();
  1129. if (this.contextSelection.Count <= 0)
  1130. {
  1131. return;
  1132. }
  1133. for (int i = 0; i < this.contextSelection.Count; i++)
  1134. {
  1135. List<int> list;
  1136. int index;
  1137. (list = this.contextSelection)[index = i] = list[index] + num;
  1138. }
  1139. foreach (AMTrack amtrack in this.trackValues)
  1140. {
  1141. if (amtrack.id != this.selectedTrack)
  1142. {
  1143. amtrack.offsetKeysFromBy(1, num);
  1144. }
  1145. }
  1146. }
  1147. public void shiftOutOfBoundsKeysOnTrack(AMTrack _track)
  1148. {
  1149. int num = _track.shiftOutOfBoundsKeys();
  1150. if (this.contextSelection.Count <= 0)
  1151. {
  1152. return;
  1153. }
  1154. for (int i = 0; i < this.contextSelection.Count; i++)
  1155. {
  1156. List<int> list;
  1157. int index;
  1158. (list = this.contextSelection)[index = i] = list[index] + num;
  1159. }
  1160. foreach (AMTrack amtrack in this.trackValues)
  1161. {
  1162. if (amtrack.id != _track.id)
  1163. {
  1164. amtrack.offsetKeysFromBy(0, num);
  1165. }
  1166. }
  1167. }
  1168. public void deleteSelectedKeysFromTrack(int track_id)
  1169. {
  1170. bool flag = false;
  1171. AMTrack track = this.getTrack(track_id);
  1172. for (int i = 0; i < track.keys.Count; i++)
  1173. {
  1174. if (this.isFrameInContextSelection(track.keys[i].frame))
  1175. {
  1176. track.keys[i].destroy();
  1177. track.keys.Remove(track.keys[i]);
  1178. i--;
  1179. flag = true;
  1180. }
  1181. }
  1182. if (flag)
  1183. {
  1184. track.updateCache();
  1185. }
  1186. }
  1187. public bool hasKeyAfter(int frame)
  1188. {
  1189. foreach (AMTrack amtrack in this.trackValues)
  1190. {
  1191. if (amtrack.keys.Count > 0 && amtrack.keys[amtrack.keys.Count - 1].frame > frame)
  1192. {
  1193. return true;
  1194. }
  1195. }
  1196. return false;
  1197. }
  1198. public bool autoKey(Transform obj, int frame)
  1199. {
  1200. if (!obj)
  1201. {
  1202. return false;
  1203. }
  1204. bool flag = false;
  1205. foreach (AMTrack amtrack in this.trackValues)
  1206. {
  1207. if (amtrack is AMTranslationTrack)
  1208. {
  1209. if ((amtrack as AMTranslationTrack).autoKey(obj, frame) && !flag)
  1210. {
  1211. flag = true;
  1212. }
  1213. }
  1214. else if (amtrack is AMRotationTrack && (amtrack as AMRotationTrack).autoKey(obj, frame) && !flag)
  1215. {
  1216. flag = true;
  1217. }
  1218. }
  1219. return flag;
  1220. }
  1221. public bool isFrameInContextSelection(int frame)
  1222. {
  1223. for (int i = 0; i < this.contextSelection.Count; i += 2)
  1224. {
  1225. if (frame >= this.contextSelection[i] && frame <= this.contextSelection[i + 1])
  1226. {
  1227. return true;
  1228. }
  1229. }
  1230. return false;
  1231. }
  1232. public bool isFrameInGhostSelection(int frame)
  1233. {
  1234. if (this.ghostSelection == null)
  1235. {
  1236. return false;
  1237. }
  1238. for (int i = 0; i < this.ghostSelection.Count; i += 2)
  1239. {
  1240. if (frame >= this.ghostSelection[i] && frame <= this.ghostSelection[i + 1])
  1241. {
  1242. return true;
  1243. }
  1244. }
  1245. return false;
  1246. }
  1247. public bool isFrameSelected(int frame)
  1248. {
  1249. if (this.hasGhostSelection())
  1250. {
  1251. return this.isFrameInGhostSelection(frame);
  1252. }
  1253. return this.isFrameInContextSelection(frame);
  1254. }
  1255. public void contextSelectFrame(int frame, bool toggle)
  1256. {
  1257. for (int i = 0; i < this.contextSelection.Count; i += 2)
  1258. {
  1259. if (frame >= this.contextSelection[i] && frame <= this.contextSelection[i + 1])
  1260. {
  1261. if (toggle)
  1262. {
  1263. if (frame == this.contextSelection[i] && frame == this.contextSelection[i + 1])
  1264. {
  1265. this.contextSelection.RemoveAt(i);
  1266. this.contextSelection.RemoveAt(i);
  1267. }
  1268. else if (frame == this.contextSelection[i])
  1269. {
  1270. List<int> list;
  1271. int index;
  1272. (list = this.contextSelection)[index = i] = list[index] + 1;
  1273. }
  1274. else if (frame == this.contextSelection[i + 1])
  1275. {
  1276. List<int> list;
  1277. int index2;
  1278. (list = this.contextSelection)[index2 = i + 1] = list[index2] + 1;
  1279. }
  1280. else
  1281. {
  1282. int item = this.contextSelection[i];
  1283. int item2 = this.contextSelection[i + 1];
  1284. this.contextSelection.RemoveAt(i);
  1285. this.contextSelection.RemoveAt(i);
  1286. this.contextSelection.Add(item);
  1287. this.contextSelection.Add(frame - 1);
  1288. this.contextSelection.Add(frame + 1);
  1289. this.contextSelection.Add(item2);
  1290. this.contextSelection.Sort();
  1291. }
  1292. }
  1293. return;
  1294. }
  1295. }
  1296. this.contextSelection.Add(frame);
  1297. this.contextSelection.Add(frame);
  1298. this.contextSelection.Sort();
  1299. }
  1300. public void contextSelectFrameRange(int startFrame, int endFrame)
  1301. {
  1302. if (startFrame == endFrame)
  1303. {
  1304. this.contextSelectFrame(endFrame, false);
  1305. return;
  1306. }
  1307. int num = endFrame;
  1308. if (endFrame < startFrame)
  1309. {
  1310. endFrame = startFrame;
  1311. startFrame = num;
  1312. }
  1313. for (int i = 0; i < this.contextSelection.Count; i += 2)
  1314. {
  1315. if (startFrame <= this.contextSelection[i] && endFrame >= this.contextSelection[i + 1])
  1316. {
  1317. this.contextSelection.RemoveAt(i);
  1318. this.contextSelection.RemoveAt(i);
  1319. i -= 2;
  1320. }
  1321. else if (this.contextSelection[i] <= startFrame && this.contextSelection[i + 1] >= endFrame)
  1322. {
  1323. return;
  1324. }
  1325. }
  1326. this.contextSelection.Add(startFrame);
  1327. this.contextSelection.Add(endFrame);
  1328. this.contextSelection.Sort();
  1329. }
  1330. public void contextSelectAllFrames()
  1331. {
  1332. this.contextSelection = new List<int>();
  1333. this.contextSelection.Add(1);
  1334. this.contextSelection.Add(this.numFrames);
  1335. }
  1336. public bool contextSelectionHasKeys()
  1337. {
  1338. foreach (AMKey amkey in this.getSelectedTrack().keys)
  1339. {
  1340. for (int i = 0; i < this.contextSelection.Count; i += 2)
  1341. {
  1342. if (this.contextSelection[i] > amkey.frame)
  1343. {
  1344. break;
  1345. }
  1346. if (this.contextSelection[i] <= amkey.frame && this.contextSelection[i + 1] >= amkey.frame)
  1347. {
  1348. return true;
  1349. }
  1350. }
  1351. }
  1352. return false;
  1353. }
  1354. public AMKey[] getContextSelectionKeysForTrack(AMTrack track)
  1355. {
  1356. List<AMKey> list = new List<AMKey>();
  1357. foreach (AMKey amkey in track.keys)
  1358. {
  1359. for (int i = 0; i < this.contextSelection.Count; i += 2)
  1360. {
  1361. if (this.contextSelection[i] > amkey.frame)
  1362. {
  1363. break;
  1364. }
  1365. if (this.contextSelection[i] <= amkey.frame && this.contextSelection[i + 1] >= amkey.frame)
  1366. {
  1367. list.Add(amkey);
  1368. }
  1369. }
  1370. }
  1371. return list.ToArray();
  1372. }
  1373. public void offsetContextSelectionFramesBy(int offset)
  1374. {
  1375. if (offset == 0)
  1376. {
  1377. return;
  1378. }
  1379. if (this.contextSelection.Count <= 0)
  1380. {
  1381. return;
  1382. }
  1383. foreach (int id in this.contextSelectionTracks)
  1384. {
  1385. bool flag = false;
  1386. List<AMKey> list = new List<AMKey>();
  1387. AMTrack track = this.getTrack(id);
  1388. foreach (AMKey amkey in track.keys)
  1389. {
  1390. for (int i = 0; i < this.contextSelection.Count; i += 2)
  1391. {
  1392. if (this.contextSelection[i] <= amkey.frame && this.contextSelection[i + 1] >= amkey.frame)
  1393. {
  1394. bool flag2 = false;
  1395. if (track.hasKeyOnFrame(amkey.frame + offset))
  1396. {
  1397. for (int j = 0; j < this.contextSelection.Count; j += 2)
  1398. {
  1399. if (this.contextSelection[j] <= amkey.frame + offset && this.contextSelection[j + 1] >= amkey.frame + offset)
  1400. {
  1401. flag2 = true;
  1402. break;
  1403. }
  1404. }
  1405. if (!flag2)
  1406. {
  1407. list.Add(track.getKeyOnFrame(amkey.frame + offset));
  1408. }
  1409. }
  1410. amkey.frame += offset;
  1411. if (!flag)
  1412. {
  1413. flag = true;
  1414. }
  1415. break;
  1416. }
  1417. }
  1418. }
  1419. foreach (AMKey amkey2 in list)
  1420. {
  1421. track.keys.Remove(amkey2);
  1422. amkey2.destroy();
  1423. }
  1424. list = new List<AMKey>();
  1425. if (flag)
  1426. {
  1427. track.updateCache();
  1428. }
  1429. }
  1430. for (int k = 0; k < this.contextSelection.Count; k++)
  1431. {
  1432. List<int> list2;
  1433. int index;
  1434. (list2 = this.contextSelection)[index = k] = list2[index] + offset;
  1435. }
  1436. this.ghostSelection = new List<int>();
  1437. }
  1438. public void offsetGhostSelectionBy(int offset)
  1439. {
  1440. for (int i = 0; i < this.ghostSelection.Count; i++)
  1441. {
  1442. List<int> list;
  1443. int index;
  1444. (list = this.ghostSelection)[index = i] = list[index] + offset;
  1445. }
  1446. this.ghost_selection_total_offset += offset;
  1447. }
  1448. public void setGhostSelection()
  1449. {
  1450. this.ghostSelection = new List<int>();
  1451. this.ghost_selection_total_offset = 0;
  1452. foreach (int item in this.contextSelection)
  1453. {
  1454. this.ghostSelection.Add(item);
  1455. }
  1456. }
  1457. public bool hasGhostSelection()
  1458. {
  1459. return this.ghostSelection == null || this.ghostSelection.Count > 0;
  1460. }
  1461. public int[] getKeyFramesInGhostSelection(int startFrame, int endFrame, int track_id)
  1462. {
  1463. List<int> list = new List<int>();
  1464. if (track_id <= -1)
  1465. {
  1466. return list.ToArray();
  1467. }
  1468. foreach (AMKey amkey in this.getTrack(track_id).keys)
  1469. {
  1470. if (amkey.frame + this.ghost_selection_total_offset >= startFrame)
  1471. {
  1472. if (amkey.frame + this.ghost_selection_total_offset > endFrame)
  1473. {
  1474. break;
  1475. }
  1476. if (this.isFrameInContextSelection(amkey.frame))
  1477. {
  1478. list.Add(amkey.frame + this.ghost_selection_total_offset);
  1479. }
  1480. }
  1481. }
  1482. return list.ToArray();
  1483. }
  1484. public void maintainTake()
  1485. {
  1486. foreach (AMTrack amtrack in this.trackValues)
  1487. {
  1488. if (!amtrack.parentTake)
  1489. {
  1490. amtrack.parentTake = this;
  1491. }
  1492. }
  1493. }
  1494. public void sampleAudio(float frame, float speed)
  1495. {
  1496. foreach (AMTrack amtrack in this.trackValues)
  1497. {
  1498. if (amtrack is AMAudioTrack)
  1499. {
  1500. (amtrack as AMAudioTrack).sampleAudio(frame, speed, this.frameRate);
  1501. }
  1502. }
  1503. }
  1504. public void stopAudio()
  1505. {
  1506. foreach (AMTrack amtrack in this.trackValues)
  1507. {
  1508. if (amtrack is AMAudioTrack)
  1509. {
  1510. (amtrack as AMAudioTrack).stopAudio();
  1511. }
  1512. }
  1513. }
  1514. public void stopAnimations()
  1515. {
  1516. foreach (AMTrack amtrack in this.trackValues)
  1517. {
  1518. if (amtrack is AMAnimationTrack)
  1519. {
  1520. if ((amtrack as AMAnimationTrack).obj)
  1521. {
  1522. (amtrack as AMAnimationTrack).obj.GetComponent<Animation>().Stop();
  1523. }
  1524. }
  1525. }
  1526. }
  1527. public void resetScene()
  1528. {
  1529. foreach (AMTrack amtrack in this.trackValues)
  1530. {
  1531. if (!(amtrack is AMAnimationTrack))
  1532. {
  1533. if (amtrack is AMOrientationTrack)
  1534. {
  1535. amtrack.previewFrame(1f, this.getTranslationTrackForTransform((amtrack as AMOrientationTrack).getTargetForFrame(1f)));
  1536. }
  1537. else
  1538. {
  1539. amtrack.previewFrame(1f, null);
  1540. }
  1541. }
  1542. }
  1543. }
  1544. public void drawGizmos(float gizmo_size, bool inPlayMode)
  1545. {
  1546. foreach (AMTrack amtrack in this.trackValues)
  1547. {
  1548. if (amtrack is AMTranslationTrack)
  1549. {
  1550. amtrack.drawGizmos(gizmo_size);
  1551. }
  1552. else if (amtrack is AMOrientationTrack)
  1553. {
  1554. (amtrack as AMOrientationTrack).drawGizmos(gizmo_size, inPlayMode, this.selectedFrame);
  1555. }
  1556. }
  1557. }
  1558. public void maintainCaches()
  1559. {
  1560. foreach (AMTrack amtrack in this.trackValues)
  1561. {
  1562. bool flag = false;
  1563. foreach (AMAction x in amtrack.cache)
  1564. {
  1565. if (x == null)
  1566. {
  1567. flag = true;
  1568. break;
  1569. }
  1570. }
  1571. if (flag)
  1572. {
  1573. amtrack.updateCache();
  1574. }
  1575. }
  1576. }
  1577. public void previewFrameInvoker(float frame)
  1578. {
  1579. this.previewFrame(frame, false, true, false, false);
  1580. }
  1581. public void executeActions(float fromFrame = 0f)
  1582. {
  1583. float num = fromFrame / (float)this.frameRate;
  1584. this.maintainCaches();
  1585. this.previewFrame(fromFrame, false, false, false, true);
  1586. foreach (AMTrack amtrack in this.trackValues)
  1587. {
  1588. foreach (AMAction amaction in amtrack.cache)
  1589. {
  1590. if (amaction is AMAudioAction)
  1591. {
  1592. if (!(amaction as AMAudioAction).loop && amaction.startFrame + (amaction as AMAudioAction).getNumberOfFrames(this.frameRate) - 1 < (int)fromFrame)
  1593. {
  1594. continue;
  1595. }
  1596. }
  1597. else if (amaction.startFrame + amaction.getNumberOfFrames() - 1 < (int)fromFrame)
  1598. {
  1599. continue;
  1600. }
  1601. if (amaction is AMCameraSwitcherAction)
  1602. {
  1603. (amaction as AMCameraSwitcherAction).execute(this.frameRate, num, (amtrack as AMCameraSwitcherTrack).cachedAllCameras);
  1604. }
  1605. else
  1606. {
  1607. amaction.execute(this.frameRate, num, amtrack.name);
  1608. }
  1609. }
  1610. }
  1611. }
  1612. public void executeActions(List<int> exclusion_track_id_list, float fromFrame = 0f)
  1613. {
  1614. HashSet<int> hashSet = new HashSet<int>();
  1615. for (int i = 0; i < exclusion_track_id_list.Count; i++)
  1616. {
  1617. if (!hashSet.Contains(exclusion_track_id_list[i]))
  1618. {
  1619. hashSet.Add(exclusion_track_id_list[i]);
  1620. }
  1621. }
  1622. float num = fromFrame / (float)this.frameRate;
  1623. this.maintainCaches();
  1624. this.previewFrame(fromFrame, false, false, false, true);
  1625. int num2 = 0;
  1626. int num3 = 0;
  1627. foreach (AMTrack amtrack in this.trackValues)
  1628. {
  1629. if (!hashSet.Contains(amtrack.id))
  1630. {
  1631. foreach (AMAction amaction in amtrack.cache)
  1632. {
  1633. if (amaction is AMAudioAction)
  1634. {
  1635. if (!(amaction as AMAudioAction).loop && amaction.startFrame + (amaction as AMAudioAction).getNumberOfFrames(this.frameRate) - 1 < (int)fromFrame)
  1636. {
  1637. continue;
  1638. }
  1639. }
  1640. else if (amaction.startFrame + amaction.getNumberOfFrames() - 1 < (int)fromFrame)
  1641. {
  1642. continue;
  1643. }
  1644. if (amaction is AMCameraSwitcherAction)
  1645. {
  1646. num2++;
  1647. (amaction as AMCameraSwitcherAction).execute(this.frameRate, num, (amtrack as AMCameraSwitcherTrack).cachedAllCameras);
  1648. }
  1649. else
  1650. {
  1651. num2++;
  1652. amaction.execute(this.frameRate, num, amtrack.name);
  1653. }
  1654. }
  1655. }
  1656. }
  1657. Debug.Log("dance object data");
  1658. Debug.Log("create : " + num2);
  1659. Debug.Log("skip : " + num3);
  1660. }
  1661. public void setupCameraSwitcher(float fromFrame = 0f)
  1662. {
  1663. if (!this.cameraSwitcher || this.cameraSwitcher.keys.Count <= 0)
  1664. {
  1665. return;
  1666. }
  1667. this.cameraSwitcher.cachedAllCameras = this.cameraSwitcher.getAllCameras();
  1668. AMCameraSwitcherKey amcameraSwitcherKey = this.cameraSwitcher.keys[0] as AMCameraSwitcherKey;
  1669. if (amcameraSwitcherKey.type == 0)
  1670. {
  1671. if (amcameraSwitcherKey.camera)
  1672. {
  1673. AMTween.SetTopCamera(amcameraSwitcherKey.camera, this.cameraSwitcher.cachedAllCameras);
  1674. }
  1675. }
  1676. else if (amcameraSwitcherKey.type == 1)
  1677. {
  1678. AMTween.ShowColor(amcameraSwitcherKey.color);
  1679. }
  1680. }
  1681. public float getElementsHeight(int group_id, float height_track, float height_track_foldin, float height_group)
  1682. {
  1683. this.initGroups();
  1684. float num = 0f;
  1685. AMGroup group = this.getGroup(group_id);
  1686. if (group_id < 0)
  1687. {
  1688. num += height_group;
  1689. if (group.elements.Count <= 0 && group.foldout)
  1690. {
  1691. num += height_group;
  1692. }
  1693. }
  1694. if (group_id == 0 || group.foldout)
  1695. {
  1696. foreach (int num2 in group.elements)
  1697. {
  1698. if (num2 < 0)
  1699. {
  1700. num += this.getElementsHeight(num2, height_track, height_track_foldin, height_group);
  1701. }
  1702. else if (this.getTrack(num2).foldout)
  1703. {
  1704. num += height_track;
  1705. }
  1706. else
  1707. {
  1708. num += height_track_foldin;
  1709. }
  1710. }
  1711. }
  1712. return num;
  1713. }
  1714. public float getElementsHeight(int element_id, int group_id, float height_track, float height_track_foldin, float height_group, ref bool found)
  1715. {
  1716. this.initGroups();
  1717. float num = 0f;
  1718. AMGroup group = this.getGroup(group_id);
  1719. if (group_id < 0)
  1720. {
  1721. if (group_id == element_id)
  1722. {
  1723. found = true;
  1724. return num;
  1725. }
  1726. num += height_group;
  1727. if (group.elements.Count <= 0 && group.foldout)
  1728. {
  1729. num += height_group;
  1730. }
  1731. }
  1732. if (group_id == 0 || group.foldout)
  1733. {
  1734. foreach (int num2 in group.elements)
  1735. {
  1736. if (num2 == element_id)
  1737. {
  1738. found = true;
  1739. return num;
  1740. }
  1741. if (num2 < 0)
  1742. {
  1743. num += this.getElementsHeight(element_id, num2, height_track, height_track_foldin, height_group, ref found);
  1744. if (found)
  1745. {
  1746. return num;
  1747. }
  1748. }
  1749. else if (this.getTrack(num2).foldout)
  1750. {
  1751. num += height_track;
  1752. }
  1753. else
  1754. {
  1755. num += height_track_foldin;
  1756. }
  1757. }
  1758. return num;
  1759. }
  1760. return num;
  1761. }
  1762. public float getElementY(int element_id, float height_track, float height_track_foldin, float height_group)
  1763. {
  1764. bool flag = false;
  1765. return this.getElementsHeight(element_id, 0, height_track, height_track_foldin, height_group, ref flag);
  1766. }
  1767. public void destroy()
  1768. {
  1769. foreach (AMTrack amtrack in this.trackValues)
  1770. {
  1771. amtrack.destroy();
  1772. }
  1773. this.rootGroup.destroy();
  1774. foreach (AMGroup amgroup in this.groupValues)
  1775. {
  1776. amgroup.destroy();
  1777. }
  1778. UnityEngine.Object.DestroyImmediate(this);
  1779. }
  1780. public List<GameObject> getDependencies()
  1781. {
  1782. List<GameObject> list = new List<GameObject>();
  1783. foreach (AMTrack amtrack in this.trackValues)
  1784. {
  1785. list = list.Union(amtrack.getDependencies()).ToList<GameObject>();
  1786. }
  1787. return list;
  1788. }
  1789. public List<GameObject> updateDependencies(List<GameObject> newReferences, List<GameObject> oldReferences)
  1790. {
  1791. List<GameObject> list = new List<GameObject>();
  1792. foreach (AMTrack amtrack in this.trackValues)
  1793. {
  1794. list = list.Union(amtrack.updateDependencies(newReferences, oldReferences)).ToList<GameObject>();
  1795. amtrack.updateCache();
  1796. }
  1797. return list;
  1798. }
  1799. public new string name;
  1800. public int frameRate = 24;
  1801. public int numFrames = 1440;
  1802. public float startFrame = 1f;
  1803. public float endFrame = 100f;
  1804. public int playbackSpeedIndex = 2;
  1805. public int selectedTrack = -1;
  1806. public int selectedFrame = 1;
  1807. public int selectedGroup;
  1808. public List<int> trackKeys = new List<int>();
  1809. public List<AMTrack> trackValues = new List<AMTrack>();
  1810. public List<int> contextSelection = new List<int>();
  1811. public List<int> ghostSelection = new List<int>();
  1812. public List<int> contextSelectionTracks = new List<int>();
  1813. public int track_count = 1;
  1814. public int group_count;
  1815. public AMGroup rootGroup;
  1816. public List<int> groupKeys = new List<int>();
  1817. public List<AMGroup> groupValues = new List<AMGroup>();
  1818. public static bool isProLicense = true;
  1819. public AMCameraSwitcherTrack cameraSwitcher;
  1820. private List<AMTake.Morph> morphs;
  1821. private int ghost_selection_total_offset;
  1822. public class Morph
  1823. {
  1824. public Morph(GameObject obj, MethodInfo methodInfo, Component component, List<float> morph)
  1825. {
  1826. this.obj = obj;
  1827. this.methodInfo = methodInfo;
  1828. this.component = component;
  1829. this.morph = new List<float>(morph);
  1830. }
  1831. public void blendMorph(List<float> new_morph)
  1832. {
  1833. for (int i = 0; i < ((this.morph.Count < new_morph.Count) ? new_morph.Count : this.morph.Count); i++)
  1834. {
  1835. if (i >= new_morph.Count)
  1836. {
  1837. break;
  1838. }
  1839. if (i >= this.morph.Count)
  1840. {
  1841. this.morph.Add(0f);
  1842. }
  1843. if (this.morph[i] == 0f)
  1844. {
  1845. this.morph[i] = new_morph[i];
  1846. }
  1847. }
  1848. }
  1849. public GameObject obj;
  1850. public MethodInfo methodInfo;
  1851. public Component component;
  1852. public List<float> morph;
  1853. }
  1854. }