Example #1
0
        public T GetWorldInfo <T>(int key, params object[] data) where T : InfoData
        {
            if (!WorldSensorDict.ContainsKey(key))
            {
                ECSLocate.ECSLog.LogError("没有找到对应的世界信息》》》》" + key);
                return(null);
            }
            IWorldSensor sensor = WorldSensorDict[key];

            return(sensor.GetInfo <T>(data));
        }
Example #2
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);
            }
        }