Esempio n. 1
0
            public BaseComponent Instance(ComponentActor actor)
            {
                var t = new T();

                t.Init(actor);
                return(t);
            }
Esempio n. 2
0
        public BaseComponent NewComponent(ComponentActor actor, Type compType)
        {
            var actorType = actor.GetType();

            if (compMap.ContainsKey(actorType))
            {
                var list = compMap[actorType];
                foreach (var info in list)
                {
                    if (info.CompType == compType)
                    {
                        return(info.Instance(actor));
                    }
                }
            }
            LOGGER.Error($"{actor.GetType()}获取未注册的component:{compType}");
            return(default);
Esempio n. 3
0
        static bool isListenerLegal <TH>(IAgent agent) where TH : ITimerHandler
        {
            ComponentActor actor = default;

            if (agent is IComponentAgent)
            {
                var comp = (BaseComponent)agent.Owner;
                actor = comp.Actor;
            }
            else if (agent is IComponentActorAgent)
            {
                actor = (ComponentActor)agent.Owner;
            }

            var listenerType = typeof(TH);
            var agentType    = listenerType.BaseType.GetGenericArguments()[0];

            if (agentType.GetInterface(typeof(IComponentAgent).FullName) != null)
            {
                //comp
                var compType = agentType.BaseType.GenericTypeArguments[0];
                var legal    = ComponentMgr.Singleton.IsCompRegisted(actor, compType);
                if (!legal)
                {
                    LOGGER.Error($"TimerHandler类型错误,注册Timer的Actor未注册TimerHandler泛型参数类型Component,{actor.GetType()}未注册Comp:{compType}");
                }
                return(legal);
            }
            else if (agentType.GetInterface(typeof(IComponentActorAgent).FullName) != null)
            {
                //actor
                var legal = agentType == agent.GetType();
                if (!legal)
                {
                    LOGGER.Error($"TimerHandler类型错误,注册Timer的Actor与回调类型不一致{agent.GetType()} != {agentType}");
                }
                return(legal);
            }
            LOGGER.Error("TimerHandler类型错误");
            return(false);
        }
Esempio n. 4
0
 public T NewComponent <T>(ComponentActor actor) where T : BaseComponent, new()
 {
     return((T)NewComponent(actor, typeof(T)));
 }
Esempio n. 5
0
 public virtual void Init(ComponentActor actor)
 {
     Actor = actor;
 }
Esempio n. 6
0
 public ComponentDriver(ComponentActor actor)
 {
     owner = actor;
 }
Esempio n. 7
0
 public EventDispatcher(ComponentActor actor)
 {
     this.ownerActor = actor;
     eventHandlers   = new Dictionary <int, List <string> >();
 }