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(); this.contextSelectionTracks = new List(); } } if (index > -1) { this.selectGroup(this.getTrackGroup(index), false, false, true); } } } else { this.contextSelectionTracks = new List(); } 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 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.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.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.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.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.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.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.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(); if (camera) { this.cameraSwitcher.addKey(this.selectedFrame, camera, null); } return; } AMCameraSwitcherTrack amcameraSwitcherTrack = ScriptableObject.CreateInstance(); 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 getTrackIDsForRange(int start_id, int end_id) { if (start_id == end_id) { return new List(); } int elementLocationIndex = this.getElementLocationIndex(start_id); if (elementLocationIndex == 0) { return new List(); } int elementLocationIndex2 = this.getElementLocationIndex(end_id); if (elementLocationIndex2 == 0) { return new List(); } if (elementLocationIndex > elementLocationIndex2) { int num = start_id; start_id = end_id; end_id = num; } List list = new List(); bool flag = false; bool flag2 = false; return this.getTrackIDsForGroup(0, start_id, end_id, ref flag, ref flag2); } private List getTrackIDsForGroup(int group_id, int start_id, int end_id, ref bool foundStartID, ref bool foundEndID) { List list = new List(); 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 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(); } 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 source = this.trackValues.FindAll((AMTrack a) => a is AMTranslationTrack && (a as AMTranslationTrack).objName == objName); return (from i in source select (AMTranslationTrack)i).ToArray(); } 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 source = this.trackValues.FindAll((AMTrack a) => a is AMRotationTrack && (a as AMRotationTrack).objName == objName); return (from i in source select (AMRotationTrack)i).ToArray(); } 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 source = this.trackValues.FindAll((AMTrack a) => a is AMPropertyTrack && (a as AMPropertyTrack).objName == objName); return (from i in source select (AMPropertyTrack)i).ToArray(); } public AMAudioTrack[] findAudioTrack(string objName) { List source = this.trackValues.FindAll((AMTrack a) => a is AMAudioTrack && (a as AMAudioTrack).asName == objName); return (from i in source select (AMAudioTrack)i).ToArray(); } 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.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.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 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 list = new List(); List list2 = new List(); this.morphs = new List(); 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 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 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 list; int index; (list = this.contextSelection)[index = i] = list[index] + 1; } else if (frame == this.contextSelection[i + 1]) { List 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(); 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 list = new List(); 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 list = new List(); 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(); if (flag) { track.updateCache(); } } for (int k = 0; k < this.contextSelection.Count; k++) { List list2; int index; (list2 = this.contextSelection)[index = k] = list2[index] + offset; } this.ghostSelection = new List(); } public void offsetGhostSelectionBy(int offset) { for (int i = 0; i < this.ghostSelection.Count; i++) { List list; int index; (list = this.ghostSelection)[index = i] = list[index] + offset; } this.ghost_selection_total_offset += offset; } public void setGhostSelection() { this.ghostSelection = new List(); 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 list = new List(); 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().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 exclusion_track_id_list, float fromFrame = 0f) { HashSet hashSet = new HashSet(); 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 getDependencies() { List list = new List(); foreach (AMTrack amtrack in this.trackValues) { list = list.Union(amtrack.getDependencies()).ToList(); } return list; } public List updateDependencies(List newReferences, List oldReferences) { List list = new List(); foreach (AMTrack amtrack in this.trackValues) { list = list.Union(amtrack.updateDependencies(newReferences, oldReferences)).ToList(); 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 trackKeys = new List(); public List trackValues = new List(); public List contextSelection = new List(); public List ghostSelection = new List(); public List contextSelectionTracks = new List(); public int track_count = 1; public int group_count; public AMGroup rootGroup; public List groupKeys = new List(); public List groupValues = new List(); public static bool isProLicense = true; public AMCameraSwitcherTrack cameraSwitcher; private List morphs; private int ghost_selection_total_offset; public class Morph { public Morph(GameObject obj, MethodInfo methodInfo, Component component, List morph) { this.obj = obj; this.methodInfo = methodInfo; this.component = component; this.morph = new List(morph); } public void blendMorph(List 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 morph; } }