Files
GhostEngine/Ghost.Entities/Template/QueryEnumerable.cs
Misaki 4110c166cf Refactor Vector3Field and update project structure
Changed Vector3Field.cs to derive from ValueControl<Vector3> and use NumberBox controls for better UI handling.
Changed EditorControls.xaml to update resource paths for new controls.
Changed InternalControls.xaml to simplify the resource dictionary by removing unnecessary references.
Changed IComponentEditor.cs to reflect updates in the component editor's lifecycle methods.
Changed project files for Ghost.Editor and Ghost.Core to include new dependencies and project references.
Changed FileExtensions.cs and IInspectorService.cs to align with the new namespace structure.
Changed Result.cs to enhance error handling and success checking methods.
Changed TypeHandle.cs to improve type handling compatibility.
Changed AssemblyInfo.cs files to include new assembly visibility attributes for better encapsulation.
Added new graphics-related classes and interfaces in the Ghost.Engine project, including IGraphicsDevice and DX12GraphicsDevice.
Added a new Mesh class to handle 3D mesh data and provide methods for creating geometric shapes.
Added GraphicsPipeline.cs to manage the graphics rendering loop and device initialization.
Added ScenePage.xaml and ScenePage.xaml.cs to create a new page for rendering scenes.
Updated HierarchyPage.xaml.cs and InspectorPage.xaml.cs to use the new service locator pattern for service retrieval.
Updated LandingWindow.xaml.cs and EngineEditorWindow.xaml.cs to utilize the new service locator pattern for better service access.
Updated Logger.cs to enhance logging capabilities with optional stack traces and assertion logging.
Updated QueryFilter.cs and QueryEnumerable.cs to use the new TypeHandle structure for improved efficiency.
Updated WorldNode.cs and WorldNodeSerializer.cs to enhance serialization and management of world nodes.
Updated AssetDatabase and related classes to improve asset management and metadata generation.
Updated Ghost.UnitTest.csproj to include new project references and package dependencies for unit tests.
2025-06-27 20:02:02 +09:00

1486 lines
54 KiB
C#

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