public BaseComponent Instance(ComponentActor actor) { var t = new T(); t.Init(actor); return(t); }
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);
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); }
public T NewComponent <T>(ComponentActor actor) where T : BaseComponent, new() { return((T)NewComponent(actor, typeof(T))); }
public virtual void Init(ComponentActor actor) { Actor = actor; }
public ComponentDriver(ComponentActor actor) { owner = actor; }
public EventDispatcher(ComponentActor actor) { this.ownerActor = actor; eventHandlers = new Dictionary <int, List <string> >(); }