123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using UnityEngine;
- [Serializable]
- public class AMTake : ScriptableObject
- {
- public AMTake(string name)
- {
- this.name = name;
- }
- public void selectTrack(int index, bool isShiftDown, bool isControlDown)
- {
- bool flag = false;
- if (this.contextSelectionTracks != null)
- {
- flag = this.contextSelectionTracks.Contains(index);
- if (!isShiftDown && !isControlDown)
- {
- if (this.selectedTrack != index)
- {
- this.selectedTrack = index;
- if (!flag)
- {
- this.contextSelection = new List<int>();
- this.contextSelectionTracks = new List<int>();
- }
- }
- if (index > -1)
- {
- this.selectGroup(this.getTrackGroup(index), false, false, true);
- }
- }
- }
- else
- {
- this.contextSelectionTracks = new List<int>();
- }
- if (!flag)
- {
- this.contextSelectionTracks.Add(index);
- }
- else if (isControlDown && this.selectedTrack != index && !isShiftDown)
- {
- this.contextSelectionTracks.Remove(index);
- }
- if ((this.selectedTrack != -1 || this.selectedGroup != 0) && isShiftDown)
- {
- List<int> trackIDsForRange = this.getTrackIDsForRange((this.selectedTrack == -1) ? this.selectedGroup : this.selectedTrack, index);
- foreach (int item in trackIDsForRange)
- {
- if (!this.contextSelectionTracks.Contains(item))
- {
- this.contextSelectionTracks.Add(item);
- }
- }
- }
- }
- public AMTrack getSelectedTrack()
- {
- return this.getTrack(this.selectedTrack);
- }
- public void addTranslationTrack(GameObject obj)
- {
- AMTranslationTrack amtranslationTrack = ScriptableObject.CreateInstance<AMTranslationTrack>();
- amtranslationTrack.setName(this.getTrackCount());
- amtranslationTrack.id = this.getUniqueTrackID();
- if (obj)
- {
- amtranslationTrack.obj = obj.transform;
- }
- this.addTrack(amtranslationTrack);
- }
- public void addRotationTrack(GameObject obj)
- {
- AMRotationTrack amrotationTrack = ScriptableObject.CreateInstance<AMRotationTrack>();
- amrotationTrack.setName(this.getTrackCount());
- amrotationTrack.id = this.getUniqueTrackID();
- if (obj)
- {
- amrotationTrack.obj = obj.transform;
- }
- this.addTrack(amrotationTrack);
- }
- public void addOrientationTrack(GameObject obj)
- {
- AMOrientationTrack amorientationTrack = ScriptableObject.CreateInstance<AMOrientationTrack>();
- amorientationTrack.setName(this.getTrackCount());
- amorientationTrack.id = this.getUniqueTrackID();
- if (obj)
- {
- amorientationTrack.obj = obj.transform;
- }
- this.addTrack(amorientationTrack);
- }
- public void addAnimationTrack(GameObject obj)
- {
- AMAnimationTrack amanimationTrack = ScriptableObject.CreateInstance<AMAnimationTrack>();
- amanimationTrack.setName(this.getTrackCount());
- amanimationTrack.id = this.getUniqueTrackID();
- if (obj && obj.GetComponent(typeof(Animation)))
- {
- amanimationTrack.obj = obj;
- }
- this.addTrack(amanimationTrack);
- }
- public void addAudioTrack(GameObject obj)
- {
- AMAudioTrack amaudioTrack = ScriptableObject.CreateInstance<AMAudioTrack>();
- amaudioTrack.setName(this.getTrackCount());
- amaudioTrack.id = this.getUniqueTrackID();
- if (obj && obj.GetComponent(typeof(AudioSource)))
- {
- amaudioTrack.audioSource = (AudioSource)obj.GetComponent(typeof(AudioSource));
- }
- this.addTrack(amaudioTrack);
- }
- public void addPropertyTrack(GameObject obj)
- {
- AMPropertyTrack ampropertyTrack = ScriptableObject.CreateInstance<AMPropertyTrack>();
- ampropertyTrack.setName(this.getTrackCount());
- ampropertyTrack.id = this.getUniqueTrackID();
- if (obj)
- {
- ampropertyTrack.obj = obj;
- }
- this.addTrack(ampropertyTrack);
- }
- public void addEventTrack(GameObject obj)
- {
- AMEventTrack ameventTrack = ScriptableObject.CreateInstance<AMEventTrack>();
- ameventTrack.setName(this.getTrackCount());
- ameventTrack.id = this.getUniqueTrackID();
- if (obj)
- {
- ameventTrack.obj = obj;
- }
- this.addTrack(ameventTrack);
- }
- public void addCameraSwitcherTrack(GameObject obj)
- {
- if (this.cameraSwitcher)
- {
- Camera camera = obj.AddComponent<Camera>();
- if (camera)
- {
- this.cameraSwitcher.addKey(this.selectedFrame, camera, null);
- }
- return;
- }
- AMCameraSwitcherTrack amcameraSwitcherTrack = ScriptableObject.CreateInstance<AMCameraSwitcherTrack>();
- amcameraSwitcherTrack.setName(this.getTrackCount());
- amcameraSwitcherTrack.id = this.getUniqueTrackID();
- if (obj && obj.GetComponent(typeof(Camera)))
- {
- amcameraSwitcherTrack.addKey(1, (Camera)obj.GetComponent(typeof(Camera)), null);
- }
- this.addTrack(amcameraSwitcherTrack);
- this.cameraSwitcher = amcameraSwitcherTrack;
- }
- public void deleteTrack(int id, bool deleteFromGroup = true)
- {
- int trackIndex = this.getTrackIndex(id);
- if (trackIndex < 0 || trackIndex >= this.trackKeys.Count || trackIndex >= this.trackValues.Count)
- {
- Debug.LogError("Animator: Track id " + id + " not found");
- return;
- }
- if (this.cameraSwitcher == this.trackValues[trackIndex])
- {
- this.cameraSwitcher = null;
- }
- this.trackKeys.RemoveAt(trackIndex);
- this.trackValues.RemoveAt(trackIndex);
- if (deleteFromGroup)
- {
- this.deleteTrackFromGroups(id);
- }
- }
- public List<int> getTrackIDsForRange(int start_id, int end_id)
- {
- if (start_id == end_id)
- {
- return new List<int>();
- }
- int elementLocationIndex = this.getElementLocationIndex(start_id);
- if (elementLocationIndex == 0)
- {
- return new List<int>();
- }
- int elementLocationIndex2 = this.getElementLocationIndex(end_id);
- if (elementLocationIndex2 == 0)
- {
- return new List<int>();
- }
- if (elementLocationIndex > elementLocationIndex2)
- {
- int num = start_id;
- start_id = end_id;
- end_id = num;
- }
- List<int> list = new List<int>();
- bool flag = false;
- bool flag2 = false;
- return this.getTrackIDsForGroup(0, start_id, end_id, ref flag, ref flag2);
- }
- private List<int> getTrackIDsForGroup(int group_id, int start_id, int end_id, ref bool foundStartID, ref bool foundEndID)
- {
- List<int> list = new List<int>();
- AMGroup group = this.getGroup(group_id);
- int i = 0;
- while (i < group.elements.Count)
- {
- if (group.elements[i] == start_id)
- {
- foundStartID = true;
- if (group.elements[i] <= 0)
- {
- goto IL_5D;
- }
- }
- else
- {
- if (group.elements[i] == end_id)
- {
- foundEndID = true;
- goto IL_5D;
- }
- goto IL_5D;
- }
- IL_C1:
- i++;
- continue;
- IL_5D:
- if (!foundEndID)
- {
- if (group.elements[i] > 0)
- {
- if (foundStartID)
- {
- list.Add(group.elements[i]);
- }
- }
- else
- {
- list.AddRange(this.getTrackIDsForGroup(group.elements[i], start_id, end_id, ref foundStartID, ref foundEndID));
- }
- }
- if (foundEndID)
- {
- break;
- }
- goto IL_C1;
- }
- return list;
- }
- public int getElementLocationIndex(int element_id)
- {
- int result = 0;
- bool flag = false;
- this.getElementLocationIndexForGroup(0, element_id, ref result, ref flag);
- return result;
- }
- private void getElementLocationIndexForGroup(int group_id, int element_id, ref int count, ref bool found)
- {
- AMGroup group = this.getGroup(group_id);
- foreach (int num in group.elements)
- {
- count++;
- if (num == element_id)
- {
- found = true;
- break;
- }
- if (num <= 0)
- {
- this.getElementLocationIndexForGroup(num, element_id, ref count, ref found);
- if (found)
- {
- break;
- }
- }
- }
- }
- public void selectGroup(int group_id, bool isShiftDown, bool isControlDown, bool softSelect = false)
- {
- if (isShiftDown || isControlDown)
- {
- this.contextSelectGroup(group_id, isControlDown);
- if ((this.selectedTrack != -1 || this.selectedGroup != 0) && isShiftDown)
- {
- List<int> trackIDsForRange = this.getTrackIDsForRange((this.selectedTrack == -1) ? this.selectedGroup : this.selectedTrack, group_id);
- foreach (int item in trackIDsForRange)
- {
- if (!this.contextSelectionTracks.Contains(item))
- {
- this.contextSelectionTracks.Add(item);
- }
- }
- }
- }
- else if (!softSelect && this.contextSelectionTracks.Count == 1)
- {
- this.contextSelectionTracks = new List<int>();
- }
- this.selectedGroup = group_id;
- }
- public void contextSelectGroup(int group_id, bool isControlDown)
- {
- AMGroup group = this.getGroup(group_id);
- int num = 0;
- bool flag = isControlDown && this.isGroupSelected(group_id, ref num);
- for (int i = 0; i < group.elements.Count; i++)
- {
- if (group.elements[i] > 0)
- {
- bool flag2 = this.contextSelectionTracks.Contains(group.elements[i]);
- if (flag)
- {
- if (flag2)
- {
- this.contextSelectionTracks.Remove(group.elements[i]);
- }
- }
- else if (!flag2)
- {
- this.contextSelectionTracks.Add(group.elements[i]);
- }
- }
- else
- {
- this.contextSelectGroup(group.elements[i], flag);
- }
- }
- }
- public bool isGroupSelected(int group_id, ref int numTracks)
- {
- AMGroup group = this.getGroup(group_id);
- for (int i = 0; i < group.elements.Count; i++)
- {
- if (group.elements[i] > 0)
- {
- if (!this.contextSelectionTracks.Contains(group.elements[i]))
- {
- return false;
- }
- numTracks++;
- }
- else if (!this.isGroupSelected(group.elements[i], ref numTracks))
- {
- return false;
- }
- }
- return true;
- }
- public void deleteGroup(int group_id, bool deleteContents)
- {
- if (group_id >= 0)
- {
- return;
- }
- AMGroup group = this.getGroup(group_id);
- if (deleteContents)
- {
- for (int i = 0; i < group.elements.Count; i++)
- {
- if (group.elements[i] > 0)
- {
- this.deleteTrack(group.elements[i], false);
- }
- else if (group.elements[i] < 0)
- {
- this.deleteGroup(group.elements[i], deleteContents);
- }
- }
- }
- else
- {
- AMGroup group2 = this.getGroup(this.getElementGroup(group_id));
- for (int j = 0; j < group2.elements.Count; j++)
- {
- if (group2.elements[j] == group_id)
- {
- group2.elements.InsertRange(j, group.elements);
- break;
- }
- }
- }
- this.removeFromGroup(group.group_id);
- bool flag = false;
- int k;
- for (k = 0; k < this.groupValues.Count; k++)
- {
- if (this.groupValues[k] == group)
- {
- flag = true;
- this.groupValues.Remove(group);
- break;
- }
- }
- if (flag)
- {
- this.groupKeys.RemoveAt(k);
- }
- group.destroy();
- }
- public void deleteSelectedGroup(bool deleteContents)
- {
- this.deleteGroup(this.selectedGroup, deleteContents);
- this.selectedGroup = 0;
- }
- public int getUniqueTrackID()
- {
- this.track_count++;
- foreach (int num in this.trackKeys)
- {
- if (num >= this.track_count)
- {
- this.track_count = num + 1;
- }
- }
- return this.track_count;
- }
- public int getUniqueGroupID()
- {
- this.group_count--;
- foreach (int num in this.groupKeys)
- {
- if (num <= this.group_count)
- {
- this.group_count = num - 1;
- }
- }
- return this.group_count;
- }
- public int getTrackIndex(int id)
- {
- int result = -1;
- for (int i = 0; i < this.trackKeys.Count; i++)
- {
- if (this.trackKeys[i] == id)
- {
- result = i;
- break;
- }
- }
- return result;
- }
- public AMTrack getTrack(int id)
- {
- int trackIndex = this.getTrackIndex(id);
- if (trackIndex == -1 || trackIndex >= this.trackValues.Count)
- {
- Debug.LogError("Animator: Track id " + id + " not found.");
- return new AMTrack();
- }
- return this.trackValues[trackIndex];
- }
- public AMAnimationTrack findAnimationTrack(GameObject go)
- {
- return this.trackValues.Find((AMTrack a) => a is AMAnimationTrack && (a as AMAnimationTrack).obj == go) as AMAnimationTrack;
- }
- public AMAnimationTrack findAnimationTrack(string name)
- {
- return this.trackValues.Find((AMTrack a) => a is AMAnimationTrack && (a as AMAnimationTrack).name == name) as AMAnimationTrack;
- }
- public AMTranslationTrack findTranslationTrack(Transform tr)
- {
- return this.trackValues.Find((AMTrack a) => a is AMTranslationTrack && (a as AMTranslationTrack).obj == tr) as AMTranslationTrack;
- }
- public AMTranslationTrack[] findTranslationTrack(string objName)
- {
- List<AMTrack> source = this.trackValues.FindAll((AMTrack a) => a is AMTranslationTrack && (a as AMTranslationTrack).objName == objName);
- return (from i in source
- select (AMTranslationTrack)i).ToArray<AMTranslationTrack>();
- }
- public AMRotationTrack findRotationTrack(Transform tr)
- {
- return this.trackValues.Find((AMTrack a) => a is AMRotationTrack && (a as AMRotationTrack).obj == tr) as AMRotationTrack;
- }
- public AMRotationTrack[] findRotationTrack(string objName)
- {
- List<AMTrack> source = this.trackValues.FindAll((AMTrack a) => a is AMRotationTrack && (a as AMRotationTrack).objName == objName);
- return (from i in source
- select (AMRotationTrack)i).ToArray<AMRotationTrack>();
- }
- public AMPropertyTrack findPropertyTrack(GameObject go)
- {
- return this.trackValues.Find((AMTrack a) => a is AMPropertyTrack && (a as AMPropertyTrack).obj == go) as AMPropertyTrack;
- }
- public AMPropertyTrack[] findPropertyTrack(string objName)
- {
- List<AMTrack> source = this.trackValues.FindAll((AMTrack a) => a is AMPropertyTrack && (a as AMPropertyTrack).objName == objName);
- return (from i in source
- select (AMPropertyTrack)i).ToArray<AMPropertyTrack>();
- }
- public AMAudioTrack[] findAudioTrack(string objName)
- {
- List<AMTrack> source = this.trackValues.FindAll((AMTrack a) => a is AMAudioTrack && (a as AMAudioTrack).asName == objName);
- return (from i in source
- select (AMAudioTrack)i).ToArray<AMAudioTrack>();
- }
- public int getElementGroup(int id)
- {
- foreach (int num in this.rootGroup.elements)
- {
- if (num == id)
- {
- return 0;
- }
- }
- foreach (AMGroup amgroup in this.groupValues)
- {
- foreach (int num2 in amgroup.elements)
- {
- if (num2 == id)
- {
- return amgroup.group_id;
- }
- }
- }
- Debug.LogError("Animator: Group not found for element " + id);
- return 0;
- }
- public bool replaceElement(int source_id, int new_id)
- {
- for (int i = 0; i < this.rootGroup.elements.Count; i++)
- {
- if (this.rootGroup.elements[i] == source_id)
- {
- this.rootGroup.elements[i] = new_id;
- return true;
- }
- }
- for (int j = 0; j < this.groupValues.Count; j++)
- {
- AMGroup amgroup = this.groupValues[j];
- for (int k = 0; k < amgroup.elements.Count; k++)
- {
- if (amgroup.elements[k] == source_id)
- {
- amgroup.elements[k] = new_id;
- return true;
- }
- }
- }
- return false;
- }
- public void addTrack(AMTrack track)
- {
- this.trackKeys.Add(track.id);
- this.trackValues.Add(track);
- this.addToGroup(track.id, this.selectedGroup, false, -1);
- track.parentTake = this;
- }
- public void moveToGroup(int source_id, int dest_group_id, bool first = false, int dest_track_id = -1)
- {
- this.initGroups();
- bool flag = true;
- if (source_id < 0)
- {
- int elementRootGroup = this.getElementRootGroup(dest_group_id, source_id);
- if (elementRootGroup < 1)
- {
- this.removeFromGroup(elementRootGroup);
- this.replaceElement(source_id, elementRootGroup);
- flag = false;
- }
- else if (elementRootGroup == 2)
- {
- this.removeFromGroup(dest_group_id);
- this.replaceElement(source_id, dest_group_id);
- flag = false;
- }
- }
- if (flag)
- {
- this.removeFromGroup(source_id);
- }
- this.addToGroup(source_id, dest_group_id, first, dest_track_id);
- }
- public bool isElementInGroup(int id, int group_id)
- {
- if (group_id > 0)
- {
- return false;
- }
- AMGroup group = this.getGroup(group_id);
- foreach (int num in group.elements)
- {
- if (num == id)
- {
- return true;
- }
- if (this.isElementInGroup(id, num))
- {
- return true;
- }
- }
- return false;
- }
- public int getElementRootGroup(int element_id, int group_id)
- {
- if (group_id > 0)
- {
- return 1;
- }
- AMGroup group = this.getGroup(group_id);
- foreach (int num in group.elements)
- {
- if (num == element_id)
- {
- return 2;
- }
- if (num <= 0 && this.isElementInGroup(element_id, num))
- {
- return num;
- }
- }
- return 1;
- }
- public void moveGroupElement(int source_id, int dest_id)
- {
- this.initGroups();
- this.removeFromGroup(source_id);
- bool flag = false;
- for (int i = 0; i < this.rootGroup.elements.Count; i++)
- {
- if (this.rootGroup.elements[i] == dest_id)
- {
- if (i < this.rootGroup.elements.Count)
- {
- this.rootGroup.elements.Insert(i + 1, source_id);
- }
- else
- {
- this.rootGroup.elements.Add(source_id);
- }
- flag = true;
- break;
- }
- }
- if (!flag)
- {
- foreach (AMGroup amgroup in this.groupValues)
- {
- for (int j = 0; j < amgroup.elements.Count; j++)
- {
- if (amgroup.elements[j] == dest_id)
- {
- if (j < amgroup.elements.Count - 1)
- {
- amgroup.elements.Insert(j + 1, source_id);
- }
- else
- {
- amgroup.elements.Add(source_id);
- }
- flag = true;
- break;
- }
- }
- if (flag)
- {
- break;
- }
- }
- }
- if (!flag)
- {
- Debug.LogWarning("Animator: No group found for element id " + dest_id);
- this.rootGroup.elements.Add(source_id);
- }
- }
- public void addGroup()
- {
- this.initGroups();
- AMGroup amgroup = ScriptableObject.CreateInstance<AMGroup>();
- amgroup.init(this.getUniqueGroupID(), null);
- this.groupKeys.Add(amgroup.group_id);
- this.groupValues.Add(amgroup);
- this.rootGroup.elements.Add(amgroup.group_id);
- this.selectedGroup = amgroup.group_id;
- }
- public int getTrackCount()
- {
- return this.trackKeys.Count;
- }
- public int getGroupIndex(int id)
- {
- int result = -1;
- for (int i = 0; i < this.groupKeys.Count; i++)
- {
- if (this.groupKeys[i] == id)
- {
- result = i;
- break;
- }
- }
- return result;
- }
- public AMGroup getGroup(int id)
- {
- this.initGroups();
- if (id == 0)
- {
- return this.rootGroup;
- }
- int groupIndex = this.getGroupIndex(id);
- if (groupIndex == -1 || groupIndex >= this.groupValues.Count)
- {
- Debug.LogError("Animator: Group id " + id + " not found.");
- return new AMGroup();
- }
- return this.groupValues[groupIndex];
- }
- public void initGroups()
- {
- if (this.rootGroup == null)
- {
- AMGroup amgroup = ScriptableObject.CreateInstance<AMGroup>();
- amgroup.init(0, null);
- this.rootGroup = amgroup;
- }
- }
- public int getTrackGroup(int track_id)
- {
- foreach (int num in this.rootGroup.elements)
- {
- if (num == track_id)
- {
- return 0;
- }
- }
- foreach (AMGroup amgroup in this.groupValues)
- {
- foreach (int num2 in amgroup.elements)
- {
- if (num2 == track_id)
- {
- return amgroup.group_id;
- }
- }
- }
- Debug.LogWarning("Animator: No group found for Track " + track_id);
- return 0;
- }
- public void removeFromGroup(int source_id)
- {
- foreach (int num in this.rootGroup.elements)
- {
- if (num == source_id)
- {
- this.rootGroup.elements.Remove(num);
- return;
- }
- }
- foreach (AMGroup amgroup in this.groupValues)
- {
- foreach (int num2 in amgroup.elements)
- {
- if (num2 == source_id)
- {
- amgroup.elements.Remove(num2);
- return;
- }
- }
- }
- }
- public void addToGroup(int source_id, int group_id, bool first = false, int dest_track_id = -1)
- {
- this.initGroups();
- bool flag = false;
- if (group_id == 0)
- {
- if (dest_track_id != -1)
- {
- for (int i = 0; i < this.rootGroup.elements.Count - 1; i++)
- {
- if (this.rootGroup.elements[i] == dest_track_id)
- {
- this.rootGroup.elements.Insert(i + 1, source_id);
- flag = true;
- break;
- }
- }
- }
- if (!flag)
- {
- if (first)
- {
- this.rootGroup.elements.Insert(0, source_id);
- }
- else
- {
- this.rootGroup.elements.Add(source_id);
- }
- }
- }
- else
- {
- int groupIndex = this.getGroupIndex(group_id);
- if (groupIndex == -1)
- {
- Debug.LogError("Animator: Group " + group_id + " not found.");
- return;
- }
- AMGroup group = this.getGroup(group_id);
- if (dest_track_id != -1)
- {
- for (int j = 0; j < group.elements.Count; j++)
- {
- if (group.elements[j] == dest_track_id)
- {
- if (j < group.elements.Count - 1)
- {
- group.elements.Insert(j + 1, source_id);
- }
- else
- {
- group.elements.Add(source_id);
- }
- flag = true;
- break;
- }
- }
- }
- if (!flag)
- {
- if (first)
- {
- group.elements.Insert(0, source_id);
- }
- else
- {
- group.elements.Add(source_id);
- }
- }
- if (!group.foldout)
- {
- group.foldout = true;
- }
- }
- }
- public void deleteTrackFromGroups(int _id)
- {
- bool flag = false;
- foreach (int num in this.rootGroup.elements)
- {
- if (num == _id)
- {
- this.rootGroup.elements.Remove(num);
- flag = true;
- break;
- }
- }
- if (!flag)
- {
- foreach (AMGroup amgroup in this.groupValues)
- {
- foreach (int num2 in amgroup.elements)
- {
- if (num2 == _id)
- {
- amgroup.elements.Remove(num2);
- flag = true;
- break;
- }
- }
- }
- }
- if (!flag)
- {
- Debug.LogWarning("Animator: Deleted track " + _id + " not found in groups.");
- }
- }
- public void selectFrame(int track, int num, float numFramesToRender, bool isShiftDown, bool isControlDown)
- {
- this.selectedFrame = num;
- this.selectTrack(track, isShiftDown, isControlDown);
- if ((float)this.selectedFrame < this.startFrame || (float)this.selectedFrame > this.endFrame)
- {
- this.startFrame = (float)this.selectedFrame;
- this.endFrame = this.startFrame + (float)((int)numFramesToRender) - 1f;
- }
- }
- public void addMorph(GameObject obj, MethodInfo methodInfo, Component component, List<float> morph)
- {
- foreach (AMTake.Morph morph2 in this.morphs)
- {
- if (morph2.obj == obj && morph2.component == component)
- {
- morph2.blendMorph(morph);
- return;
- }
- }
- AMTake.Morph item = new AMTake.Morph(obj, methodInfo, component, morph);
- this.morphs.Add(item);
- }
- public void previewFrame(float _frame, bool orientationOnly = false, bool renderStill = true, bool skipCameraSwitcher = false, bool quickPreview = false)
- {
- if (!skipCameraSwitcher && renderStill)
- {
- this.renderCameraSwitcherStill(_frame);
- }
- List<AMOrientationTrack> list = new List<AMOrientationTrack>();
- List<AMRotationTrack> list2 = new List<AMRotationTrack>();
- this.morphs = new List<AMTake.Morph>();
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (!skipCameraSwitcher || !(amtrack is AMCameraSwitcherTrack))
- {
- if (!(amtrack is AMAudioTrack))
- {
- if (amtrack is AMOrientationTrack)
- {
- list.Add(amtrack as AMOrientationTrack);
- }
- else if (!orientationOnly)
- {
- if (amtrack is AMRotationTrack)
- {
- list2.Add(amtrack as AMRotationTrack);
- }
- if (amtrack is AMAnimationTrack)
- {
- (amtrack as AMAnimationTrack).previewFrame(_frame, (float)this.frameRate);
- }
- else if (amtrack is AMPropertyTrack)
- {
- (amtrack as AMPropertyTrack).previewFrame(_frame, quickPreview);
- }
- else
- {
- amtrack.previewFrame(_frame, null);
- }
- }
- }
- }
- }
- foreach (AMOrientationTrack amorientationTrack in list)
- {
- amorientationTrack.cachedTranslationTrackStartTarget = this.getTranslationTrackForTransform(amorientationTrack.getStartTargetForFrame(_frame));
- amorientationTrack.cachedTranslationTrackEndTarget = this.getTranslationTrackForTransform(amorientationTrack.getEndTargetForFrame(_frame));
- amorientationTrack.previewFrame(_frame, null);
- }
- if (list.Count > 0)
- {
- foreach (AMRotationTrack amrotationTrack in list2)
- {
- amrotationTrack.previewFrame(_frame, null);
- }
- }
- foreach (AMTake.Morph m in this.morphs)
- {
- this.previewMorph(m);
- }
- }
- public void previewMorph(AMTake.Morph m)
- {
- for (int i = 0; i < m.morph.Count; i++)
- {
- if (i >= m.morph.Count)
- {
- break;
- }
- m.methodInfo.Invoke(m.component, new object[]
- {
- i,
- m.morph[i]
- });
- }
- if (!Application.isPlaying)
- {
- m.obj.transform.position = new Vector3(m.obj.transform.position.x, m.obj.transform.position.y, m.obj.transform.position.z);
- }
- }
- private void renderCameraSwitcherStill(float _frame)
- {
- if (!this.cameraSwitcher)
- {
- return;
- }
- AMCameraSwitcherTrack.cfTuple cameraFadeTupleForFrame = this.cameraSwitcher.getCameraFadeTupleForFrame((int)_frame);
- if (cameraFadeTupleForFrame.frame != 0)
- {
- AMCameraFade cameraFade = AMCameraFade.getCameraFade(true);
- cameraFade.isReset = false;
- bool flag = AMTake.isProLicense;
- if (!cameraFade.tex2d || cameraFade.shouldUpdateStill || (flag && cameraFade.cachedStillFrame != cameraFadeTupleForFrame.frame))
- {
- if (flag)
- {
- int num = (!cameraFadeTupleForFrame.isReversed) ? cameraFadeTupleForFrame.type1 : cameraFadeTupleForFrame.type2;
- int num2 = (!cameraFadeTupleForFrame.isReversed) ? cameraFadeTupleForFrame.type2 : cameraFadeTupleForFrame.type1;
- if (num == 0)
- {
- if (cameraFade.tex2d)
- {
- UnityEngine.Object.DestroyImmediate(cameraFade.tex2d);
- }
- this.previewFrame((float)cameraFadeTupleForFrame.frame, false, false, false, false);
- Camera camera = (!cameraFadeTupleForFrame.isReversed) ? cameraFadeTupleForFrame.camera1 : cameraFadeTupleForFrame.camera2;
- AMTween.SetTopCamera(camera, this.cameraSwitcher.getAllCameras());
- if (cameraFade.width <= 0 || cameraFade.height <= 0)
- {
- if (Application.isPlaying)
- {
- cameraFade.width = Screen.width;
- cameraFade.height = Screen.height;
- }
- else
- {
- cameraFade.width = 200;
- cameraFade.height = 100;
- cameraFade.shouldUpdateStill = true;
- }
- }
- else
- {
- cameraFade.shouldUpdateStill = false;
- }
- RenderTexture temporary = RenderTexture.GetTemporary(cameraFade.width, cameraFade.height, 24);
- camera.targetTexture = temporary;
- camera.Render();
- Texture2D texture2D = new Texture2D(temporary.width, temporary.height, TextureFormat.RGB24, false);
- RenderTexture.active = temporary;
- texture2D.ReadPixels(new Rect(0f, 0f, (float)temporary.width, (float)temporary.height), 0, 0);
- texture2D.Apply();
- cameraFade.tex2d = texture2D;
- cameraFade.cachedStillFrame = cameraFadeTupleForFrame.frame;
- RenderTexture.active = null;
- RenderTexture.ReleaseTemporary(temporary);
- camera.targetTexture = null;
- if (cameraFade.placeholder)
- {
- cameraFade.placeholder = false;
- }
- if (num2 == 0)
- {
- Camera top = (!cameraFadeTupleForFrame.isReversed) ? cameraFadeTupleForFrame.camera2 : cameraFadeTupleForFrame.camera1;
- AMTween.SetTopCamera(top, this.cameraSwitcher.getAllCameras());
- }
- }
- }
- else
- {
- cameraFade.tex2d = (Texture2D)Resources.Load("am_indie_placeholder");
- if (!cameraFade.placeholder)
- {
- cameraFade.placeholder = true;
- }
- }
- }
- cameraFade.useRenderTexture = false;
- }
- }
- public void sampleAudioAtFrame(int frame, float speed)
- {
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (amtrack is AMAudioTrack)
- {
- (amtrack as AMAudioTrack).sampleAudioAtFrame(frame, speed, this.frameRate);
- }
- }
- }
- public AMTranslationTrack getTranslationTrackForTransform(Transform obj)
- {
- if (!obj)
- {
- return null;
- }
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (amtrack is AMTranslationTrack && (amtrack as AMTranslationTrack).obj == obj)
- {
- return amtrack as AMTranslationTrack;
- }
- }
- return null;
- }
- public void deleteKeysAfter(int frame)
- {
- foreach (AMTrack amtrack in this.trackValues)
- {
- bool flag = false;
- for (int i = 0; i < amtrack.keys.Count; i++)
- {
- if (amtrack.keys[i].frame > frame)
- {
- amtrack.keys[i].destroy();
- amtrack.keys.RemoveAt(i);
- flag = true;
- i--;
- }
- if (flag)
- {
- amtrack.updateCache();
- }
- }
- }
- }
- public void deleteKeysBefore(int frame)
- {
- foreach (AMTrack amtrack in this.trackValues)
- {
- bool flag = false;
- for (int i = 0; i < amtrack.keys.Count; i++)
- {
- if (amtrack.keys[i].frame < frame)
- {
- amtrack.keys[i].destroy();
- amtrack.keys.RemoveAt(i);
- flag = true;
- i--;
- }
- if (flag)
- {
- amtrack.updateCache();
- }
- }
- }
- }
- public void shiftOutOfBoundsKeysOnSelectedTrack()
- {
- int num = this.getSelectedTrack().shiftOutOfBoundsKeys();
- if (this.contextSelection.Count <= 0)
- {
- return;
- }
- for (int i = 0; i < this.contextSelection.Count; i++)
- {
- List<int> list;
- int index;
- (list = this.contextSelection)[index = i] = list[index] + num;
- }
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (amtrack.id != this.selectedTrack)
- {
- amtrack.offsetKeysFromBy(1, num);
- }
- }
- }
- public void shiftOutOfBoundsKeysOnTrack(AMTrack _track)
- {
- int num = _track.shiftOutOfBoundsKeys();
- if (this.contextSelection.Count <= 0)
- {
- return;
- }
- for (int i = 0; i < this.contextSelection.Count; i++)
- {
- List<int> list;
- int index;
- (list = this.contextSelection)[index = i] = list[index] + num;
- }
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (amtrack.id != _track.id)
- {
- amtrack.offsetKeysFromBy(0, num);
- }
- }
- }
- public void deleteSelectedKeysFromTrack(int track_id)
- {
- bool flag = false;
- AMTrack track = this.getTrack(track_id);
- for (int i = 0; i < track.keys.Count; i++)
- {
- if (this.isFrameInContextSelection(track.keys[i].frame))
- {
- track.keys[i].destroy();
- track.keys.Remove(track.keys[i]);
- i--;
- flag = true;
- }
- }
- if (flag)
- {
- track.updateCache();
- }
- }
- public bool hasKeyAfter(int frame)
- {
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (amtrack.keys.Count > 0 && amtrack.keys[amtrack.keys.Count - 1].frame > frame)
- {
- return true;
- }
- }
- return false;
- }
- public bool autoKey(Transform obj, int frame)
- {
- if (!obj)
- {
- return false;
- }
- bool flag = false;
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (amtrack is AMTranslationTrack)
- {
- if ((amtrack as AMTranslationTrack).autoKey(obj, frame) && !flag)
- {
- flag = true;
- }
- }
- else if (amtrack is AMRotationTrack && (amtrack as AMRotationTrack).autoKey(obj, frame) && !flag)
- {
- flag = true;
- }
- }
- return flag;
- }
- public bool isFrameInContextSelection(int frame)
- {
- for (int i = 0; i < this.contextSelection.Count; i += 2)
- {
- if (frame >= this.contextSelection[i] && frame <= this.contextSelection[i + 1])
- {
- return true;
- }
- }
- return false;
- }
- public bool isFrameInGhostSelection(int frame)
- {
- if (this.ghostSelection == null)
- {
- return false;
- }
- for (int i = 0; i < this.ghostSelection.Count; i += 2)
- {
- if (frame >= this.ghostSelection[i] && frame <= this.ghostSelection[i + 1])
- {
- return true;
- }
- }
- return false;
- }
- public bool isFrameSelected(int frame)
- {
- if (this.hasGhostSelection())
- {
- return this.isFrameInGhostSelection(frame);
- }
- return this.isFrameInContextSelection(frame);
- }
- public void contextSelectFrame(int frame, bool toggle)
- {
- for (int i = 0; i < this.contextSelection.Count; i += 2)
- {
- if (frame >= this.contextSelection[i] && frame <= this.contextSelection[i + 1])
- {
- if (toggle)
- {
- if (frame == this.contextSelection[i] && frame == this.contextSelection[i + 1])
- {
- this.contextSelection.RemoveAt(i);
- this.contextSelection.RemoveAt(i);
- }
- else if (frame == this.contextSelection[i])
- {
- List<int> list;
- int index;
- (list = this.contextSelection)[index = i] = list[index] + 1;
- }
- else if (frame == this.contextSelection[i + 1])
- {
- List<int> list;
- int index2;
- (list = this.contextSelection)[index2 = i + 1] = list[index2] + 1;
- }
- else
- {
- int item = this.contextSelection[i];
- int item2 = this.contextSelection[i + 1];
- this.contextSelection.RemoveAt(i);
- this.contextSelection.RemoveAt(i);
- this.contextSelection.Add(item);
- this.contextSelection.Add(frame - 1);
- this.contextSelection.Add(frame + 1);
- this.contextSelection.Add(item2);
- this.contextSelection.Sort();
- }
- }
- return;
- }
- }
- this.contextSelection.Add(frame);
- this.contextSelection.Add(frame);
- this.contextSelection.Sort();
- }
- public void contextSelectFrameRange(int startFrame, int endFrame)
- {
- if (startFrame == endFrame)
- {
- this.contextSelectFrame(endFrame, false);
- return;
- }
- int num = endFrame;
- if (endFrame < startFrame)
- {
- endFrame = startFrame;
- startFrame = num;
- }
- for (int i = 0; i < this.contextSelection.Count; i += 2)
- {
- if (startFrame <= this.contextSelection[i] && endFrame >= this.contextSelection[i + 1])
- {
- this.contextSelection.RemoveAt(i);
- this.contextSelection.RemoveAt(i);
- i -= 2;
- }
- else if (this.contextSelection[i] <= startFrame && this.contextSelection[i + 1] >= endFrame)
- {
- return;
- }
- }
- this.contextSelection.Add(startFrame);
- this.contextSelection.Add(endFrame);
- this.contextSelection.Sort();
- }
- public void contextSelectAllFrames()
- {
- this.contextSelection = new List<int>();
- this.contextSelection.Add(1);
- this.contextSelection.Add(this.numFrames);
- }
- public bool contextSelectionHasKeys()
- {
- foreach (AMKey amkey in this.getSelectedTrack().keys)
- {
- for (int i = 0; i < this.contextSelection.Count; i += 2)
- {
- if (this.contextSelection[i] > amkey.frame)
- {
- break;
- }
- if (this.contextSelection[i] <= amkey.frame && this.contextSelection[i + 1] >= amkey.frame)
- {
- return true;
- }
- }
- }
- return false;
- }
- public AMKey[] getContextSelectionKeysForTrack(AMTrack track)
- {
- List<AMKey> list = new List<AMKey>();
- foreach (AMKey amkey in track.keys)
- {
- for (int i = 0; i < this.contextSelection.Count; i += 2)
- {
- if (this.contextSelection[i] > amkey.frame)
- {
- break;
- }
- if (this.contextSelection[i] <= amkey.frame && this.contextSelection[i + 1] >= amkey.frame)
- {
- list.Add(amkey);
- }
- }
- }
- return list.ToArray();
- }
- public void offsetContextSelectionFramesBy(int offset)
- {
- if (offset == 0)
- {
- return;
- }
- if (this.contextSelection.Count <= 0)
- {
- return;
- }
- foreach (int id in this.contextSelectionTracks)
- {
- bool flag = false;
- List<AMKey> list = new List<AMKey>();
- AMTrack track = this.getTrack(id);
- foreach (AMKey amkey in track.keys)
- {
- for (int i = 0; i < this.contextSelection.Count; i += 2)
- {
- if (this.contextSelection[i] <= amkey.frame && this.contextSelection[i + 1] >= amkey.frame)
- {
- bool flag2 = false;
- if (track.hasKeyOnFrame(amkey.frame + offset))
- {
- for (int j = 0; j < this.contextSelection.Count; j += 2)
- {
- if (this.contextSelection[j] <= amkey.frame + offset && this.contextSelection[j + 1] >= amkey.frame + offset)
- {
- flag2 = true;
- break;
- }
- }
- if (!flag2)
- {
- list.Add(track.getKeyOnFrame(amkey.frame + offset));
- }
- }
- amkey.frame += offset;
- if (!flag)
- {
- flag = true;
- }
- break;
- }
- }
- }
- foreach (AMKey amkey2 in list)
- {
- track.keys.Remove(amkey2);
- amkey2.destroy();
- }
- list = new List<AMKey>();
- if (flag)
- {
- track.updateCache();
- }
- }
- for (int k = 0; k < this.contextSelection.Count; k++)
- {
- List<int> list2;
- int index;
- (list2 = this.contextSelection)[index = k] = list2[index] + offset;
- }
- this.ghostSelection = new List<int>();
- }
- public void offsetGhostSelectionBy(int offset)
- {
- for (int i = 0; i < this.ghostSelection.Count; i++)
- {
- List<int> list;
- int index;
- (list = this.ghostSelection)[index = i] = list[index] + offset;
- }
- this.ghost_selection_total_offset += offset;
- }
- public void setGhostSelection()
- {
- this.ghostSelection = new List<int>();
- this.ghost_selection_total_offset = 0;
- foreach (int item in this.contextSelection)
- {
- this.ghostSelection.Add(item);
- }
- }
- public bool hasGhostSelection()
- {
- return this.ghostSelection == null || this.ghostSelection.Count > 0;
- }
- public int[] getKeyFramesInGhostSelection(int startFrame, int endFrame, int track_id)
- {
- List<int> list = new List<int>();
- if (track_id <= -1)
- {
- return list.ToArray();
- }
- foreach (AMKey amkey in this.getTrack(track_id).keys)
- {
- if (amkey.frame + this.ghost_selection_total_offset >= startFrame)
- {
- if (amkey.frame + this.ghost_selection_total_offset > endFrame)
- {
- break;
- }
- if (this.isFrameInContextSelection(amkey.frame))
- {
- list.Add(amkey.frame + this.ghost_selection_total_offset);
- }
- }
- }
- return list.ToArray();
- }
- public void maintainTake()
- {
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (!amtrack.parentTake)
- {
- amtrack.parentTake = this;
- }
- }
- }
- public void sampleAudio(float frame, float speed)
- {
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (amtrack is AMAudioTrack)
- {
- (amtrack as AMAudioTrack).sampleAudio(frame, speed, this.frameRate);
- }
- }
- }
- public void stopAudio()
- {
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (amtrack is AMAudioTrack)
- {
- (amtrack as AMAudioTrack).stopAudio();
- }
- }
- }
- public void stopAnimations()
- {
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (amtrack is AMAnimationTrack)
- {
- if ((amtrack as AMAnimationTrack).obj)
- {
- (amtrack as AMAnimationTrack).obj.GetComponent<Animation>().Stop();
- }
- }
- }
- }
- public void resetScene()
- {
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (!(amtrack is AMAnimationTrack))
- {
- if (amtrack is AMOrientationTrack)
- {
- amtrack.previewFrame(1f, this.getTranslationTrackForTransform((amtrack as AMOrientationTrack).getTargetForFrame(1f)));
- }
- else
- {
- amtrack.previewFrame(1f, null);
- }
- }
- }
- }
- public void drawGizmos(float gizmo_size, bool inPlayMode)
- {
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (amtrack is AMTranslationTrack)
- {
- amtrack.drawGizmos(gizmo_size);
- }
- else if (amtrack is AMOrientationTrack)
- {
- (amtrack as AMOrientationTrack).drawGizmos(gizmo_size, inPlayMode, this.selectedFrame);
- }
- }
- }
- public void maintainCaches()
- {
- foreach (AMTrack amtrack in this.trackValues)
- {
- bool flag = false;
- foreach (AMAction x in amtrack.cache)
- {
- if (x == null)
- {
- flag = true;
- break;
- }
- }
- if (flag)
- {
- amtrack.updateCache();
- }
- }
- }
- public void previewFrameInvoker(float frame)
- {
- this.previewFrame(frame, false, true, false, false);
- }
- public void executeActions(float fromFrame = 0f)
- {
- float num = fromFrame / (float)this.frameRate;
- this.maintainCaches();
- this.previewFrame(fromFrame, false, false, false, true);
- foreach (AMTrack amtrack in this.trackValues)
- {
- foreach (AMAction amaction in amtrack.cache)
- {
- if (amaction is AMAudioAction)
- {
- if (!(amaction as AMAudioAction).loop && amaction.startFrame + (amaction as AMAudioAction).getNumberOfFrames(this.frameRate) - 1 < (int)fromFrame)
- {
- continue;
- }
- }
- else if (amaction.startFrame + amaction.getNumberOfFrames() - 1 < (int)fromFrame)
- {
- continue;
- }
- if (amaction is AMCameraSwitcherAction)
- {
- (amaction as AMCameraSwitcherAction).execute(this.frameRate, num, (amtrack as AMCameraSwitcherTrack).cachedAllCameras);
- }
- else
- {
- amaction.execute(this.frameRate, num, amtrack.name);
- }
- }
- }
- }
- public void executeActions(List<int> exclusion_track_id_list, float fromFrame = 0f)
- {
- HashSet<int> hashSet = new HashSet<int>();
- for (int i = 0; i < exclusion_track_id_list.Count; i++)
- {
- if (!hashSet.Contains(exclusion_track_id_list[i]))
- {
- hashSet.Add(exclusion_track_id_list[i]);
- }
- }
- float num = fromFrame / (float)this.frameRate;
- this.maintainCaches();
- this.previewFrame(fromFrame, false, false, false, true);
- int num2 = 0;
- int num3 = 0;
- foreach (AMTrack amtrack in this.trackValues)
- {
- if (!hashSet.Contains(amtrack.id))
- {
- foreach (AMAction amaction in amtrack.cache)
- {
- if (amaction is AMAudioAction)
- {
- if (!(amaction as AMAudioAction).loop && amaction.startFrame + (amaction as AMAudioAction).getNumberOfFrames(this.frameRate) - 1 < (int)fromFrame)
- {
- continue;
- }
- }
- else if (amaction.startFrame + amaction.getNumberOfFrames() - 1 < (int)fromFrame)
- {
- continue;
- }
- if (amaction is AMCameraSwitcherAction)
- {
- num2++;
- (amaction as AMCameraSwitcherAction).execute(this.frameRate, num, (amtrack as AMCameraSwitcherTrack).cachedAllCameras);
- }
- else
- {
- num2++;
- amaction.execute(this.frameRate, num, amtrack.name);
- }
- }
- }
- }
- Debug.Log("dance object data");
- Debug.Log("create : " + num2);
- Debug.Log("skip : " + num3);
- }
- public void setupCameraSwitcher(float fromFrame = 0f)
- {
- if (!this.cameraSwitcher || this.cameraSwitcher.keys.Count <= 0)
- {
- return;
- }
- this.cameraSwitcher.cachedAllCameras = this.cameraSwitcher.getAllCameras();
- AMCameraSwitcherKey amcameraSwitcherKey = this.cameraSwitcher.keys[0] as AMCameraSwitcherKey;
- if (amcameraSwitcherKey.type == 0)
- {
- if (amcameraSwitcherKey.camera)
- {
- AMTween.SetTopCamera(amcameraSwitcherKey.camera, this.cameraSwitcher.cachedAllCameras);
- }
- }
- else if (amcameraSwitcherKey.type == 1)
- {
- AMTween.ShowColor(amcameraSwitcherKey.color);
- }
- }
- public float getElementsHeight(int group_id, float height_track, float height_track_foldin, float height_group)
- {
- this.initGroups();
- float num = 0f;
- AMGroup group = this.getGroup(group_id);
- if (group_id < 0)
- {
- num += height_group;
- if (group.elements.Count <= 0 && group.foldout)
- {
- num += height_group;
- }
- }
- if (group_id == 0 || group.foldout)
- {
- foreach (int num2 in group.elements)
- {
- if (num2 < 0)
- {
- num += this.getElementsHeight(num2, height_track, height_track_foldin, height_group);
- }
- else if (this.getTrack(num2).foldout)
- {
- num += height_track;
- }
- else
- {
- num += height_track_foldin;
- }
- }
- }
- return num;
- }
- public float getElementsHeight(int element_id, int group_id, float height_track, float height_track_foldin, float height_group, ref bool found)
- {
- this.initGroups();
- float num = 0f;
- AMGroup group = this.getGroup(group_id);
- if (group_id < 0)
- {
- if (group_id == element_id)
- {
- found = true;
- return num;
- }
- num += height_group;
- if (group.elements.Count <= 0 && group.foldout)
- {
- num += height_group;
- }
- }
- if (group_id == 0 || group.foldout)
- {
- foreach (int num2 in group.elements)
- {
- if (num2 == element_id)
- {
- found = true;
- return num;
- }
- if (num2 < 0)
- {
- num += this.getElementsHeight(element_id, num2, height_track, height_track_foldin, height_group, ref found);
- if (found)
- {
- return num;
- }
- }
- else if (this.getTrack(num2).foldout)
- {
- num += height_track;
- }
- else
- {
- num += height_track_foldin;
- }
- }
- return num;
- }
- return num;
- }
- public float getElementY(int element_id, float height_track, float height_track_foldin, float height_group)
- {
- bool flag = false;
- return this.getElementsHeight(element_id, 0, height_track, height_track_foldin, height_group, ref flag);
- }
- public void destroy()
- {
- foreach (AMTrack amtrack in this.trackValues)
- {
- amtrack.destroy();
- }
- this.rootGroup.destroy();
- foreach (AMGroup amgroup in this.groupValues)
- {
- amgroup.destroy();
- }
- UnityEngine.Object.DestroyImmediate(this);
- }
- public List<GameObject> getDependencies()
- {
- List<GameObject> list = new List<GameObject>();
- foreach (AMTrack amtrack in this.trackValues)
- {
- list = list.Union(amtrack.getDependencies()).ToList<GameObject>();
- }
- return list;
- }
- public List<GameObject> updateDependencies(List<GameObject> newReferences, List<GameObject> oldReferences)
- {
- List<GameObject> list = new List<GameObject>();
- foreach (AMTrack amtrack in this.trackValues)
- {
- list = list.Union(amtrack.updateDependencies(newReferences, oldReferences)).ToList<GameObject>();
- amtrack.updateCache();
- }
- return list;
- }
- public new string name;
- public int frameRate = 24;
- public int numFrames = 1440;
- public float startFrame = 1f;
- public float endFrame = 100f;
- public int playbackSpeedIndex = 2;
- public int selectedTrack = -1;
- public int selectedFrame = 1;
- public int selectedGroup;
- public List<int> trackKeys = new List<int>();
- public List<AMTrack> trackValues = new List<AMTrack>();
- public List<int> contextSelection = new List<int>();
- public List<int> ghostSelection = new List<int>();
- public List<int> contextSelectionTracks = new List<int>();
- public int track_count = 1;
- public int group_count;
- public AMGroup rootGroup;
- public List<int> groupKeys = new List<int>();
- public List<AMGroup> groupValues = new List<AMGroup>();
- public static bool isProLicense = true;
- public AMCameraSwitcherTrack cameraSwitcher;
- private List<AMTake.Morph> morphs;
- private int ghost_selection_total_offset;
- public class Morph
- {
- public Morph(GameObject obj, MethodInfo methodInfo, Component component, List<float> morph)
- {
- this.obj = obj;
- this.methodInfo = methodInfo;
- this.component = component;
- this.morph = new List<float>(morph);
- }
- public void blendMorph(List<float> new_morph)
- {
- for (int i = 0; i < ((this.morph.Count < new_morph.Count) ? new_morph.Count : this.morph.Count); i++)
- {
- if (i >= new_morph.Count)
- {
- break;
- }
- if (i >= this.morph.Count)
- {
- this.morph.Add(0f);
- }
- if (this.morph[i] == 0f)
- {
- this.morph[i] = new_morph[i];
- }
- }
- }
- public GameObject obj;
- public MethodInfo methodInfo;
- public Component component;
- public List<float> morph;
- }
- }
|