예제 #1
0
        public static void LoadEvent(List <Type> types)
        {
            allEvents.Clear();
            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(AnnotationEventAttribute), false);

                if (attrs.Length == 0)
                {
                    continue;
                }

                object obj = Activator.CreateInstance(type);

                Log.Info("HotfixEvent type" + type.FullName);

                IEventMethod iEvent = Activator.CreateInstance(type) as IEventMethod;
                if (iEvent == null)
                {
                    throw new Exception($"type not is AEvent: {iEvent.GetType().Name}");
                }

                RegisterEvent(iEvent.GetEventType(), iEvent);

                // hotfix的事件也要注册到mono层,hotfix可以订阅mono层的事件
                Action <List <object> > action = list => { Handle(iEvent, list); };

                if (EventComponent.This != null)
                {
                    Log.Info(iEvent.GetEventType());

                    EventComponent.This.RegisterEvent(iEvent.GetEventType(), new EventProxy(action));
                }
            }
        }
예제 #2
0
        public static void UploadEvent(HashSet <Type> types)
        {
            allEvents.Clear();
            foreach (Type type in types)
            {
                //Log.Info("RunEvent type" + type.FullName);

                IEventMethod iEvent = Activator.CreateInstance(type) as IEventMethod;
                if (iEvent == null)
                {
                    throw new Exception($"type not is AEvent: {iEvent.GetType().Name}");
                }

                RegisterEvent(iEvent.GetEventType(), iEvent);
            }
        }