using System;
using System.Collections.Generic;
using System.Reflection;
using Base;
namespace Model
{
///
/// 事件分发
///
[ComponentEvent(typeof(EventComponent))]
public class EventComponent: Component
{
private Dictionary> allEvents;
private void Awake()
{
this.Load();
}
private void Load()
{
this.allEvents = new Dictionary>();
Assembly[] assemblies = Game.ComponentEventManager.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false);
foreach (object attr in attrs)
{
EventAttribute aEventAttribute = (EventAttribute)attr;
object obj = Activator.CreateInstance(type);
if (!this.allEvents.ContainsKey(aEventAttribute.Type))
{
this.allEvents.Add(aEventAttribute.Type, new List