Files
GhostEngine/Ghost.Entities/Template/QueryEnumerable.cs
Misaki d2d9f5feb7 Refactor and enhance codebase for maintainability
Refactored and reorganized the codebase to improve readability, performance, and maintainability. Introduced new interfaces and structs for better resource management, updated project configuration files, and refactored shader and graphics pipeline management. Improved error handling, code formatting, and removed unused code and namespaces. Updated DLL references and method signatures for consistency and maintainability.
2025-10-22 18:46:39 +09:00

1707 lines
60 KiB
C#

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<T0>
where T0 : unmanaged, IComponentData
{
private QueryFilter _filter;
private readonly World _world;
private readonly ComponentPool<T0> _pool0;
private readonly int _count;
internal QueryEnumerable(World world, ComponentPool<T0> pool0, int count)
{
_filter = new();
_filter._all.Add(TypeHandle.Get<T0>());
_world = world;
_pool0 = pool0;
_count = count;
}
internal QueryEnumerable(World world, ComponentPool<T0> 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<Entity> _entities;
private readonly Stack.Scope _stackScope;
private readonly ComponentPool<T0> _pool0;
private int _index;
private int _count;
public QueryItem<T0> Current
{
get;
private set;
}
internal Enumerator(World world, ComponentPool<T0> 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<T0>(_entities[_index], _pool0);
return true;
}
public readonly void Dispose()
{
_stackScope.Dispose();
_filter.Dispose();
}
}
public QueryEnumerable<T0> WithAll<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0> WithAny<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0> WithAbsent<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0> WithDisabled<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0> WithAll<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0> WithAny<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0> WithAbsent<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0> WithDisabled<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0> WithAll<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
_filter._all.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0> WithAny<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
_filter._any.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0> WithAbsent<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
_filter._absent.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0> WithDisabled<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
_filter._disabled.Add(TypeHandle.Get<TComponent2>());
return this;
}
}
public unsafe ref struct QueryEnumerable<T0, T1>
where T0 : unmanaged, IComponentData where T1 : unmanaged, IComponentData
{
private QueryFilter _filter;
private readonly World _world;
private readonly ComponentPool<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private readonly int _count;
internal QueryEnumerable(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, int count)
{
_filter = new();
_filter._all.Add(TypeHandle.Get<T0>());
_filter._all.Add(TypeHandle.Get<T1>());
_world = world;
_pool0 = pool0;
_pool1 = pool1;
_count = count;
}
internal QueryEnumerable(World world, ComponentPool<T0> pool0, ComponentPool<T1> 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<Entity> _entities;
private readonly Stack.Scope _stackScope;
private readonly ComponentPool<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private int _index;
private int _count;
public QueryItem<T0, T1> Current
{
get;
private set;
}
internal Enumerator(World world, ComponentPool<T0> pool0, ComponentPool<T1> 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<T0, T1>(_entities[_index], _pool0, _pool1);
return true;
}
public readonly void Dispose()
{
_stackScope.Dispose();
_filter.Dispose();
}
}
public QueryEnumerable<T0, T1> WithAll<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1> WithAny<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1> WithAbsent<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1> WithDisabled<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1> WithAll<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1> WithAny<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1> WithAbsent<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1> WithDisabled<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1> WithAll<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
_filter._all.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1> WithAny<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
_filter._any.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1> WithAbsent<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
_filter._absent.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1> WithDisabled<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
_filter._disabled.Add(TypeHandle.Get<TComponent2>());
return this;
}
}
public unsafe ref struct QueryEnumerable<T0, T1, T2>
where T0 : unmanaged, IComponentData where T1 : unmanaged, IComponentData where T2 : unmanaged, IComponentData
{
private QueryFilter _filter;
private readonly World _world;
private readonly ComponentPool<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private readonly ComponentPool<T2> _pool2;
private readonly int _count;
internal QueryEnumerable(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, int count)
{
_filter = new();
_filter._all.Add(TypeHandle.Get<T0>());
_filter._all.Add(TypeHandle.Get<T1>());
_filter._all.Add(TypeHandle.Get<T2>());
_world = world;
_pool0 = pool0;
_pool1 = pool1;
_pool2 = pool2;
_count = count;
}
internal QueryEnumerable(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> 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<Entity> _entities;
private readonly Stack.Scope _stackScope;
private readonly ComponentPool<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private readonly ComponentPool<T2> _pool2;
private int _index;
private int _count;
public QueryItem<T0, T1, T2> Current
{
get;
private set;
}
internal Enumerator(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> 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<T0, T1, T2>(_entities[_index], _pool0, _pool1, _pool2);
return true;
}
public readonly void Dispose()
{
_stackScope.Dispose();
_filter.Dispose();
}
}
public QueryEnumerable<T0, T1, T2> WithAll<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2> WithAny<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2> WithAbsent<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2> WithDisabled<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2> WithAll<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2> WithAny<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2> WithAbsent<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2> WithDisabled<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2> WithAll<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
_filter._all.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2> WithAny<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
_filter._any.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2> WithAbsent<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
_filter._absent.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2> WithDisabled<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
_filter._disabled.Add(TypeHandle.Get<TComponent2>());
return this;
}
}
public unsafe ref struct QueryEnumerable<T0, T1, T2, T3>
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<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private readonly ComponentPool<T2> _pool2;
private readonly ComponentPool<T3> _pool3;
private readonly int _count;
internal QueryEnumerable(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> pool3, int count)
{
_filter = new();
_filter._all.Add(TypeHandle.Get<T0>());
_filter._all.Add(TypeHandle.Get<T1>());
_filter._all.Add(TypeHandle.Get<T2>());
_filter._all.Add(TypeHandle.Get<T3>());
_world = world;
_pool0 = pool0;
_pool1 = pool1;
_pool2 = pool2;
_pool3 = pool3;
_count = count;
}
internal QueryEnumerable(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> 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<Entity> _entities;
private readonly Stack.Scope _stackScope;
private readonly ComponentPool<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private readonly ComponentPool<T2> _pool2;
private readonly ComponentPool<T3> _pool3;
private int _index;
private int _count;
public QueryItem<T0, T1, T2, T3> Current
{
get;
private set;
}
internal Enumerator(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> 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<T0, T1, T2, T3>(_entities[_index], _pool0, _pool1, _pool2, _pool3);
return true;
}
public readonly void Dispose()
{
_stackScope.Dispose();
_filter.Dispose();
}
}
public QueryEnumerable<T0, T1, T2, T3> WithAll<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3> WithAny<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3> WithAbsent<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3> WithDisabled<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3> WithAll<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3> WithAny<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3> WithAbsent<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3> WithDisabled<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3> WithAll<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
_filter._all.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3> WithAny<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
_filter._any.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3> WithAbsent<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
_filter._absent.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3> WithDisabled<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
_filter._disabled.Add(TypeHandle.Get<TComponent2>());
return this;
}
}
public unsafe ref struct QueryEnumerable<T0, T1, T2, T3, T4>
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<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private readonly ComponentPool<T2> _pool2;
private readonly ComponentPool<T3> _pool3;
private readonly ComponentPool<T4> _pool4;
private readonly int _count;
internal QueryEnumerable(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> pool3, ComponentPool<T4> pool4, int count)
{
_filter = new();
_filter._all.Add(TypeHandle.Get<T0>());
_filter._all.Add(TypeHandle.Get<T1>());
_filter._all.Add(TypeHandle.Get<T2>());
_filter._all.Add(TypeHandle.Get<T3>());
_filter._all.Add(TypeHandle.Get<T4>());
_world = world;
_pool0 = pool0;
_pool1 = pool1;
_pool2 = pool2;
_pool3 = pool3;
_pool4 = pool4;
_count = count;
}
internal QueryEnumerable(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> pool3, ComponentPool<T4> 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<Entity> _entities;
private readonly Stack.Scope _stackScope;
private readonly ComponentPool<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private readonly ComponentPool<T2> _pool2;
private readonly ComponentPool<T3> _pool3;
private readonly ComponentPool<T4> _pool4;
private int _index;
private int _count;
public QueryItem<T0, T1, T2, T3, T4> Current
{
get;
private set;
}
internal Enumerator(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> pool3, ComponentPool<T4> 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<T0, T1, T2, T3, T4>(_entities[_index], _pool0, _pool1, _pool2, _pool3, _pool4);
return true;
}
public readonly void Dispose()
{
_stackScope.Dispose();
_filter.Dispose();
}
}
public QueryEnumerable<T0, T1, T2, T3, T4> WithAll<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4> WithAny<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4> WithAbsent<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4> WithDisabled<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4> WithAll<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4> WithAny<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4> WithAbsent<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4> WithDisabled<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4> WithAll<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
_filter._all.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4> WithAny<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
_filter._any.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4> WithAbsent<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
_filter._absent.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4> WithDisabled<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
_filter._disabled.Add(TypeHandle.Get<TComponent2>());
return this;
}
}
public unsafe ref struct QueryEnumerable<T0, T1, T2, T3, T4, T5>
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<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private readonly ComponentPool<T2> _pool2;
private readonly ComponentPool<T3> _pool3;
private readonly ComponentPool<T4> _pool4;
private readonly ComponentPool<T5> _pool5;
private readonly int _count;
internal QueryEnumerable(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> pool3, ComponentPool<T4> pool4, ComponentPool<T5> pool5, int count)
{
_filter = new();
_filter._all.Add(TypeHandle.Get<T0>());
_filter._all.Add(TypeHandle.Get<T1>());
_filter._all.Add(TypeHandle.Get<T2>());
_filter._all.Add(TypeHandle.Get<T3>());
_filter._all.Add(TypeHandle.Get<T4>());
_filter._all.Add(TypeHandle.Get<T5>());
_world = world;
_pool0 = pool0;
_pool1 = pool1;
_pool2 = pool2;
_pool3 = pool3;
_pool4 = pool4;
_pool5 = pool5;
_count = count;
}
internal QueryEnumerable(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> pool3, ComponentPool<T4> pool4, ComponentPool<T5> 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<Entity> _entities;
private readonly Stack.Scope _stackScope;
private readonly ComponentPool<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private readonly ComponentPool<T2> _pool2;
private readonly ComponentPool<T3> _pool3;
private readonly ComponentPool<T4> _pool4;
private readonly ComponentPool<T5> _pool5;
private int _index;
private int _count;
public QueryItem<T0, T1, T2, T3, T4, T5> Current
{
get;
private set;
}
internal Enumerator(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> pool3, ComponentPool<T4> pool4, ComponentPool<T5> 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<T0, T1, T2, T3, T4, T5>(_entities[_index], _pool0, _pool1, _pool2, _pool3, _pool4, _pool5);
return true;
}
public readonly void Dispose()
{
_stackScope.Dispose();
_filter.Dispose();
}
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5> WithAll<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5> WithAny<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5> WithAbsent<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5> WithDisabled<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5> WithAll<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5> WithAny<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5> WithAbsent<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5> WithDisabled<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5> WithAll<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
_filter._all.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5> WithAny<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
_filter._any.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5> WithAbsent<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
_filter._absent.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5> WithDisabled<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
_filter._disabled.Add(TypeHandle.Get<TComponent2>());
return this;
}
}
public unsafe ref struct QueryEnumerable<T0, T1, T2, T3, T4, T5, T6>
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<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private readonly ComponentPool<T2> _pool2;
private readonly ComponentPool<T3> _pool3;
private readonly ComponentPool<T4> _pool4;
private readonly ComponentPool<T5> _pool5;
private readonly ComponentPool<T6> _pool6;
private readonly int _count;
internal QueryEnumerable(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> pool3, ComponentPool<T4> pool4, ComponentPool<T5> pool5, ComponentPool<T6> pool6, int count)
{
_filter = new();
_filter._all.Add(TypeHandle.Get<T0>());
_filter._all.Add(TypeHandle.Get<T1>());
_filter._all.Add(TypeHandle.Get<T2>());
_filter._all.Add(TypeHandle.Get<T3>());
_filter._all.Add(TypeHandle.Get<T4>());
_filter._all.Add(TypeHandle.Get<T5>());
_filter._all.Add(TypeHandle.Get<T6>());
_world = world;
_pool0 = pool0;
_pool1 = pool1;
_pool2 = pool2;
_pool3 = pool3;
_pool4 = pool4;
_pool5 = pool5;
_pool6 = pool6;
_count = count;
}
internal QueryEnumerable(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> pool3, ComponentPool<T4> pool4, ComponentPool<T5> pool5, ComponentPool<T6> 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<Entity> _entities;
private readonly Stack.Scope _stackScope;
private readonly ComponentPool<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private readonly ComponentPool<T2> _pool2;
private readonly ComponentPool<T3> _pool3;
private readonly ComponentPool<T4> _pool4;
private readonly ComponentPool<T5> _pool5;
private readonly ComponentPool<T6> _pool6;
private int _index;
private int _count;
public QueryItem<T0, T1, T2, T3, T4, T5, T6> Current
{
get;
private set;
}
internal Enumerator(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> pool3, ComponentPool<T4> pool4, ComponentPool<T5> pool5, ComponentPool<T6> 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<T0, T1, T2, T3, T4, T5, T6>(_entities[_index], _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6);
return true;
}
public readonly void Dispose()
{
_stackScope.Dispose();
_filter.Dispose();
}
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6> WithAll<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6> WithAny<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6> WithAbsent<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6> WithDisabled<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6> WithAll<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6> WithAny<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6> WithAbsent<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6> WithDisabled<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6> WithAll<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
_filter._all.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6> WithAny<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
_filter._any.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6> WithAbsent<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
_filter._absent.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6> WithDisabled<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
_filter._disabled.Add(TypeHandle.Get<TComponent2>());
return this;
}
}
public unsafe ref struct QueryEnumerable<T0, T1, T2, T3, T4, T5, T6, T7>
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<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private readonly ComponentPool<T2> _pool2;
private readonly ComponentPool<T3> _pool3;
private readonly ComponentPool<T4> _pool4;
private readonly ComponentPool<T5> _pool5;
private readonly ComponentPool<T6> _pool6;
private readonly ComponentPool<T7> _pool7;
private readonly int _count;
internal QueryEnumerable(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> pool3, ComponentPool<T4> pool4, ComponentPool<T5> pool5, ComponentPool<T6> pool6, ComponentPool<T7> pool7, int count)
{
_filter = new();
_filter._all.Add(TypeHandle.Get<T0>());
_filter._all.Add(TypeHandle.Get<T1>());
_filter._all.Add(TypeHandle.Get<T2>());
_filter._all.Add(TypeHandle.Get<T3>());
_filter._all.Add(TypeHandle.Get<T4>());
_filter._all.Add(TypeHandle.Get<T5>());
_filter._all.Add(TypeHandle.Get<T6>());
_filter._all.Add(TypeHandle.Get<T7>());
_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<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> pool3, ComponentPool<T4> pool4, ComponentPool<T5> pool5, ComponentPool<T6> pool6, ComponentPool<T7> 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<Entity> _entities;
private readonly Stack.Scope _stackScope;
private readonly ComponentPool<T0> _pool0;
private readonly ComponentPool<T1> _pool1;
private readonly ComponentPool<T2> _pool2;
private readonly ComponentPool<T3> _pool3;
private readonly ComponentPool<T4> _pool4;
private readonly ComponentPool<T5> _pool5;
private readonly ComponentPool<T6> _pool6;
private readonly ComponentPool<T7> _pool7;
private int _index;
private int _count;
public QueryItem<T0, T1, T2, T3, T4, T5, T6, T7> Current
{
get;
private set;
}
internal Enumerator(World world, ComponentPool<T0> pool0, ComponentPool<T1> pool1, ComponentPool<T2> pool2, ComponentPool<T3> pool3, ComponentPool<T4> pool4, ComponentPool<T5> pool5, ComponentPool<T6> pool6, ComponentPool<T7> 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<T0, T1, T2, T3, T4, T5, T6, T7>(_entities[_index], _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6, _pool7);
return true;
}
public readonly void Dispose()
{
_stackScope.Dispose();
_filter.Dispose();
}
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6, T7> WithAll<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6, T7> WithAny<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6, T7> WithAbsent<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6, T7> WithDisabled<TComponent0>()
where TComponent0 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6, T7> WithAll<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6, T7> WithAny<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6, T7> WithAbsent<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6, T7> WithDisabled<TComponent0, TComponent1>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6, T7> WithAll<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._all.Add(TypeHandle.Get<TComponent0>());
_filter._all.Add(TypeHandle.Get<TComponent1>());
_filter._all.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6, T7> WithAny<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._any.Add(TypeHandle.Get<TComponent0>());
_filter._any.Add(TypeHandle.Get<TComponent1>());
_filter._any.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6, T7> WithAbsent<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._absent.Add(TypeHandle.Get<TComponent0>());
_filter._absent.Add(TypeHandle.Get<TComponent1>());
_filter._absent.Add(TypeHandle.Get<TComponent2>());
return this;
}
public QueryEnumerable<T0, T1, T2, T3, T4, T5, T6, T7> WithDisabled<TComponent0, TComponent1, TComponent2>()
where TComponent0 : unmanaged, IComponentData where TComponent1 : unmanaged, IComponentData where TComponent2 : unmanaged, IComponentData
{
_filter._disabled.Add(TypeHandle.Get<TComponent0>());
_filter._disabled.Add(TypeHandle.Get<TComponent1>());
_filter._disabled.Add(TypeHandle.Get<TComponent2>());
return this;
}
}