public void ExecuteEvent(string eventId, object data) { if (!m_UseDataEventCallers.ContainsKey(eventId) && !m_NotDataEventCallers.ContainsKey(eventId)) { #if UNITY_EDITOR || DEBUG AiukDebugUtility.LogWarning(string.Format("没有发现目标事件{0}", eventId)); #endif return; } if (m_UseDataEventCallers.ContainsKey(eventId)) { var caller = m_UseDataEventCallers[eventId]; caller.CallEventHanlder(data); TryCleanZero(); } if (m_NotDataEventCallers.ContainsKey(eventId)) { var caller = m_NotDataEventCallers[eventId]; caller.CallEventHanlder(); TryCleanZero(); } }
public void ExecuteEvent() { if (m_TaskQueue.Count == 0) { return; } var taskCount = m_TaskQueue.Count; for (int i = 0; i < taskCount; i++) { var task = m_TaskQueue.Dequeue(); if (!m_EventHandleUnits.ContainsKey(task.EventCode.EventModuleType)) { #if UNITY_EDITOR || DEBUG AiukDebugUtility.LogWarning(string.Format("尝试触发一个没有响应处理器的事件," + "事件Id为{0}", task.EventCode.EventName)); #endif continue; } else { var unit = m_EventHandleUnits[task.EventCode.EventModuleType]; unit.ExecuteEvent(task.EventCode.EventName, task.EventData); } if (task.OnCompelted != null) { task.OnCompelted(); } AiukEventFactory.EventTaskPool.Restore(task); } }
/// <summary> /// 移除一个Unity类型的事件处理器。 /// </summary> /// <param name="type">Type.</param> /// <param name="action">Action.</param> public void RemoveUnityEvent(AiukUnityEventType type, Action action) { if (!m_EventCallers.ContainsKey(type)) { #if UNITY_EDITOR || DEBUG AiukDebugUtility.LogWarning( string.Format("尝试移除一个不存在的Unity事件类型,事件类型为{0}", type)); #endif return; } var caller = m_EventCallers[type]; caller.RemoveHandler(action); }
public void RemoveSpecifiedHandler(AiukEventCode eventCode, int handlerId) { if (!m_EventHandleUnits.ContainsKey(eventCode.EventModuleType)) { #if UNITY_EDITOR || DEBUG AiukDebugUtility.LogWarning( string.Format("尝试移除一个当前不存在的事件处理器,事件Id为{0}。", eventCode.EventName)); #endif return; } var unit = m_EventHandleUnits[eventCode.EventModuleType]; unit.RemoveSpecifiedHandler(eventCode.EventName, handlerId); }
public void RemoveHandler(int handlerId) { var handler = m_Handlers.Find(h => h.Id == handlerId); if (handler == null) { #if UNITY_EDITOR || DEBUG AiukDebugUtility.LogWarning( string.Format("尝试移除不存在的事件处理器,事件Id为{0}!", handlerId)); #endif return; } m_Handlers.Remove(handler); }
/// <summary> /// 显式手动创建实例。 /// </summary> /// <returns></returns> public T ExplicitCreate(string typeName) { var index = m_Types.FindIndex(t => t.Name == typeName); if (index == -1) { AiukDebugUtility.LogWarning(string.Format("没有找到所要创建的目标类型{0}!", typeName)); return(null); } m_ExplicitCreatedIndexs.Add(index); var type = m_Types[index]; var instance = Activator.CreateInstance(type) as T; m_Instances.Add(instance); return(instance); }
private void RemoveSpecifiedHandlerAtUseData(string eventName, int handlerId) { if (!m_UseDataEventCallers.ContainsKey(eventName)) { #if UNITY_EDITOR || DEBUG AiukDebugUtility.LogWarning( string.Format("尝试移除不存在的有数据事件处理器,事件名为{0}", eventName)); #endif return; } else { var caller = m_UseDataEventCallers[eventName]; caller.RemoveHandler(handlerId); if (caller.EventHanlderCount == 0) { m_UseDataEventCallers.Remove(eventName); } } }