// ~5. public void TriggerEvent(T eventType, params object[] optParams) { List <Action <T, object[]> > list; m_events.TryGetValue(eventType, out list); // Debug.Log(optParams.Aggregate("TriggerEvent(<color=cyan>" + eventType + ":: ", (c, n) => c + "\"" + n + "\", ") + "</color>) " + (list != null ? list.Count.ToString() : "null")); if (list != null) { if (list.Count == 0) { return; } // Make a copy of this list, as it may get modified by the action. var copy = m_listenerPool.Unpool(); copy.AddRange(list); foreach (var action in copy) { action(eventType, optParams); } copy.Clear(); m_listenerPool.Pool(copy); } }
// ~115. public void TriggerEvent(T eventType, object param1) { var arr = m_reusableParams1Pool.Unpool(); arr[0] = param1; TriggerEvent(eventType, arr); arr[0] = null; m_reusableParams1Pool.Pool(arr); }
// ~10. public void TriggerEvent(T eventType, object param1, object param2, object param3) { var arr = m_reusableParams3Pool.Unpool(); arr[0] = param1; arr[1] = param2; arr[2] = param3; TriggerEvent(eventType, arr); arr[0] = null; arr[1] = null; arr[2] = null; m_reusableParams3Pool.Pool(arr); }