/// <summary> /// 注册事件 /// </summary> /// <param name="recv"></param> /// <typeparam name="T"></typeparam> /// <returns></returns> public Handler RegEventHandler <T>(OnEventRecv <T> recv) where T : Event { HandlerGroup g; if (!event_handlers.TryGetValue(typeof(T), out g)) { g = new HandlerGroup(typeof(T)); event_handlers.Add(typeof(T), g); } return(g.Create <T>(recv)); }
public Handler Create <T>(OnEventRecv <T> recv) where T : Event { if (!index_pool.CanAlloc()) { index_pool.Grow(5); Array.Resize(ref handlers, handlers.Length + 5); } int idx = index_pool.Alloc(); RealHandler <T> h = new RealHandler <T>(idx, recv); handlers[idx] = h; return(h); }
public RealHandler(int key, OnEventRecv <T> recv) { this.key = key; this.recv = recv; }