using Ghost.Core; using Ghost.Entities.Components; using Ghost.Entities.Query; using Misaki.HighPerformance.LowLevel.Buffer; using Misaki.HighPerformance.LowLevel.Collections; namespace Ghost.Entities; public unsafe ref struct QueryEnumerable where T0 : unmanaged, IComponentData { private QueryFilter _filter; private readonly World _world; private readonly ComponentPool _pool0; private readonly int _count; internal QueryEnumerable(World world, ComponentPool pool0, int count) { _filter = new(); _filter._all.Add(TypeHandle.Get()); _world = world; _pool0 = pool0; _count = count; } internal QueryEnumerable(World world, ComponentPool pool0, int count, ref readonly QueryFilter filter) { _filter = filter; _world = world; _pool0 = pool0; _count = count; } #pragma warning disable CS9084 // Struct member returns 'this' or other instance members by reference public Enumerator GetEnumerator() => new(_world, _pool0, _count, ref _filter); #pragma warning restore CS9084 // Struct member returns 'this' or other instance members by reference public ref struct Enumerator { private ref QueryFilter _filter; private UnsafeBitSet _filterMask; private readonly ReadOnlySpan _entities; private readonly Stack.Scope _stackScope; private readonly ComponentPool _pool0; private int _index; private int _count; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, int count, ref QueryFilter filter) { _stackScope = AllocationManager.CreateStackScope(); _filter = ref filter; _filterMask = _filter.ComputeFilterBitMask(world, Allocator.Stack); _entities = world.EntityManager.Entities; _pool0 = pool0; _count = count; _index = -1; Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _count <= 0 || _index >= _entities.Length) { return false; } _count--; Current = new QueryItem(_entities[_index], _pool0); return true; } public readonly void Dispose() { _stackScope.Dispose(); _filter.Dispose(); } } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } } public unsafe ref struct QueryEnumerable where T0 : unmanaged, IComponentData where T1 : unmanaged, IComponentData { private QueryFilter _filter; private readonly World _world; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly int _count; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, int count) { _filter = new(); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _world = world; _pool0 = pool0; _pool1 = pool1; _count = count; } internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, int count, ref readonly QueryFilter filter) { _filter = filter; _world = world; _pool0 = pool0; _pool1 = pool1; _count = count; } #pragma warning disable CS9084 // Struct member returns 'this' or other instance members by reference public Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _count, ref _filter); #pragma warning restore CS9084 // Struct member returns 'this' or other instance members by reference public ref struct Enumerator { private ref QueryFilter _filter; private UnsafeBitSet _filterMask; private readonly ReadOnlySpan _entities; private readonly Stack.Scope _stackScope; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private int _index; private int _count; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, ComponentPool pool1, int count, ref QueryFilter filter) { _stackScope = AllocationManager.CreateStackScope(); _filter = ref filter; _filterMask = _filter.ComputeFilterBitMask(world, Allocator.Stack); _entities = world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _count = count; _index = -1; Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _count <= 0) { return false; } _count--; Current = new QueryItem(_entities[_index], _pool0, _pool1); return true; } public readonly void Dispose() { _stackScope.Dispose(); _filter.Dispose(); } } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } } public unsafe ref struct QueryEnumerable where T0 : unmanaged, IComponentData where T1 : unmanaged, IComponentData where T2 : unmanaged, IComponentData { private QueryFilter _filter; private readonly World _world; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly int _count; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, int count) { _filter = new(); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _count = count; } internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, int count, ref readonly QueryFilter filter) { _filter = filter; _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _count = count; } #pragma warning disable CS9084 // Struct member returns 'this' or other instance members by reference public Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _pool2, _count, ref _filter); #pragma warning restore CS9084 // Struct member returns 'this' or other instance members by reference public ref struct Enumerator { private ref QueryFilter _filter; private UnsafeBitSet _filterMask; private readonly ReadOnlySpan _entities; private readonly Stack.Scope _stackScope; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private int _index; private int _count; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, int count, ref QueryFilter filter) { _stackScope = AllocationManager.CreateStackScope(); _filter = ref filter; _filterMask = _filter.ComputeFilterBitMask(world, Allocator.Stack); _entities = world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _count = count; _index = -1; Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _count <= 0) { return false; } _count--; Current = new QueryItem(_entities[_index], _pool0, _pool1, _pool2); return true; } public readonly void Dispose() { _stackScope.Dispose(); _filter.Dispose(); } } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } } public unsafe ref struct QueryEnumerable where T0 : unmanaged, IComponentData where T1 : unmanaged, IComponentData where T2 : unmanaged, IComponentData where T3 : unmanaged, IComponentData { private QueryFilter _filter; private readonly World _world; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly ComponentPool _pool3; private readonly int _count; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, int count) { _filter = new(); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _count = count; } internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, int count, ref readonly QueryFilter filter) { _filter = filter; _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _count = count; } #pragma warning disable CS9084 // Struct member returns 'this' or other instance members by reference public Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _pool2, _pool3, _count, ref _filter); #pragma warning restore CS9084 // Struct member returns 'this' or other instance members by reference public ref struct Enumerator { private ref QueryFilter _filter; private UnsafeBitSet _filterMask; private readonly ReadOnlySpan _entities; private readonly Stack.Scope _stackScope; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly ComponentPool _pool3; private int _index; private int _count; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, int count, ref QueryFilter filter) { _stackScope = AllocationManager.CreateStackScope(); _filter = ref filter; _filterMask = _filter.ComputeFilterBitMask(world, Allocator.Stack); _entities = world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _count = count; _index = -1; Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _count <= 0) { return false; } _count--; Current = new QueryItem(_entities[_index], _pool0, _pool1, _pool2, _pool3); return true; } public readonly void Dispose() { _stackScope.Dispose(); _filter.Dispose(); } } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } } public unsafe ref struct QueryEnumerable where T0 : unmanaged, IComponentData where T1 : unmanaged, IComponentData where T2 : unmanaged, IComponentData where T3 : unmanaged, IComponentData where T4 : unmanaged, IComponentData { private QueryFilter _filter; 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; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, int count) { _filter = new(); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _count = count; } internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, int count, ref readonly QueryFilter filter) { _filter = filter; _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _count = count; } #pragma warning disable CS9084 // Struct member returns 'this' or other instance members by reference public Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _pool2, _pool3, _pool4, _count, ref _filter); #pragma warning restore CS9084 // Struct member returns 'this' or other instance members by reference public ref struct Enumerator { private ref QueryFilter _filter; private UnsafeBitSet _filterMask; private readonly ReadOnlySpan _entities; private readonly Stack.Scope _stackScope; private readonly ComponentPool _pool0; private readonly ComponentPool _pool1; private readonly ComponentPool _pool2; private readonly ComponentPool _pool3; private readonly ComponentPool _pool4; private int _index; private int _count; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, int count, ref QueryFilter filter) { _stackScope = AllocationManager.CreateStackScope(); _filter = ref filter; _filterMask = _filter.ComputeFilterBitMask(world, Allocator.Stack); _entities = world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _count = count; _index = -1; Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _count <= 0) { return false; } _count--; Current = new QueryItem(_entities[_index], _pool0, _pool1, _pool2, _pool3, _pool4); return true; } public readonly void Dispose() { _stackScope.Dispose(); _filter.Dispose(); } } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } } public unsafe ref 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 QueryFilter _filter; 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; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, ComponentPool pool5, int count) { _filter = new(); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _count = count; } internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, ComponentPool pool5, int count, ref readonly QueryFilter filter) { _filter = filter; _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _count = count; } #pragma warning disable CS9084 // Struct member returns 'this' or other instance members by reference public Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _count, ref _filter); #pragma warning restore CS9084 // Struct member returns 'this' or other instance members by reference public ref struct Enumerator { private ref QueryFilter _filter; private UnsafeBitSet _filterMask; private readonly ReadOnlySpan _entities; private readonly Stack.Scope _stackScope; 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 int _count; public QueryItem Current { get; private set; } internal Enumerator(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, ComponentPool pool5, int count, ref QueryFilter filter) { _stackScope = AllocationManager.CreateStackScope(); _filter = ref filter; _filterMask = _filter.ComputeFilterBitMask(world, Allocator.Stack); _entities = world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _count = count; _index = -1; Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _count <= 0) { return false; } _count--; Current = new QueryItem(_entities[_index], _pool0, _pool1, _pool2, _pool3, _pool4, _pool5); return true; } public readonly void Dispose() { _stackScope.Dispose(); _filter.Dispose(); } } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } } public unsafe ref 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 QueryFilter _filter; 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; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, ComponentPool pool5, ComponentPool pool6, int count) { _filter = new(); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _pool6 = pool6; _count = count; } internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, ComponentPool pool5, ComponentPool pool6, int count, ref readonly QueryFilter filter) { _filter = filter; _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _pool6 = pool6; _count = count; } #pragma warning disable CS9084 // Struct member returns 'this' or other instance members by reference public Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6, _count, ref _filter); #pragma warning restore CS9084 // Struct member returns 'this' or other instance members by reference public ref struct Enumerator { private ref QueryFilter _filter; private UnsafeBitSet _filterMask; private readonly ReadOnlySpan _entities; private readonly Stack.Scope _stackScope; 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 int _count; 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, ref QueryFilter filter) { _stackScope = AllocationManager.CreateStackScope(); _filter = ref filter; _filterMask = _filter.ComputeFilterBitMask(world, Allocator.Stack); _entities = world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _pool6 = pool6; _count = count; _index = -1; Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _count <= 0) { return false; } _count--; Current = new QueryItem(_entities[_index], _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6); return true; } public readonly void Dispose() { _stackScope.Dispose(); _filter.Dispose(); } } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } } public unsafe ref 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 QueryFilter _filter; 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; internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, ComponentPool pool5, ComponentPool pool6, ComponentPool pool7, int count) { _filter = new(); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _pool6 = pool6; _pool7 = pool7; _count = count; } internal QueryEnumerable(World world, ComponentPool pool0, ComponentPool pool1, ComponentPool pool2, ComponentPool pool3, ComponentPool pool4, ComponentPool pool5, ComponentPool pool6, ComponentPool pool7, int count, ref readonly QueryFilter filter) { _filter = filter; _world = world; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _pool6 = pool6; _pool7 = pool7; _count = count; } #pragma warning disable CS9084 // Struct member returns 'this' or other instance members by reference public Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6, _pool7, _count, ref _filter); #pragma warning restore CS9084 // Struct member returns 'this' or other instance members by reference public ref struct Enumerator { private ref QueryFilter _filter; private UnsafeBitSet _filterMask; private readonly ReadOnlySpan _entities; private readonly Stack.Scope _stackScope; 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 int _count; 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, ref QueryFilter filter) { _stackScope = AllocationManager.CreateStackScope(); _filter = ref filter; _filterMask = _filter.ComputeFilterBitMask(world, Allocator.Stack); _entities = world.EntityManager.Entities; _pool0 = pool0; _pool1 = pool1; _pool2 = pool2; _pool3 = pool3; _pool4 = pool4; _pool5 = pool5; _pool6 = pool6; _pool7 = pool7; _count = count; _index = -1; Current = default; } public bool MoveNext() { _index = _filterMask.NextSetBit(_index + 1); if (_index < 0 || _count <= 0) { return false; } _count--; Current = new QueryItem(_entities[_index], _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6, _pool7); return true; } public readonly void Dispose() { _stackScope.Dispose(); _filter.Dispose(); } } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAll() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); _filter._all.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAny() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); _filter._any.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithAbsent() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); _filter._absent.Add(TypeHandle.Get()); return this; } public QueryEnumerable WithDisabled() where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData { _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); _filter._disabled.Add(TypeHandle.Get()); return this; } }