// 注册事件处理函数,同一事件注册两次,则后面的覆盖前面的 protected void RegisterEvent(int eventID, EventHandleFunction handlerFunc) { if (EventHandlerMap.ContainsKey(eventID)) { EventHandlerMap.Remove(eventID); } EventHandlerMap.Add(eventID, handlerFunc); }
public virtual bool OnEvent(Event evt) { EventHandleFunction function = null; if (EventHandlerMap.TryGetValue(evt.EventID, out function) == false) { return(false); } if (function == null) { return(false); } function(evt); return(true); }