private static void CollectEvents(List <MecanimEvent> allEvents, Dictionary <int, Dictionary <int, Dictionary <int, List <MecanimEvent> > > > contextLoadedData, Animator animator, int animatorControllerId, int layer, int nameHash, int tagHash, float normalizedTimeStart, float normalizedTimeEnd, bool onlyCritical = false) { if (contextLoadedData.ContainsKey(animatorControllerId) && contextLoadedData[animatorControllerId].ContainsKey(layer) && contextLoadedData[animatorControllerId][layer].ContainsKey(nameHash)) { List <MecanimEvent> list = contextLoadedData[animatorControllerId][layer][nameHash]; for (int i = 0; i < list.Count; i++) { MecanimEvent mecanimEvent = list[i]; if (mecanimEvent.isEnable) { if (mecanimEvent.normalizedTime >= normalizedTimeStart && mecanimEvent.normalizedTime < normalizedTimeEnd && mecanimEvent.condition.Test(animator)) { if (!onlyCritical || mecanimEvent.critical) { MecanimEvent pooledEvent = MecanimEventManager.GetPooledEvent(); pooledEvent.Copy(mecanimEvent); EventContext context = pooledEvent.GetContext(); context.controllerId = animatorControllerId; context.layer = layer; context.stateHash = nameHash; context.tagHash = tagHash; pooledEvent.SetContext(context); allEvents.Add(pooledEvent); } } } } return; } }
public static void SetEventDataSource(MecanimEventData[] dataSources) { if (dataSources != null) { MecanimEventManager.eventDataSources = dataSources; MecanimEventManager.LoadGlobalData(); } }
public static void SetEventDataSource(MecanimEventData dataSource) { if (dataSource != null) { MecanimEventManager.eventDataSources = new MecanimEventData[1]; MecanimEventManager.eventDataSources[0] = dataSource; MecanimEventManager.LoadGlobalData(); } }
private void refreshDataSources() { if (this.dataSource != null) { MecanimEventManager.SetEventDataSource(this.dataSource); } else { MecanimEventManager.SetEventDataSource(this.dataSources); } }
// Token: 0x06001593 RID: 5523 RVA: 0x00078C0C File Offset: 0x00076E0C private void Update() { foreach (MecanimEvent mecanimEvent in MecanimEventManager.GetEvents(this.animatorController.GetInstanceID(), this.animator)) { if (mecanimEvent.paramType != MecanimEventParamTypes.None) { base.SendMessage(mecanimEvent.functionName, mecanimEvent.parameter, SendMessageOptions.DontRequireReceiver); } else { base.SendMessage(mecanimEvent.functionName, SendMessageOptions.DontRequireReceiver); } } }
private void Update() { if ((this.timePassed += Time.deltaTime) < 0.05f) { return; } this.timePassed -= 0.05f; List <MecanimEvent> events = MecanimEventManager.GetEvents(this.animatorController.GetInstanceID(), this.animator); for (int i = 0; i < events.Count; i++) { MecanimEvent mecanimEvent = events[i]; MecanimEvent.SetCurrentContext(mecanimEvent); MecanimEventEmitTypes mecanimEventEmitTypes = this.emitType; if (mecanimEventEmitTypes != MecanimEventEmitTypes.Upwards) { if (mecanimEventEmitTypes != MecanimEventEmitTypes.Broadcast) { if (mecanimEvent.paramType != MecanimEventParamTypes.None) { base.SendMessage(mecanimEvent.functionName, mecanimEvent.parameter, SendMessageOptions.DontRequireReceiver); } else { base.SendMessage(mecanimEvent.functionName, SendMessageOptions.DontRequireReceiver); } } else if (mecanimEvent.paramType != MecanimEventParamTypes.None) { base.BroadcastMessage(mecanimEvent.functionName, mecanimEvent.parameter, SendMessageOptions.DontRequireReceiver); } else { base.BroadcastMessage(mecanimEvent.functionName, SendMessageOptions.DontRequireReceiver); } } else if (mecanimEvent.paramType != MecanimEventParamTypes.None) { base.SendMessageUpwards(mecanimEvent.functionName, mecanimEvent.parameter, SendMessageOptions.DontRequireReceiver); } else { base.SendMessageUpwards(mecanimEvent.functionName, SendMessageOptions.DontRequireReceiver); } MecanimEventManager.PoolEvent(mecanimEvent); } events.Clear(); }
private void Awake() { if (this.dataSource == null && (this.dataSources == null || this.dataSources.Length == 0)) { Debug.Log("Please setup data source of event system."); return; } if (this.dataSource != null) { MecanimEventManager.SetEventDataSource(this.dataSource); } else { MecanimEventManager.SetEventDataSource(this.dataSources); } }
// Token: 0x06001592 RID: 5522 RVA: 0x00078BB0 File Offset: 0x00076DB0 private void Start() { if (this.animator == null) { Debug.LogWarning("Do not find animator component."); base.enabled = false; return; } if (this.animatorController == null) { Debug.LogWarning("Please assgin animator in editor. Add emitter at runtime is not currently supported."); base.enabled = false; return; } MecanimEventManager.SetEventDataSource(this); }
private void Update() { var events = MecanimEventManager.GetEvents(loadedData, lastStates, animatorController.GetInstanceID(), animator); foreach (var e in events) { MecanimEvent.SetCurrentContext(e); switch (emitType) { case MecanimEventEmitTypes.Upwards: if (e.paramType != MecanimEventParamTypes.None) { SendMessageUpwards(e.functionName, e.parameter, SendMessageOptions.DontRequireReceiver); } else { SendMessageUpwards(e.functionName, SendMessageOptions.DontRequireReceiver); } break; case MecanimEventEmitTypes.Broadcast: if (e.paramType != MecanimEventParamTypes.None) { BroadcastMessage(e.functionName, e.parameter, SendMessageOptions.DontRequireReceiver); } else { BroadcastMessage(e.functionName, SendMessageOptions.DontRequireReceiver); } break; default: if (e.paramType != MecanimEventParamTypes.None) { SendMessage(e.functionName, e.parameter, SendMessageOptions.DontRequireReceiver); } else { SendMessage(e.functionName, SendMessageOptions.DontRequireReceiver); } break; } } }
private void Update() { List <MecanimEvent> events = MecanimEventManager.GetEvents(this.loadedData, this.lastStates, this.animatorController.GetInstanceID(), this.animator); for (int i = 0; i < events.Count; i++) { MecanimEvent mecanimEvent = events[i]; MecanimEvent.SetCurrentContext(mecanimEvent); MecanimEventEmitTypes mecanimEventEmitTypes = this.emitType; if (mecanimEventEmitTypes != MecanimEventEmitTypes.Upwards) { if (mecanimEventEmitTypes != MecanimEventEmitTypes.Broadcast) { if (mecanimEvent.paramType != MecanimEventParamTypes.None) { base.SendMessage(mecanimEvent.functionName, mecanimEvent.parameter, SendMessageOptions.DontRequireReceiver); } else { base.SendMessage(mecanimEvent.functionName, SendMessageOptions.DontRequireReceiver); } } else if (mecanimEvent.paramType != MecanimEventParamTypes.None) { base.BroadcastMessage(mecanimEvent.functionName, mecanimEvent.parameter, SendMessageOptions.DontRequireReceiver); } else { base.BroadcastMessage(mecanimEvent.functionName, SendMessageOptions.DontRequireReceiver); } } else if (mecanimEvent.paramType != MecanimEventParamTypes.None) { base.SendMessageUpwards(mecanimEvent.functionName, mecanimEvent.parameter, SendMessageOptions.DontRequireReceiver); } else { base.SendMessageUpwards(mecanimEvent.functionName, SendMessageOptions.DontRequireReceiver); } } }
private void Start() { if (this.animator == null) { Debug.LogWarning(string.Format("GameObject:{0} cannot find animator component.", base.transform.name)); base.enabled = false; return; } if (this.animatorController == null) { Debug.LogWarning("Please assgin animator in editor. Add emitter at runtime is not currently supported."); base.enabled = false; return; } if (this.data == null) { base.enabled = false; return; } this.loadedData = MecanimEventManager.LoadData(this.data); }
// Token: 0x06001598 RID: 5528 RVA: 0x00078D84 File Offset: 0x00076F84 private void Update() { ICollection <MecanimEvent> events = MecanimEventManager.GetEvents(this.animatorController.GetInstanceID(), this.animator); foreach (MecanimEvent mecanimEvent in events) { MecanimEvent.SetCurrentContext(mecanimEvent); MecanimEventEmitTypes mecanimEventEmitTypes = this.emitType; if (mecanimEventEmitTypes != MecanimEventEmitTypes.Upwards) { if (mecanimEventEmitTypes != MecanimEventEmitTypes.Broadcast) { if (mecanimEvent.paramType != MecanimEventParamTypes.None) { base.SendMessage(mecanimEvent.functionName, mecanimEvent.parameter, SendMessageOptions.DontRequireReceiver); } else { base.SendMessage(mecanimEvent.functionName, SendMessageOptions.DontRequireReceiver); } } else if (mecanimEvent.paramType != MecanimEventParamTypes.None) { base.BroadcastMessage(mecanimEvent.functionName, mecanimEvent.parameter, SendMessageOptions.DontRequireReceiver); } else { base.BroadcastMessage(mecanimEvent.functionName, SendMessageOptions.DontRequireReceiver); } } else if (mecanimEvent.paramType != MecanimEventParamTypes.None) { base.SendMessageUpwards(mecanimEvent.functionName, mecanimEvent.parameter, SendMessageOptions.DontRequireReceiver); } else { base.SendMessageUpwards(mecanimEvent.functionName, SendMessageOptions.DontRequireReceiver); } } }
void Update() { if (mecanimEventHandler == null || animatorController == null) { return; } MecanimEvent[] events = MecanimEventManager.GetEvents(loadedData, lastStates, animatorController.GetInstanceID(), animator); foreach (MecanimEvent e in events) { MecanimEvent.SetCurrentContext(e); var m = ReflectionHelper.GetMethodRecursive(mecanimEventHandler, e.functionName); if (e.paramType == MecanimEventParamTypes.None) { m.FastInvoke(mecanimEventHandler); } else { m.FastInvoke(mecanimEventHandler, e.parameter); } } }
// Token: 0x0600159D RID: 5533 RVA: 0x00078EA8 File Offset: 0x000770A8 public static ICollection <MecanimEvent> GetEvents(int animatorControllerId, Animator animator) { List <MecanimEvent> list = new List <MecanimEvent>(); int hashCode = animator.GetHashCode(); if (!MecanimEventManager.lastStates.ContainsKey(hashCode)) { MecanimEventManager.lastStates[hashCode] = new Dictionary <int, AnimatorStateInfo>(); } int layerCount = animator.layerCount; Dictionary <int, AnimatorStateInfo> dictionary = MecanimEventManager.lastStates[hashCode]; for (int i = 0; i < layerCount; i++) { if (!dictionary.ContainsKey(i)) { dictionary[i] = default(AnimatorStateInfo); } AnimatorStateInfo animatorStateInfo = dictionary[i]; AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(i); int num = (int)animatorStateInfo.normalizedTime; int num2 = (int)currentAnimatorStateInfo.normalizedTime; float normalizedTimeStart = animatorStateInfo.normalizedTime - (float)num; float normalizedTimeEnd = currentAnimatorStateInfo.normalizedTime - (float)num2; if (animatorStateInfo.nameHash == currentAnimatorStateInfo.nameHash) { if (currentAnimatorStateInfo.loop) { if (num == num2) { list.AddRange(MecanimEventManager.CollectEvents(animator, animatorControllerId, i, currentAnimatorStateInfo.nameHash, currentAnimatorStateInfo.tagHash, normalizedTimeStart, normalizedTimeEnd, false)); } else { list.AddRange(MecanimEventManager.CollectEvents(animator, animatorControllerId, i, currentAnimatorStateInfo.nameHash, currentAnimatorStateInfo.tagHash, normalizedTimeStart, 1.00001f, false)); list.AddRange(MecanimEventManager.CollectEvents(animator, animatorControllerId, i, currentAnimatorStateInfo.nameHash, currentAnimatorStateInfo.tagHash, 0f, normalizedTimeEnd, false)); } } else { float num3 = Mathf.Clamp01(animatorStateInfo.normalizedTime); float num4 = Mathf.Clamp01(currentAnimatorStateInfo.normalizedTime); if (num == 0 && num2 == 0) { if (num3 != num4) { list.AddRange(MecanimEventManager.CollectEvents(animator, animatorControllerId, i, currentAnimatorStateInfo.nameHash, currentAnimatorStateInfo.tagHash, num3, num4, false)); } } else if (num == 0 && num2 > 0) { list.AddRange(MecanimEventManager.CollectEvents(animator, animatorControllerId, i, animatorStateInfo.nameHash, animatorStateInfo.tagHash, num3, 1.00001f, false)); } } } else { list.AddRange(MecanimEventManager.CollectEvents(animator, animatorControllerId, i, currentAnimatorStateInfo.nameHash, currentAnimatorStateInfo.tagHash, 0f, normalizedTimeEnd, false)); if (!animatorStateInfo.loop) { list.AddRange(MecanimEventManager.CollectEvents(animator, animatorControllerId, i, animatorStateInfo.nameHash, animatorStateInfo.tagHash, normalizedTimeStart, 1.00001f, true)); } } dictionary[i] = currentAnimatorStateInfo; } return(list); }
public static List <MecanimEvent> GetEvents(int animatorControllerId, Animator animator) { return(MecanimEventManager.GetEvents(MecanimEventManager.globalLoadedData, MecanimEventManager.globalLastStates, animatorControllerId, animator)); }
public static List <MecanimEvent> GetEvents(Dictionary <int, Dictionary <int, Dictionary <int, List <MecanimEvent> > > > contextLoadedData, Dictionary <int, Dictionary <int, AnimatorStateInfo> > contextLastStates, int animatorControllerId, Animator animator) { int hashCode = animator.GetHashCode(); if (!contextLastStates.ContainsKey(hashCode)) { contextLastStates[hashCode] = new Dictionary <int, AnimatorStateInfo>(); } int layerCount = animator.layerCount; Dictionary <int, AnimatorStateInfo> dictionary = contextLastStates[hashCode]; for (int i = 0; i < layerCount; i++) { if (!dictionary.ContainsKey(i)) { dictionary[i] = default(AnimatorStateInfo); } AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(i); int num = (int)dictionary[i].normalizedTime; int num2 = (int)currentAnimatorStateInfo.normalizedTime; float normalizedTimeStart = dictionary[i].normalizedTime - (float)num; float normalizedTimeEnd = currentAnimatorStateInfo.normalizedTime - (float)num2; if (dictionary[i].fullPathHash == currentAnimatorStateInfo.fullPathHash) { if (currentAnimatorStateInfo.loop) { if (num == num2) { MecanimEventManager.CollectEvents(MecanimEventManager.allEvents, contextLoadedData, animator, animatorControllerId, i, currentAnimatorStateInfo.fullPathHash, currentAnimatorStateInfo.tagHash, normalizedTimeStart, normalizedTimeEnd, false); } else { MecanimEventManager.CollectEvents(MecanimEventManager.allEvents, contextLoadedData, animator, animatorControllerId, i, currentAnimatorStateInfo.fullPathHash, currentAnimatorStateInfo.tagHash, normalizedTimeStart, 1.00001f, false); MecanimEventManager.CollectEvents(MecanimEventManager.allEvents, contextLoadedData, animator, animatorControllerId, i, currentAnimatorStateInfo.fullPathHash, currentAnimatorStateInfo.tagHash, 0f, normalizedTimeEnd, false); } } else { float num3 = Mathf.Clamp01(dictionary[i].normalizedTime); float num4 = Mathf.Clamp01(currentAnimatorStateInfo.normalizedTime); if (num == 0 && num2 == 0) { if (num3 != num4) { MecanimEventManager.CollectEvents(MecanimEventManager.allEvents, contextLoadedData, animator, animatorControllerId, i, currentAnimatorStateInfo.fullPathHash, currentAnimatorStateInfo.tagHash, num3, num4, false); } } else if (num == 0 && num2 > 0) { MecanimEventManager.CollectEvents(MecanimEventManager.allEvents, contextLoadedData, animator, animatorControllerId, i, dictionary[i].fullPathHash, dictionary[i].tagHash, num3, 1.00001f, false); } } } else { MecanimEventManager.CollectEvents(MecanimEventManager.allEvents, contextLoadedData, animator, animatorControllerId, i, currentAnimatorStateInfo.fullPathHash, currentAnimatorStateInfo.tagHash, 0f, normalizedTimeEnd, false); if (!dictionary[i].loop) { MecanimEventManager.CollectEvents(MecanimEventManager.allEvents, contextLoadedData, animator, animatorControllerId, i, dictionary[i].fullPathHash, dictionary[i].tagHash, normalizedTimeStart, 1.00001f, true); } } dictionary[i] = currentAnimatorStateInfo; } return(MecanimEventManager.allEvents); }
public void SetData(MecanimEventData data) { this.data = data; loadedData = MecanimEventManager.LoadData(data); }