internal Enumerator(EcsQuery query) { _query = query; _world = query._world; _entities = query._entities; _idx = 0; _count = _entities != null ? query._entitiesCount + 1 : 0; }
internal EcsQuery(EcsWorld world, int capacity) { _world = world; _include = new EcsBitSet(capacity); _exclude = new EcsBitSet(capacity); _entities = null; _entitiesCount = int.MaxValue; }
void Recycle() { _it = default; _entities = null; _entitiesCount = int.MaxValue; _include.Clear(); _exclude.Clear(); _world.RecycleQuery(this); }
public EcsQuery With <T> () where T : struct { var typeId = EcsComponentType <T> .GetIdInWorld(_world.Index); #if DEBUG if (typeId <= 0) { throw new Exception($"invalid query: \"{typeof (T).Name}\" component not registered in world."); } if (_include.Get(typeId) || _exclude.Get(typeId)) { throw new Exception($"invalid query: \"{typeof (T).Name}\" constraint already used."); } #endif _include.Set(typeId); var pool = _world.Pools[typeId]; var poolCount = pool.Entities.GetCount(); if (poolCount < _entitiesCount) { _entities = pool.Entities; _entitiesCount = poolCount; } return(this); }
public EcsComponentPoolBase(int entitiesCapacity) { Entities = new EcsSparseSet(entitiesCapacity, entitiesCapacity); }