Exemple #1
0
        private void RegAllSensor()
        {
            List <Type> worldSensorTypes  = LCReflect.GetInterfaceByType <IWorldSensor>();
            List <Type> entitySensorTypes = LCReflect.GetInterfaceByType <IEntitySensor>();

            if (worldSensorTypes == null && entitySensorTypes == null)
            {
                return;
            }

            //世界信息
            foreach (Type type in worldSensorTypes)
            {
                WorldSensorAttribute attr = LCReflect.GetTypeAttr <WorldSensorAttribute>(type);
                if (attr == null)
                {
                    ECSLocate.ECSLog.LogR("有世界信息没有加入特性 >>>>>>", type.Name);
                    return;
                }

                IWorldSensor sensor = LCReflect.CreateInstanceByType <IWorldSensor>(type.FullName);
                WorldSensorDict.Add((int)attr.InfoKey, sensor);
            }

            //实体信息
            foreach (Type type in entitySensorTypes)
            {
                EntitySensorAttribute attr = LCReflect.GetTypeAttr <EntitySensorAttribute>(type);
                if (attr == null)
                {
                    ECSLocate.ECSLog.LogR("有实体信息没有加入特性 >>>>>>", type.Name);
                    return;
                }

                IEntitySensor sensor = LCReflect.CreateInstanceByType <IEntitySensor>(type.FullName);
                EntitySensorDict.Add((int)attr.InfoKey, sensor);
            }
        }
Exemple #2
0
        private void RegAllRequest()
        {
            List <Type> worldRequestTypes  = LCReflect.GetInterfaceByType <IWorldRequest>();
            List <Type> entityRequestTypes = LCReflect.GetInterfaceByType <IEntityRequest>();

            if (worldRequestTypes == null && entityRequestTypes == null)
            {
                return;
            }

            //世界请求
            foreach (Type type in worldRequestTypes)
            {
                WorldRequestAttribute attr = LCReflect.GetTypeAttr <WorldRequestAttribute>(type);
                if (attr == null)
                {
                    ECSLocate.ECSLog.Log("有请求没有加特性 走权重 >>>>>>", type.Name);
                    return;
                }

                IWorldRequest request = LCReflect.CreateInstanceByType <IWorldRequest>(type.FullName);
                WorldRequestDict.Add((int)attr.ReqId, request);
            }

            //实体请求
            foreach (Type type in entityRequestTypes)
            {
                EntityRequestAttribute attr = LCReflect.GetTypeAttr <EntityRequestAttribute>(type);
                if (attr == null)
                {
                    ECSLocate.ECSLog.Log("有请求没有加特性 走权重 >>>>>>", type.Name);
                    return;
                }

                IEntityRequest request = LCReflect.CreateInstanceByType <IEntityRequest>(type.FullName);
                EntityRequestDict.Add((int)attr.ReqId, request);
            }
        }