コード例 #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
ファイル: ComponentPool.cs プロジェクト: theypsilon/MiniECS
 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);
     }
 }