using Ghost.Core; using Ghost.Entities.Components; using Ghost.Entities.Query; using Misaki.HighPerformance.Unsafe.Collections; namespace Ghost.Entities; public struct QueryEnumerable where T0 : unmanaged, IComponentData { private readonly World _world; private readonly ComponentPool _pool0; private readonly int _count; private QueryFilter _filters; internal readonly QueryFilter Filters => _filters; internal QueryEnumerable(World world, ComponentPool pool0, int count) { _world = world; _pool0 = pool0; _count = count; _filters = new(); _filters._all.Add(TypeHandle.Get()); } public readonly Enumerator GetEnumerator() => new (_world, _pool0, _count, _filters); public ref struct Enumerator { private readonly World _world; private readonly ReadOnlySpan _entities; private readonly ComponentPool _pool0; private int _index; private readonly int _count; private BitSet _filterMask; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, int count, QueryFilter filters) { _world = world; _entities = _world.EntityManager.Entities; _pool0 = pool0; _count = count; _index = -1; _filterMask = filters.ComputeFilterBitMask(_world); Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _index >= _world.EntityManager.EntityCount) { return false; } Current = new QueryItem(_entities[_index], _pool0); return true; } } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } } public struct QueryEnumerable where T0 : unmanaged, IComponentData where T1 : unmanaged, IComponentData { private readonly World _world; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly int _count; private QueryFilter _filters; internal readonly QueryFilter Filters => _filters; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, int count) { _world = world; _pool0 = pool0; _pool1 = pool1; _count = count; _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); } public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _count, _filters); public ref struct Enumerator { private readonly World _world; private readonly ReadOnlySpan _entities; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private int _index; private readonly int _count; private BitSet _filterMask; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, ComponentPool pool1, int count, QueryFilter filters) { _world = world; _entities = _world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _count = count; _index = -1; _filterMask = filters.ComputeFilterBitMask(_world); Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _index >= _world.EntityManager.EntityCount) { return false; } Current = new QueryItem(_entities[_index], _pool0, _pool1); return true; } } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } } public struct QueryEnumerable where T0 : unmanaged, IComponentData where T1 : unmanaged, IComponentData where T2 : unmanaged, IComponentData { private readonly World _world; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly int _count; private QueryFilter _filters; internal readonly QueryFilter Filters => _filters; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, int count) { _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _count = count; _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); } public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _pool2, _count, _filters); public ref struct Enumerator { private readonly World _world; private readonly ReadOnlySpan _entities; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private int _index; private readonly int _count; private BitSet _filterMask; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, int count, QueryFilter filters) { _world = world; _entities = _world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _count = count; _index = -1; _filterMask = filters.ComputeFilterBitMask(_world); Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _index >= _world.EntityManager.EntityCount) { return false; } Current = new QueryItem(_entities[_index], _pool0, _pool1, _pool2); return true; } } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } } public struct QueryEnumerable where T0 : unmanaged, IComponentData where T1 : unmanaged, IComponentData where T2 : unmanaged, IComponentData where T3 : unmanaged, IComponentData { private readonly World _world; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly ComponentPool _pool3; private readonly int _count; private QueryFilter _filters; internal readonly QueryFilter Filters => _filters; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, int count) { _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _count = count; _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); } public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _pool2, _pool3, _count, _filters); public ref struct Enumerator { private readonly World _world; private readonly ReadOnlySpan _entities; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly ComponentPool _pool3; private int _index; private readonly int _count; private BitSet _filterMask; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, int count, QueryFilter filters) { _world = world; _entities = _world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _count = count; _index = -1; _filterMask = filters.ComputeFilterBitMask(_world); Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _index >= _world.EntityManager.EntityCount) { return false; } Current = new QueryItem(_entities[_index], _pool0, _pool1, _pool2, _pool3); return true; } } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } } public struct QueryEnumerable where T0 : unmanaged, IComponentData where T1 : unmanaged, IComponentData where T2 : unmanaged, IComponentData where T3 : unmanaged, IComponentData where T4 : unmanaged, IComponentData { private readonly World _world; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly ComponentPool _pool3; private readonly ComponentPool _pool4; private readonly int _count; private QueryFilter _filters; internal readonly QueryFilter Filters => _filters; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, int count) { _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _count = count; _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); } public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _pool2, _pool3, _pool4, _count, _filters); public ref struct Enumerator { private readonly World _world; private readonly ReadOnlySpan _entities; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly ComponentPool _pool3; private readonly ComponentPool _pool4; private int _index; private readonly int _count; private BitSet _filterMask; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, int count, QueryFilter filters) { _world = world; _entities = _world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _count = count; _index = -1; _filterMask = filters.ComputeFilterBitMask(_world); Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _index >= _world.EntityManager.EntityCount) { return false; } Current = new QueryItem(_entities[_index], _pool0, _pool1, _pool2, _pool3, _pool4); return true; } } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } } public struct QueryEnumerable where T0 : unmanaged, IComponentData where T1 : unmanaged, IComponentData where T2 : unmanaged, IComponentData where T3 : unmanaged, IComponentData where T4 : unmanaged, IComponentData where T5 : unmanaged, IComponentData { private readonly World _world; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly ComponentPool _pool3; private readonly ComponentPool _pool4; private readonly ComponentPool _pool5; private readonly int _count; private QueryFilter _filters; internal readonly QueryFilter Filters => _filters; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, ComponentPool pool5, int count) { _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _count = count; _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); } public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _count, _filters); public ref struct Enumerator { private readonly World _world; private readonly ReadOnlySpan _entities; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly ComponentPool _pool3; private readonly ComponentPool _pool4; private readonly ComponentPool _pool5; private int _index; private readonly int _count; private BitSet _filterMask; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, ComponentPool pool5, int count, QueryFilter filters) { _world = world; _entities = _world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _count = count; _index = -1; _filterMask = filters.ComputeFilterBitMask(_world); Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _index >= _world.EntityManager.EntityCount) { return false; } Current = new QueryItem(_entities[_index], _pool0, _pool1, _pool2, _pool3, _pool4, _pool5); return true; } } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } } public struct QueryEnumerable where T0 : unmanaged, IComponentData where T1 : unmanaged, IComponentData where T2 : unmanaged, IComponentData where T3 : unmanaged, IComponentData where T4 : unmanaged, IComponentData where T5 : unmanaged, IComponentData where T6 : unmanaged, IComponentData { private readonly World _world; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly ComponentPool _pool3; private readonly ComponentPool _pool4; private readonly ComponentPool _pool5; private readonly ComponentPool _pool6; private readonly int _count; private QueryFilter _filters; internal readonly QueryFilter Filters => _filters; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, ComponentPool pool5, ComponentPool pool6, int count) { _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _pool6 = pool6; _count = count; _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); } public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6, _count, _filters); public ref struct Enumerator { private readonly World _world; private readonly ReadOnlySpan _entities; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly ComponentPool _pool3; private readonly ComponentPool _pool4; private readonly ComponentPool _pool5; private readonly ComponentPool _pool6; private int _index; private readonly int _count; private BitSet _filterMask; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, ComponentPool pool5, ComponentPool pool6, int count, QueryFilter filters) { _world = world; _entities = _world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _pool6 = pool6; _count = count; _index = -1; _filterMask = filters.ComputeFilterBitMask(_world); Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _index >= _world.EntityManager.EntityCount) { return false; } Current = new QueryItem(_entities[_index], _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6); return true; } } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } } public struct QueryEnumerable where T0 : unmanaged, IComponentData where T1 : unmanaged, IComponentData where T2 : unmanaged, IComponentData where T3 : unmanaged, IComponentData where T4 : unmanaged, IComponentData where T5 : unmanaged, IComponentData where T6 : unmanaged, IComponentData where T7 : unmanaged, IComponentData { private readonly World _world; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly ComponentPool _pool3; private readonly ComponentPool _pool4; private readonly ComponentPool _pool5; private readonly ComponentPool _pool6; private readonly ComponentPool _pool7; private readonly int _count; private QueryFilter _filters; internal readonly QueryFilter Filters => _filters; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, ComponentPool pool5, ComponentPool pool6, ComponentPool pool7, int count) { _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _pool6 = pool6; _pool7 = pool7; _count = count; _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); } public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6, _pool7, _count, _filters); public ref struct Enumerator { private readonly World _world; private readonly ReadOnlySpan _entities; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly ComponentPool _pool3; private readonly ComponentPool _pool4; private readonly ComponentPool _pool5; private readonly ComponentPool _pool6; private readonly ComponentPool _pool7; private int _index; private readonly int _count; private BitSet _filterMask; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, ComponentPool pool5, ComponentPool pool6, ComponentPool pool7, int count, QueryFilter filters) { _world = world; _entities = _world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _pool6 = pool6; _pool7 = pool7; _count = count; _index = -1; _filterMask = filters.ComputeFilterBitMask(_world); Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _index >= _world.EntityManager.EntityCount) { return false; } Current = new QueryItem(_entities[_index], _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6, _pool7); return true; } } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; } public readonly QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; } }