using System; using System.Collections.Generic; using System.Linq; using UnityEngine; [Serializable] public class AMEventTrack : AMTrack { public override string getTrackType() { return "Event"; } public override void updateCache() { base.destroyCache(); this.cache = new List(); base.sortKeys(); for (int i = 0; i < this.keys.Count; i++) { AMEventAction ameventAction = ScriptableObject.CreateInstance(); ameventAction.startFrame = this.keys[i].frame; ameventAction.component = (this.keys[i] as AMEventKey).component; ameventAction.methodInfo = (this.keys[i] as AMEventKey).methodInfo; ameventAction.parameters = (this.keys[i] as AMEventKey).parameters; ameventAction.useSendMessage = (this.keys[i] as AMEventKey).useSendMessage; this.cache.Add(ameventAction); } base.updateCache(); } public void setObject(GameObject obj) { this.obj = obj; } public bool isObjectUnique(GameObject obj) { return this.obj != obj; } public void addKey(int _frame) { foreach (AMKey amkey in this.keys) { AMEventKey ameventKey = (AMEventKey)amkey; if (ameventKey.frame == _frame) { return; } } AMEventKey ameventKey2 = ScriptableObject.CreateInstance(); ameventKey2.frame = _frame; ameventKey2.component = null; ameventKey2.methodName = null; ameventKey2.parameters = null; this.keys.Add(ameventKey2); this.updateCache(); } public bool hasSameEventsAs(AMEventTrack _track) { return _track.obj == this.obj; } public override AnimatorTimeline.JSONInit getJSONInit() { return null; } public override List getDependencies() { List list = new List(); if (this.obj) { list.Add(this.obj); } foreach (AMKey amkey in this.keys) { AMEventKey ameventKey = (AMEventKey)amkey; list = list.Union(ameventKey.getDependencies()).ToList(); } return list; } public override List updateDependencies(List newReferences, List oldReferences) { bool flag = false; bool flag2 = false; if (this.obj) { for (int i = 0; i < oldReferences.Count; i++) { if (oldReferences[i] == this.obj) { foreach (AMKey amkey in this.keys) { AMEventKey ameventKey = (AMEventKey)amkey; string name = ameventKey.component.GetType().Name; if (ameventKey.component && newReferences[i].GetComponent(name) == null) { Debug.LogWarning(string.Concat(new string[] { "Animator: Event Track component '", name, "' not found on new reference for GameObject '", this.obj.name, "'. Duplicate not replaced." })); return new List { oldReferences[i] }; } } this.obj = newReferences[i]; flag = true; break; } } } foreach (AMKey amkey2 in this.keys) { AMEventKey ameventKey2 = (AMEventKey)amkey2; if (ameventKey2.updateDependencies(newReferences, oldReferences, flag, this.obj) && !flag2) { flag2 = true; } } if (flag || flag2) { this.updateCache(); } return new List(); } public GameObject obj; }