123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- 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<AMAction>();
- base.sortKeys();
- for (int i = 0; i < this.keys.Count; i++)
- {
- AMEventAction ameventAction = ScriptableObject.CreateInstance<AMEventAction>();
- 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<AMEventKey>();
- 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<GameObject> getDependencies()
- {
- List<GameObject> list = new List<GameObject>();
- if (this.obj)
- {
- list.Add(this.obj);
- }
- foreach (AMKey amkey in this.keys)
- {
- AMEventKey ameventKey = (AMEventKey)amkey;
- list = list.Union(ameventKey.getDependencies()).ToList<GameObject>();
- }
- return list;
- }
- public override List<GameObject> updateDependencies(List<GameObject> newReferences, List<GameObject> 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<GameObject>
- {
- 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<GameObject>();
- }
- public GameObject obj;
- }
|