示例#1
0
文件: ECS.cs 项目: theypsilon/MiniECS
        public ComponentPool <TComponent> CreatePool <TComponent>(int capacity = 32, EntityLinker indexes = null, Func <TComponent> factory = null) where TComponent : new()
        {
            var pool = new ComponentPool <TComponent>(
                capacity,
                indexes ?? new EntityLinker(_entityValidation.Capacity),
                _removeEntitiesShortcut,
                factory ?? (() => new TComponent())
                );

            _pools.Add(pool);
            _resetters.Add(pool);
            return(pool);
        }
示例#2
0
 public ComponentPool(int capacity, EntityLinker indexArray, List <ComponentSet> removeEntityShorcut, Func <TComponent> factory)
 {
     _factory = factory;
     _bitSet.Initialize(indexArray.Array.Data.Length);
     _Entities.Initialize(capacity);
     _IndexByEntity       = indexArray;
     _removeEntityShorcut = removeEntityShorcut;
     _isReferenceType     = !typeof(TComponent).IsValueType;
     _Components.Initialize(capacity);
     if (_isReferenceType)
     {
         FillDefaultComponents(0, capacity);
     }
 }