Пример #1
0
        public T GetEntityInfo <T>(int key, Entity entity, params object[] data) where T : InfoData
        {
            if (!EntitySensorDict.ContainsKey(key))
            {
                ECSLocate.ECSLog.LogError("没有找到对应的自身信息》》》》" + key);
                return(null);
            }
            IEntitySensor sensor = EntitySensorDict[key];

            return(sensor.GetInfo <T>(entity, data));
        }
Пример #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);
            }
        }