Exemplo n.º 1
0
        /// <summary>
        /// 初始化助手
        /// </summary>
        public void OnInitialization()
        {
            _module     = Module as EntityManager;
            _entityRoot = _module.transform.Find("EntityRoot");

            List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
            {
                return(type.IsSubclassOf(typeof(EntityLogicBase)) && !type.IsAbstract);
            });

            for (int i = 0; i < types.Count; i++)
            {
                EntityResourceAttribute attribute = types[i].GetCustomAttribute <EntityResourceAttribute>();
                if (attribute != null)
                {
                    Entities.Add(types[i], new List <EntityLogicBase>());

                    GameObject group = new GameObject(types[i].Name + "[Group]");
                    group.transform.SetParent(_entityRoot);
                    group.transform.localPosition = Vector3.zero;
                    group.transform.localRotation = Quaternion.identity;
                    group.transform.localScale    = Vector3.one;
                    group.SetActive(true);
                    _entitiesGroup.Add(types[i], group);

                    ObjectPools.Add(types[i], new Queue <GameObject>());
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.Entity, "创建实体逻辑对象失败:实体逻辑类 " + types[i].Name + " 丢失 EntityResourceAttribute 标记!");
                }
            }
        }