package ecs

// Code generated by go generate; DO NOT EDIT.

import (
	
	
)

// Filter0 is a filter for 0 components.
// Used to create [Query0] iterators.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Filter2] for a usage example.
type Filter0 struct {
	world        *World
	ids          []ID
	relations    []relationID
	components   []*componentStorage
	filter       filter
	mutex        sync.Mutex
	generation   uint32
	rareComp     uint8
	numRelations uint8
}

// New creates a new [Filter0]. It is safe to call on `nil` instance.
// It is a helper method, intended to avoid repeated listing of type parameters.
//
// See [Filter2.New] for an example.
func (*Filter0) ( *World) *Filter0 {
	return NewFilter0()
}

// NewFilter0 creates a new [Filter0].
//
// Use [Filter0.Query] to obtain a [Query0].
//
// See also [Filter0.New] for a shortcut when constructing an already defined instance.
func ( *World) *Filter0 {
	 := []ID{}
	 := make([]*componentStorage, 0)
	return &Filter0{
		world:      ,
		ids:        ,
		filter:     newFilter(...),
		components: ,
	}
}

// With specifies additional components to filter for.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter0) ( ...Comp) *Filter0 {
	.checkModify()
	for ,  := range  {
		 := .world.componentID(.tp)
		.ids = append(.ids, )
		.filter.mask.Set(.id)
	}
	return 
}

// Without specifies components to exclude.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter0) ( ...Comp) *Filter0 {
	.checkModify()
	if len() == 0 {
		return 
	}
	for ,  := range  {
		 := .world.componentID(.tp)
		.filter.without.Set(.id)
		.filter.hasWithout = true
	}
	return 
}

// Exclusive makes the filter exclusive in the sense that the component composition is matched exactly,
// and no other components are allowed. This includes components set via [Filter0.With].
//
// Overwrites components set via [Filter0.Without].
func ( *Filter0) () *Filter0 {
	.checkModify()
	.filter = .filter.Exclusive()
	return 
}

// Relations sets permanent entity relation targets for this filter.
// Relation targets set here are included in filter caching.
// Contrary, relation targets specified in [Filter0.Query] or [Filter0.Batch] are not cached.
//
// Relation components used here must be in the filter's parameters
// or added via [Filter0.With] beforehand.
//
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter0) ( ...Relation) *Filter0 {
	.checkModify()
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	.numRelations = uint8(len(.relations))
	return 
}

// Register this filter to the world's filter cache.
//
// Registering filters is optional.
// It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func ( *Filter0) () *Filter0 {
	if .filter.cache != maxCacheID {
		panic("filter is already registered, can't register")
	}
	.world.storage.registerFilter(&.filter, .relations[:.numRelations])
	return 
}

// Unregister this filter from the world's filter cache.
func ( *Filter0) () {
	if .filter.cache == maxCacheID {
		panic("filter is not registered, can't unregister")
	}
	.world.storage.unregisterFilter(&.filter)
}

// Query creates a [Query0] from this filter.
// This must be used each time before iterating a query.
//
// Relation targets provided here are added to those specified with [Filter0.Relations].
// Relation components must be in the filter's parameters or added via [Filter0.With] beforehand.
func ( *Filter0) ( ...Relation) Query0 {
	 := relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], true)

	var  uint8
	var  *cacheEntry
	if .filter.cache != maxCacheID {
		 = .numRelations
		 = .world.storage.getRegisteredFilter(.filter.cache)
	} else {
		 := &.world.storage.registry
		 := .version
		if .generation !=  {
			.mutex.Lock()
			.rareComp = .rareComponent(.ids).id
			.generation = 
			.mutex.Unlock()
		}
	}

	return Query0{
		world:      .world,
		filter:     &.filter,
		relations:  [:],
		cache:      ,
		lock:       .world.lockSafe(),
		components: .components,
		cursor: cursor{
			archetype: -1,
			table:     -1,
			index:     0,
			maxIndex:  -1,
		},
		rareComp:    .rareComp,
		hasRareComp: len(.ids) > 0,
	}
}

// Batch creates a [Batch] from this filter.
//
// Relation targets provided here are added to those specified with [Filter0.Relations].
// Relation components must be in the filter's parameters or added via [Filter0.With] beforehand.
//
// ⚠️ The returned [Batch] filter should not be stored, but used immediately and re-generated
// each time a batch operation is called.
// Otherwise, changes to the origin filter or calls to [Filter0.Batch] or [Filter0.Query]
// with different relationship targets may modify stored instances.
func ( *Filter0) ( ...Relation) Batch {
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	var  uint8
	if .filter.cache != maxCacheID {
		 = .numRelations
	}
	return Batch{
		filter:    &.filter,
		relations: .relations[:],
	}
}

func ( *Filter0) () {
	if .filter.cache != maxCacheID {
		panic("can't modify a cached filter")
	}
	if .generation != 0 {
		panic("can't modify a filter that was already queried")
	}
}

// Filter1 is a filter for 1 components.
// Used to create [Query1] iterators.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Filter2] for a usage example.
type Filter1[ any] struct {
	world        *World
	ids          []ID
	relations    []relationID
	components   []*componentStorage
	filter       filter
	mutex        sync.Mutex
	generation   uint32
	rareComp     uint8
	numRelations uint8
}

// New creates a new [Filter1]. It is safe to call on `nil` instance.
// It is a helper method, intended to avoid repeated listing of type parameters.
//
// See [Filter2.New] for an example.
func (*Filter1[]) ( *World) *Filter1[] {
	return NewFilter1[]()
}

// NewFilter1 creates a new [Filter1].
//
// Use [Filter1.Query] to obtain a [Query1].
//
// See also [Filter1.New] for a shortcut when constructing an already defined instance.
func [ any]( *World) *Filter1[] {
	 := []ID{
		ComponentID[](),
	}
	 := make([]*componentStorage, 1)
	[0] = &.storage.components[[0].id]
	return &Filter1[]{
		world:      ,
		ids:        ,
		filter:     newFilter(...),
		components: ,
	}
}

// With specifies additional components to filter for.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter1[]) ( ...Comp) *Filter1[] {
	.checkModify()
	for ,  := range  {
		 := .world.componentID(.tp)
		.ids = append(.ids, )
		.filter.mask.Set(.id)
	}
	return 
}

// Without specifies components to exclude.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter1[]) ( ...Comp) *Filter1[] {
	.checkModify()
	if len() == 0 {
		return 
	}
	for ,  := range  {
		 := .world.componentID(.tp)
		.filter.without.Set(.id)
		.filter.hasWithout = true
	}
	return 
}

// Exclusive makes the filter exclusive in the sense that the component composition is matched exactly,
// and no other components are allowed. This includes components set via [Filter1.With].
//
// Overwrites components set via [Filter1.Without].
func ( *Filter1[]) () *Filter1[] {
	.checkModify()
	.filter = .filter.Exclusive()
	return 
}

// Relations sets permanent entity relation targets for this filter.
// Relation targets set here are included in filter caching.
// Contrary, relation targets specified in [Filter1.Query] or [Filter1.Batch] are not cached.
//
// Relation components used here must be in the filter's parameters
// or added via [Filter1.With] beforehand.
//
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter1[]) ( ...Relation) *Filter1[] {
	.checkModify()
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	.numRelations = uint8(len(.relations))
	return 
}

// Register this filter to the world's filter cache.
//
// Registering filters is optional.
// It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func ( *Filter1[]) () *Filter1[] {
	if .filter.cache != maxCacheID {
		panic("filter is already registered, can't register")
	}
	.world.storage.registerFilter(&.filter, .relations[:.numRelations])
	return 
}

// Unregister this filter from the world's filter cache.
func ( *Filter1[]) () {
	if .filter.cache == maxCacheID {
		panic("filter is not registered, can't unregister")
	}
	.world.storage.unregisterFilter(&.filter)
}

// Query creates a [Query1] from this filter.
// This must be used each time before iterating a query.
//
// Relation targets provided here are added to those specified with [Filter1.Relations].
// Relation components must be in the filter's parameters or added via [Filter1.With] beforehand.
func ( *Filter1[]) ( ...Relation) Query1[] {
	 := relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], true)

	var  uint8
	var  *cacheEntry
	if .filter.cache != maxCacheID {
		 = .numRelations
		 = .world.storage.getRegisteredFilter(.filter.cache)
	} else {
		 := &.world.storage.registry
		 := .version
		if .generation !=  {
			.mutex.Lock()
			.rareComp = .rareComponent(.ids).id
			.generation = 
			.mutex.Unlock()
		}
	}

	return Query1[]{
		world:      .world,
		filter:     &.filter,
		relations:  [:],
		cache:      ,
		lock:       .world.lockSafe(),
		components: .components,
		cursor: cursor{
			archetype: -1,
			table:     -1,
			index:     0,
			maxIndex:  -1,
		},
		rareComp:   .rareComp,
		columnPtrA: unsafe.Pointer(nilDummy),
	}
}

// Batch creates a [Batch] from this filter.
//
// Relation targets provided here are added to those specified with [Filter1.Relations].
// Relation components must be in the filter's parameters or added via [Filter1.With] beforehand.
//
// ⚠️ The returned [Batch] filter should not be stored, but used immediately and re-generated
// each time a batch operation is called.
// Otherwise, changes to the origin filter or calls to [Filter1.Batch] or [Filter1.Query]
// with different relationship targets may modify stored instances.
func ( *Filter1[]) ( ...Relation) Batch {
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	var  uint8
	if .filter.cache != maxCacheID {
		 = .numRelations
	}
	return Batch{
		filter:    &.filter,
		relations: .relations[:],
	}
}

func ( *Filter1[]) () {
	if .filter.cache != maxCacheID {
		panic("can't modify a cached filter")
	}
	if .generation != 0 {
		panic("can't modify a filter that was already queried")
	}
}

// Filter2 is a filter for 2 components.
// Used to create [Query2] iterators.
//
// Instances should be created during initialization and stored, e.g. in systems.
type Filter2[ any,  any] struct {
	world        *World
	ids          []ID
	relations    []relationID
	components   []*componentStorage
	filter       filter
	mutex        sync.Mutex
	generation   uint32
	rareComp     uint8
	numRelations uint8
}

// New creates a new [Filter2]. It is safe to call on `nil` instance.
// It is a helper method, intended to avoid repeated listing of type parameters.
func (*Filter2[, ]) ( *World) *Filter2[, ] {
	return NewFilter2[, ]()
}

// NewFilter2 creates a new [Filter2].
//
// Use [Filter2.Query] to obtain a [Query2].
//
// See also [Filter2.New] for a shortcut when constructing an already defined instance.
func [ any,  any]( *World) *Filter2[, ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
	}
	 := make([]*componentStorage, 2)
	[0] = &.storage.components[[0].id]
	[1] = &.storage.components[[1].id]
	return &Filter2[, ]{
		world:      ,
		ids:        ,
		filter:     newFilter(...),
		components: ,
	}
}

// With specifies additional components to filter for.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter2[, ]) ( ...Comp) *Filter2[, ] {
	.checkModify()
	for ,  := range  {
		 := .world.componentID(.tp)
		.ids = append(.ids, )
		.filter.mask.Set(.id)
	}
	return 
}

// Without specifies components to exclude.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter2[, ]) ( ...Comp) *Filter2[, ] {
	.checkModify()
	if len() == 0 {
		return 
	}
	for ,  := range  {
		 := .world.componentID(.tp)
		.filter.without.Set(.id)
		.filter.hasWithout = true
	}
	return 
}

// Exclusive makes the filter exclusive in the sense that the component composition is matched exactly,
// and no other components are allowed. This includes components set via [Filter2.With].
//
// Overwrites components set via [Filter2.Without].
func ( *Filter2[, ]) () *Filter2[, ] {
	.checkModify()
	.filter = .filter.Exclusive()
	return 
}

// Relations sets permanent entity relation targets for this filter.
// Relation targets set here are included in filter caching.
// Contrary, relation targets specified in [Filter2.Query] or [Filter2.Batch] are not cached.
//
// Relation components used here must be in the filter's parameters
// or added via [Filter2.With] beforehand.
//
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter2[, ]) ( ...Relation) *Filter2[, ] {
	.checkModify()
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	.numRelations = uint8(len(.relations))
	return 
}

// Register this filter to the world's filter cache.
//
// Registering filters is optional.
// It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func ( *Filter2[, ]) () *Filter2[, ] {
	if .filter.cache != maxCacheID {
		panic("filter is already registered, can't register")
	}
	.world.storage.registerFilter(&.filter, .relations[:.numRelations])
	return 
}

// Unregister this filter from the world's filter cache.
func ( *Filter2[, ]) () {
	if .filter.cache == maxCacheID {
		panic("filter is not registered, can't unregister")
	}
	.world.storage.unregisterFilter(&.filter)
}

// Query creates a [Query2] from this filter.
// This must be used each time before iterating a query.
//
// Relation targets provided here are added to those specified with [Filter2.Relations].
// Relation components must be in the filter's parameters or added via [Filter2.With] beforehand.
func ( *Filter2[, ]) ( ...Relation) Query2[, ] {
	 := relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], true)

	var  uint8
	var  *cacheEntry
	if .filter.cache != maxCacheID {
		 = .numRelations
		 = .world.storage.getRegisteredFilter(.filter.cache)
	} else {
		 := &.world.storage.registry
		 := .version
		if .generation !=  {
			.mutex.Lock()
			.rareComp = .rareComponent(.ids).id
			.generation = 
			.mutex.Unlock()
		}
	}

	return Query2[, ]{
		world:      .world,
		filter:     &.filter,
		relations:  [:],
		cache:      ,
		lock:       .world.lockSafe(),
		components: .components,
		cursor: cursor{
			archetype: -1,
			table:     -1,
			index:     0,
			maxIndex:  -1,
		},
		rareComp:   .rareComp,
		columnPtrA: unsafe.Pointer(nilDummy),
		columnPtrB: unsafe.Pointer(nilDummy),
	}
}

// Batch creates a [Batch] from this filter.
//
// Relation targets provided here are added to those specified with [Filter2.Relations].
// Relation components must be in the filter's parameters or added via [Filter2.With] beforehand.
//
// ⚠️ The returned [Batch] filter should not be stored, but used immediately and re-generated
// each time a batch operation is called.
// Otherwise, changes to the origin filter or calls to [Filter2.Batch] or [Filter2.Query]
// with different relationship targets may modify stored instances.
func ( *Filter2[, ]) ( ...Relation) Batch {
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	var  uint8
	if .filter.cache != maxCacheID {
		 = .numRelations
	}
	return Batch{
		filter:    &.filter,
		relations: .relations[:],
	}
}

func ( *Filter2[, ]) () {
	if .filter.cache != maxCacheID {
		panic("can't modify a cached filter")
	}
	if .generation != 0 {
		panic("can't modify a filter that was already queried")
	}
}

// Filter3 is a filter for 3 components.
// Used to create [Query3] iterators.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Filter2] for a usage example.
type Filter3[ any,  any,  any] struct {
	world        *World
	ids          []ID
	relations    []relationID
	components   []*componentStorage
	filter       filter
	mutex        sync.Mutex
	generation   uint32
	rareComp     uint8
	numRelations uint8
}

// New creates a new [Filter3]. It is safe to call on `nil` instance.
// It is a helper method, intended to avoid repeated listing of type parameters.
//
// See [Filter2.New] for an example.
func (*Filter3[, , ]) ( *World) *Filter3[, , ] {
	return NewFilter3[, , ]()
}

// NewFilter3 creates a new [Filter3].
//
// Use [Filter3.Query] to obtain a [Query3].
//
// See also [Filter3.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any]( *World) *Filter3[, , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	 := make([]*componentStorage, 3)
	[0] = &.storage.components[[0].id]
	[1] = &.storage.components[[1].id]
	[2] = &.storage.components[[2].id]
	return &Filter3[, , ]{
		world:      ,
		ids:        ,
		filter:     newFilter(...),
		components: ,
	}
}

// With specifies additional components to filter for.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter3[, , ]) ( ...Comp) *Filter3[, , ] {
	.checkModify()
	for ,  := range  {
		 := .world.componentID(.tp)
		.ids = append(.ids, )
		.filter.mask.Set(.id)
	}
	return 
}

// Without specifies components to exclude.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter3[, , ]) ( ...Comp) *Filter3[, , ] {
	.checkModify()
	if len() == 0 {
		return 
	}
	for ,  := range  {
		 := .world.componentID(.tp)
		.filter.without.Set(.id)
		.filter.hasWithout = true
	}
	return 
}

// Exclusive makes the filter exclusive in the sense that the component composition is matched exactly,
// and no other components are allowed. This includes components set via [Filter3.With].
//
// Overwrites components set via [Filter3.Without].
func ( *Filter3[, , ]) () *Filter3[, , ] {
	.checkModify()
	.filter = .filter.Exclusive()
	return 
}

// Relations sets permanent entity relation targets for this filter.
// Relation targets set here are included in filter caching.
// Contrary, relation targets specified in [Filter3.Query] or [Filter3.Batch] are not cached.
//
// Relation components used here must be in the filter's parameters
// or added via [Filter3.With] beforehand.
//
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter3[, , ]) ( ...Relation) *Filter3[, , ] {
	.checkModify()
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	.numRelations = uint8(len(.relations))
	return 
}

// Register this filter to the world's filter cache.
//
// Registering filters is optional.
// It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func ( *Filter3[, , ]) () *Filter3[, , ] {
	if .filter.cache != maxCacheID {
		panic("filter is already registered, can't register")
	}
	.world.storage.registerFilter(&.filter, .relations[:.numRelations])
	return 
}

// Unregister this filter from the world's filter cache.
func ( *Filter3[, , ]) () {
	if .filter.cache == maxCacheID {
		panic("filter is not registered, can't unregister")
	}
	.world.storage.unregisterFilter(&.filter)
}

// Query creates a [Query3] from this filter.
// This must be used each time before iterating a query.
//
// Relation targets provided here are added to those specified with [Filter3.Relations].
// Relation components must be in the filter's parameters or added via [Filter3.With] beforehand.
func ( *Filter3[, , ]) ( ...Relation) Query3[, , ] {
	 := relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], true)

	var  uint8
	var  *cacheEntry
	if .filter.cache != maxCacheID {
		 = .numRelations
		 = .world.storage.getRegisteredFilter(.filter.cache)
	} else {
		 := &.world.storage.registry
		 := .version
		if .generation !=  {
			.mutex.Lock()
			.rareComp = .rareComponent(.ids).id
			.generation = 
			.mutex.Unlock()
		}
	}

	return Query3[, , ]{
		world:      .world,
		filter:     &.filter,
		relations:  [:],
		cache:      ,
		lock:       .world.lockSafe(),
		components: .components,
		cursor: cursor{
			archetype: -1,
			table:     -1,
			index:     0,
			maxIndex:  -1,
		},
		rareComp:   .rareComp,
		columnPtrA: unsafe.Pointer(nilDummy),
		columnPtrB: unsafe.Pointer(nilDummy),
		columnPtrC: unsafe.Pointer(nilDummy),
	}
}

// Batch creates a [Batch] from this filter.
//
// Relation targets provided here are added to those specified with [Filter3.Relations].
// Relation components must be in the filter's parameters or added via [Filter3.With] beforehand.
//
// ⚠️ The returned [Batch] filter should not be stored, but used immediately and re-generated
// each time a batch operation is called.
// Otherwise, changes to the origin filter or calls to [Filter3.Batch] or [Filter3.Query]
// with different relationship targets may modify stored instances.
func ( *Filter3[, , ]) ( ...Relation) Batch {
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	var  uint8
	if .filter.cache != maxCacheID {
		 = .numRelations
	}
	return Batch{
		filter:    &.filter,
		relations: .relations[:],
	}
}

func ( *Filter3[, , ]) () {
	if .filter.cache != maxCacheID {
		panic("can't modify a cached filter")
	}
	if .generation != 0 {
		panic("can't modify a filter that was already queried")
	}
}

// Filter4 is a filter for 4 components.
// Used to create [Query4] iterators.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Filter2] for a usage example.
type Filter4[ any,  any,  any,  any] struct {
	world        *World
	ids          []ID
	relations    []relationID
	components   []*componentStorage
	filter       filter
	mutex        sync.Mutex
	generation   uint32
	rareComp     uint8
	numRelations uint8
}

// New creates a new [Filter4]. It is safe to call on `nil` instance.
// It is a helper method, intended to avoid repeated listing of type parameters.
//
// See [Filter2.New] for an example.
func (*Filter4[, , , ]) ( *World) *Filter4[, , , ] {
	return NewFilter4[, , , ]()
}

// NewFilter4 creates a new [Filter4].
//
// Use [Filter4.Query] to obtain a [Query4].
//
// See also [Filter4.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any]( *World) *Filter4[, , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	 := make([]*componentStorage, 4)
	[0] = &.storage.components[[0].id]
	[1] = &.storage.components[[1].id]
	[2] = &.storage.components[[2].id]
	[3] = &.storage.components[[3].id]
	return &Filter4[, , , ]{
		world:      ,
		ids:        ,
		filter:     newFilter(...),
		components: ,
	}
}

// With specifies additional components to filter for.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter4[, , , ]) ( ...Comp) *Filter4[, , , ] {
	.checkModify()
	for ,  := range  {
		 := .world.componentID(.tp)
		.ids = append(.ids, )
		.filter.mask.Set(.id)
	}
	return 
}

// Without specifies components to exclude.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter4[, , , ]) ( ...Comp) *Filter4[, , , ] {
	.checkModify()
	if len() == 0 {
		return 
	}
	for ,  := range  {
		 := .world.componentID(.tp)
		.filter.without.Set(.id)
		.filter.hasWithout = true
	}
	return 
}

// Exclusive makes the filter exclusive in the sense that the component composition is matched exactly,
// and no other components are allowed. This includes components set via [Filter4.With].
//
// Overwrites components set via [Filter4.Without].
func ( *Filter4[, , , ]) () *Filter4[, , , ] {
	.checkModify()
	.filter = .filter.Exclusive()
	return 
}

// Relations sets permanent entity relation targets for this filter.
// Relation targets set here are included in filter caching.
// Contrary, relation targets specified in [Filter4.Query] or [Filter4.Batch] are not cached.
//
// Relation components used here must be in the filter's parameters
// or added via [Filter4.With] beforehand.
//
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter4[, , , ]) ( ...Relation) *Filter4[, , , ] {
	.checkModify()
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	.numRelations = uint8(len(.relations))
	return 
}

// Register this filter to the world's filter cache.
//
// Registering filters is optional.
// It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func ( *Filter4[, , , ]) () *Filter4[, , , ] {
	if .filter.cache != maxCacheID {
		panic("filter is already registered, can't register")
	}
	.world.storage.registerFilter(&.filter, .relations[:.numRelations])
	return 
}

// Unregister this filter from the world's filter cache.
func ( *Filter4[, , , ]) () {
	if .filter.cache == maxCacheID {
		panic("filter is not registered, can't unregister")
	}
	.world.storage.unregisterFilter(&.filter)
}

// Query creates a [Query4] from this filter.
// This must be used each time before iterating a query.
//
// Relation targets provided here are added to those specified with [Filter4.Relations].
// Relation components must be in the filter's parameters or added via [Filter4.With] beforehand.
func ( *Filter4[, , , ]) ( ...Relation) Query4[, , , ] {
	 := relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], true)

	var  uint8
	var  *cacheEntry
	if .filter.cache != maxCacheID {
		 = .numRelations
		 = .world.storage.getRegisteredFilter(.filter.cache)
	} else {
		 := &.world.storage.registry
		 := .version
		if .generation !=  {
			.mutex.Lock()
			.rareComp = .rareComponent(.ids).id
			.generation = 
			.mutex.Unlock()
		}
	}

	return Query4[, , , ]{
		world:      .world,
		filter:     &.filter,
		relations:  [:],
		cache:      ,
		lock:       .world.lockSafe(),
		components: .components,
		cursor: cursor{
			archetype: -1,
			table:     -1,
			index:     0,
			maxIndex:  -1,
		},
		rareComp:   .rareComp,
		columnPtrA: unsafe.Pointer(nilDummy),
		columnPtrB: unsafe.Pointer(nilDummy),
		columnPtrC: unsafe.Pointer(nilDummy),
		columnPtrD: unsafe.Pointer(nilDummy),
	}
}

// Batch creates a [Batch] from this filter.
//
// Relation targets provided here are added to those specified with [Filter4.Relations].
// Relation components must be in the filter's parameters or added via [Filter4.With] beforehand.
//
// ⚠️ The returned [Batch] filter should not be stored, but used immediately and re-generated
// each time a batch operation is called.
// Otherwise, changes to the origin filter or calls to [Filter4.Batch] or [Filter4.Query]
// with different relationship targets may modify stored instances.
func ( *Filter4[, , , ]) ( ...Relation) Batch {
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	var  uint8
	if .filter.cache != maxCacheID {
		 = .numRelations
	}
	return Batch{
		filter:    &.filter,
		relations: .relations[:],
	}
}

func ( *Filter4[, , , ]) () {
	if .filter.cache != maxCacheID {
		panic("can't modify a cached filter")
	}
	if .generation != 0 {
		panic("can't modify a filter that was already queried")
	}
}

// Filter5 is a filter for 5 components.
// Used to create [Query5] iterators.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Filter2] for a usage example.
type Filter5[ any,  any,  any,  any,  any] struct {
	world        *World
	ids          []ID
	relations    []relationID
	components   []*componentStorage
	filter       filter
	mutex        sync.Mutex
	generation   uint32
	rareComp     uint8
	numRelations uint8
}

// New creates a new [Filter5]. It is safe to call on `nil` instance.
// It is a helper method, intended to avoid repeated listing of type parameters.
//
// See [Filter2.New] for an example.
func (*Filter5[, , , , ]) ( *World) *Filter5[, , , , ] {
	return NewFilter5[, , , , ]()
}

// NewFilter5 creates a new [Filter5].
//
// Use [Filter5.Query] to obtain a [Query5].
//
// See also [Filter5.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any,  any]( *World) *Filter5[, , , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	 := make([]*componentStorage, 5)
	[0] = &.storage.components[[0].id]
	[1] = &.storage.components[[1].id]
	[2] = &.storage.components[[2].id]
	[3] = &.storage.components[[3].id]
	[4] = &.storage.components[[4].id]
	return &Filter5[, , , , ]{
		world:      ,
		ids:        ,
		filter:     newFilter(...),
		components: ,
	}
}

// With specifies additional components to filter for.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter5[, , , , ]) ( ...Comp) *Filter5[, , , , ] {
	.checkModify()
	for ,  := range  {
		 := .world.componentID(.tp)
		.ids = append(.ids, )
		.filter.mask.Set(.id)
	}
	return 
}

// Without specifies components to exclude.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter5[, , , , ]) ( ...Comp) *Filter5[, , , , ] {
	.checkModify()
	if len() == 0 {
		return 
	}
	for ,  := range  {
		 := .world.componentID(.tp)
		.filter.without.Set(.id)
		.filter.hasWithout = true
	}
	return 
}

// Exclusive makes the filter exclusive in the sense that the component composition is matched exactly,
// and no other components are allowed. This includes components set via [Filter5.With].
//
// Overwrites components set via [Filter5.Without].
func ( *Filter5[, , , , ]) () *Filter5[, , , , ] {
	.checkModify()
	.filter = .filter.Exclusive()
	return 
}

// Relations sets permanent entity relation targets for this filter.
// Relation targets set here are included in filter caching.
// Contrary, relation targets specified in [Filter5.Query] or [Filter5.Batch] are not cached.
//
// Relation components used here must be in the filter's parameters
// or added via [Filter5.With] beforehand.
//
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter5[, , , , ]) ( ...Relation) *Filter5[, , , , ] {
	.checkModify()
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	.numRelations = uint8(len(.relations))
	return 
}

// Register this filter to the world's filter cache.
//
// Registering filters is optional.
// It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func ( *Filter5[, , , , ]) () *Filter5[, , , , ] {
	if .filter.cache != maxCacheID {
		panic("filter is already registered, can't register")
	}
	.world.storage.registerFilter(&.filter, .relations[:.numRelations])
	return 
}

// Unregister this filter from the world's filter cache.
func ( *Filter5[, , , , ]) () {
	if .filter.cache == maxCacheID {
		panic("filter is not registered, can't unregister")
	}
	.world.storage.unregisterFilter(&.filter)
}

// Query creates a [Query5] from this filter.
// This must be used each time before iterating a query.
//
// Relation targets provided here are added to those specified with [Filter5.Relations].
// Relation components must be in the filter's parameters or added via [Filter5.With] beforehand.
func ( *Filter5[, , , , ]) ( ...Relation) Query5[, , , , ] {
	 := relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], true)

	var  uint8
	var  *cacheEntry
	if .filter.cache != maxCacheID {
		 = .numRelations
		 = .world.storage.getRegisteredFilter(.filter.cache)
	} else {
		 := &.world.storage.registry
		 := .version
		if .generation !=  {
			.mutex.Lock()
			.rareComp = .rareComponent(.ids).id
			.generation = 
			.mutex.Unlock()
		}
	}

	return Query5[, , , , ]{
		world:      .world,
		filter:     &.filter,
		relations:  [:],
		cache:      ,
		lock:       .world.lockSafe(),
		components: .components,
		cursor: cursor{
			archetype: -1,
			table:     -1,
			index:     0,
			maxIndex:  -1,
		},
		rareComp:   .rareComp,
		columnPtrA: unsafe.Pointer(nilDummy),
		columnPtrB: unsafe.Pointer(nilDummy),
		columnPtrC: unsafe.Pointer(nilDummy),
		columnPtrD: unsafe.Pointer(nilDummy),
		columnPtrE: unsafe.Pointer(nilDummy),
	}
}

// Batch creates a [Batch] from this filter.
//
// Relation targets provided here are added to those specified with [Filter5.Relations].
// Relation components must be in the filter's parameters or added via [Filter5.With] beforehand.
//
// ⚠️ The returned [Batch] filter should not be stored, but used immediately and re-generated
// each time a batch operation is called.
// Otherwise, changes to the origin filter or calls to [Filter5.Batch] or [Filter5.Query]
// with different relationship targets may modify stored instances.
func ( *Filter5[, , , , ]) ( ...Relation) Batch {
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	var  uint8
	if .filter.cache != maxCacheID {
		 = .numRelations
	}
	return Batch{
		filter:    &.filter,
		relations: .relations[:],
	}
}

func ( *Filter5[, , , , ]) () {
	if .filter.cache != maxCacheID {
		panic("can't modify a cached filter")
	}
	if .generation != 0 {
		panic("can't modify a filter that was already queried")
	}
}

// Filter6 is a filter for 6 components.
// Used to create [Query6] iterators.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Filter2] for a usage example.
type Filter6[ any,  any,  any,  any,  any,  any] struct {
	world        *World
	ids          []ID
	relations    []relationID
	components   []*componentStorage
	filter       filter
	mutex        sync.Mutex
	generation   uint32
	rareComp     uint8
	numRelations uint8
}

// New creates a new [Filter6]. It is safe to call on `nil` instance.
// It is a helper method, intended to avoid repeated listing of type parameters.
//
// See [Filter2.New] for an example.
func (*Filter6[, , , , , ]) ( *World) *Filter6[, , , , , ] {
	return NewFilter6[, , , , , ]()
}

// NewFilter6 creates a new [Filter6].
//
// Use [Filter6.Query] to obtain a [Query6].
//
// See also [Filter6.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any,  any,  any]( *World) *Filter6[, , , , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	 := make([]*componentStorage, 6)
	[0] = &.storage.components[[0].id]
	[1] = &.storage.components[[1].id]
	[2] = &.storage.components[[2].id]
	[3] = &.storage.components[[3].id]
	[4] = &.storage.components[[4].id]
	[5] = &.storage.components[[5].id]
	return &Filter6[, , , , , ]{
		world:      ,
		ids:        ,
		filter:     newFilter(...),
		components: ,
	}
}

// With specifies additional components to filter for.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter6[, , , , , ]) ( ...Comp) *Filter6[, , , , , ] {
	.checkModify()
	for ,  := range  {
		 := .world.componentID(.tp)
		.ids = append(.ids, )
		.filter.mask.Set(.id)
	}
	return 
}

// Without specifies components to exclude.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter6[, , , , , ]) ( ...Comp) *Filter6[, , , , , ] {
	.checkModify()
	if len() == 0 {
		return 
	}
	for ,  := range  {
		 := .world.componentID(.tp)
		.filter.without.Set(.id)
		.filter.hasWithout = true
	}
	return 
}

// Exclusive makes the filter exclusive in the sense that the component composition is matched exactly,
// and no other components are allowed. This includes components set via [Filter6.With].
//
// Overwrites components set via [Filter6.Without].
func ( *Filter6[, , , , , ]) () *Filter6[, , , , , ] {
	.checkModify()
	.filter = .filter.Exclusive()
	return 
}

// Relations sets permanent entity relation targets for this filter.
// Relation targets set here are included in filter caching.
// Contrary, relation targets specified in [Filter6.Query] or [Filter6.Batch] are not cached.
//
// Relation components used here must be in the filter's parameters
// or added via [Filter6.With] beforehand.
//
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter6[, , , , , ]) ( ...Relation) *Filter6[, , , , , ] {
	.checkModify()
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	.numRelations = uint8(len(.relations))
	return 
}

// Register this filter to the world's filter cache.
//
// Registering filters is optional.
// It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func ( *Filter6[, , , , , ]) () *Filter6[, , , , , ] {
	if .filter.cache != maxCacheID {
		panic("filter is already registered, can't register")
	}
	.world.storage.registerFilter(&.filter, .relations[:.numRelations])
	return 
}

// Unregister this filter from the world's filter cache.
func ( *Filter6[, , , , , ]) () {
	if .filter.cache == maxCacheID {
		panic("filter is not registered, can't unregister")
	}
	.world.storage.unregisterFilter(&.filter)
}

// Query creates a [Query6] from this filter.
// This must be used each time before iterating a query.
//
// Relation targets provided here are added to those specified with [Filter6.Relations].
// Relation components must be in the filter's parameters or added via [Filter6.With] beforehand.
func ( *Filter6[, , , , , ]) ( ...Relation) Query6[, , , , , ] {
	 := relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], true)

	var  uint8
	var  *cacheEntry
	if .filter.cache != maxCacheID {
		 = .numRelations
		 = .world.storage.getRegisteredFilter(.filter.cache)
	} else {
		 := &.world.storage.registry
		 := .version
		if .generation !=  {
			.mutex.Lock()
			.rareComp = .rareComponent(.ids).id
			.generation = 
			.mutex.Unlock()
		}
	}

	return Query6[, , , , , ]{
		world:      .world,
		filter:     &.filter,
		relations:  [:],
		cache:      ,
		lock:       .world.lockSafe(),
		components: .components,
		cursor: cursor{
			archetype: -1,
			table:     -1,
			index:     0,
			maxIndex:  -1,
		},
		rareComp:   .rareComp,
		columnPtrA: unsafe.Pointer(nilDummy),
		columnPtrB: unsafe.Pointer(nilDummy),
		columnPtrC: unsafe.Pointer(nilDummy),
		columnPtrD: unsafe.Pointer(nilDummy),
		columnPtrE: unsafe.Pointer(nilDummy),
		columnPtrF: unsafe.Pointer(nilDummy),
	}
}

// Batch creates a [Batch] from this filter.
//
// Relation targets provided here are added to those specified with [Filter6.Relations].
// Relation components must be in the filter's parameters or added via [Filter6.With] beforehand.
//
// ⚠️ The returned [Batch] filter should not be stored, but used immediately and re-generated
// each time a batch operation is called.
// Otherwise, changes to the origin filter or calls to [Filter6.Batch] or [Filter6.Query]
// with different relationship targets may modify stored instances.
func ( *Filter6[, , , , , ]) ( ...Relation) Batch {
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	var  uint8
	if .filter.cache != maxCacheID {
		 = .numRelations
	}
	return Batch{
		filter:    &.filter,
		relations: .relations[:],
	}
}

func ( *Filter6[, , , , , ]) () {
	if .filter.cache != maxCacheID {
		panic("can't modify a cached filter")
	}
	if .generation != 0 {
		panic("can't modify a filter that was already queried")
	}
}

// Filter7 is a filter for 7 components.
// Used to create [Query7] iterators.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Filter2] for a usage example.
type Filter7[ any,  any,  any,  any,  any,  any,  any] struct {
	world        *World
	ids          []ID
	relations    []relationID
	components   []*componentStorage
	filter       filter
	mutex        sync.Mutex
	generation   uint32
	rareComp     uint8
	numRelations uint8
}

// New creates a new [Filter7]. It is safe to call on `nil` instance.
// It is a helper method, intended to avoid repeated listing of type parameters.
//
// See [Filter2.New] for an example.
func (*Filter7[, , , , , , ]) ( *World) *Filter7[, , , , , , ] {
	return NewFilter7[, , , , , , ]()
}

// NewFilter7 creates a new [Filter7].
//
// Use [Filter7.Query] to obtain a [Query7].
//
// See also [Filter7.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any,  any,  any,  any]( *World) *Filter7[, , , , , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	 := make([]*componentStorage, 7)
	[0] = &.storage.components[[0].id]
	[1] = &.storage.components[[1].id]
	[2] = &.storage.components[[2].id]
	[3] = &.storage.components[[3].id]
	[4] = &.storage.components[[4].id]
	[5] = &.storage.components[[5].id]
	[6] = &.storage.components[[6].id]
	return &Filter7[, , , , , , ]{
		world:      ,
		ids:        ,
		filter:     newFilter(...),
		components: ,
	}
}

// With specifies additional components to filter for.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter7[, , , , , , ]) ( ...Comp) *Filter7[, , , , , , ] {
	.checkModify()
	for ,  := range  {
		 := .world.componentID(.tp)
		.ids = append(.ids, )
		.filter.mask.Set(.id)
	}
	return 
}

// Without specifies components to exclude.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter7[, , , , , , ]) ( ...Comp) *Filter7[, , , , , , ] {
	.checkModify()
	if len() == 0 {
		return 
	}
	for ,  := range  {
		 := .world.componentID(.tp)
		.filter.without.Set(.id)
		.filter.hasWithout = true
	}
	return 
}

// Exclusive makes the filter exclusive in the sense that the component composition is matched exactly,
// and no other components are allowed. This includes components set via [Filter7.With].
//
// Overwrites components set via [Filter7.Without].
func ( *Filter7[, , , , , , ]) () *Filter7[, , , , , , ] {
	.checkModify()
	.filter = .filter.Exclusive()
	return 
}

// Relations sets permanent entity relation targets for this filter.
// Relation targets set here are included in filter caching.
// Contrary, relation targets specified in [Filter7.Query] or [Filter7.Batch] are not cached.
//
// Relation components used here must be in the filter's parameters
// or added via [Filter7.With] beforehand.
//
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter7[, , , , , , ]) ( ...Relation) *Filter7[, , , , , , ] {
	.checkModify()
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	.numRelations = uint8(len(.relations))
	return 
}

// Register this filter to the world's filter cache.
//
// Registering filters is optional.
// It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func ( *Filter7[, , , , , , ]) () *Filter7[, , , , , , ] {
	if .filter.cache != maxCacheID {
		panic("filter is already registered, can't register")
	}
	.world.storage.registerFilter(&.filter, .relations[:.numRelations])
	return 
}

// Unregister this filter from the world's filter cache.
func ( *Filter7[, , , , , , ]) () {
	if .filter.cache == maxCacheID {
		panic("filter is not registered, can't unregister")
	}
	.world.storage.unregisterFilter(&.filter)
}

// Query creates a [Query7] from this filter.
// This must be used each time before iterating a query.
//
// Relation targets provided here are added to those specified with [Filter7.Relations].
// Relation components must be in the filter's parameters or added via [Filter7.With] beforehand.
func ( *Filter7[, , , , , , ]) ( ...Relation) Query7[, , , , , , ] {
	 := relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], true)

	var  uint8
	var  *cacheEntry
	if .filter.cache != maxCacheID {
		 = .numRelations
		 = .world.storage.getRegisteredFilter(.filter.cache)
	} else {
		 := &.world.storage.registry
		 := .version
		if .generation !=  {
			.mutex.Lock()
			.rareComp = .rareComponent(.ids).id
			.generation = 
			.mutex.Unlock()
		}
	}

	return Query7[, , , , , , ]{
		world:      .world,
		filter:     &.filter,
		relations:  [:],
		cache:      ,
		lock:       .world.lockSafe(),
		components: .components,
		cursor: cursor{
			archetype: -1,
			table:     -1,
			index:     0,
			maxIndex:  -1,
		},
		rareComp:   .rareComp,
		columnPtrA: unsafe.Pointer(nilDummy),
		columnPtrB: unsafe.Pointer(nilDummy),
		columnPtrC: unsafe.Pointer(nilDummy),
		columnPtrD: unsafe.Pointer(nilDummy),
		columnPtrE: unsafe.Pointer(nilDummy),
		columnPtrF: unsafe.Pointer(nilDummy),
		columnPtrG: unsafe.Pointer(nilDummy),
	}
}

// Batch creates a [Batch] from this filter.
//
// Relation targets provided here are added to those specified with [Filter7.Relations].
// Relation components must be in the filter's parameters or added via [Filter7.With] beforehand.
//
// ⚠️ The returned [Batch] filter should not be stored, but used immediately and re-generated
// each time a batch operation is called.
// Otherwise, changes to the origin filter or calls to [Filter7.Batch] or [Filter7.Query]
// with different relationship targets may modify stored instances.
func ( *Filter7[, , , , , , ]) ( ...Relation) Batch {
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	var  uint8
	if .filter.cache != maxCacheID {
		 = .numRelations
	}
	return Batch{
		filter:    &.filter,
		relations: .relations[:],
	}
}

func ( *Filter7[, , , , , , ]) () {
	if .filter.cache != maxCacheID {
		panic("can't modify a cached filter")
	}
	if .generation != 0 {
		panic("can't modify a filter that was already queried")
	}
}

// Filter8 is a filter for 8 components.
// Used to create [Query8] iterators.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Filter2] for a usage example.
type Filter8[ any,  any,  any,  any,  any,  any,  any,  any] struct {
	world        *World
	ids          []ID
	relations    []relationID
	components   []*componentStorage
	filter       filter
	mutex        sync.Mutex
	generation   uint32
	rareComp     uint8
	numRelations uint8
}

// New creates a new [Filter8]. It is safe to call on `nil` instance.
// It is a helper method, intended to avoid repeated listing of type parameters.
//
// See [Filter2.New] for an example.
func (*Filter8[, , , , , , , ]) ( *World) *Filter8[, , , , , , , ] {
	return NewFilter8[, , , , , , , ]()
}

// NewFilter8 creates a new [Filter8].
//
// Use [Filter8.Query] to obtain a [Query8].
//
// See also [Filter8.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any,  any,  any,  any,  any]( *World) *Filter8[, , , , , , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	 := make([]*componentStorage, 8)
	[0] = &.storage.components[[0].id]
	[1] = &.storage.components[[1].id]
	[2] = &.storage.components[[2].id]
	[3] = &.storage.components[[3].id]
	[4] = &.storage.components[[4].id]
	[5] = &.storage.components[[5].id]
	[6] = &.storage.components[[6].id]
	[7] = &.storage.components[[7].id]
	return &Filter8[, , , , , , , ]{
		world:      ,
		ids:        ,
		filter:     newFilter(...),
		components: ,
	}
}

// With specifies additional components to filter for.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter8[, , , , , , , ]) ( ...Comp) *Filter8[, , , , , , , ] {
	.checkModify()
	for ,  := range  {
		 := .world.componentID(.tp)
		.ids = append(.ids, )
		.filter.mask.Set(.id)
	}
	return 
}

// Without specifies components to exclude.
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter8[, , , , , , , ]) ( ...Comp) *Filter8[, , , , , , , ] {
	.checkModify()
	if len() == 0 {
		return 
	}
	for ,  := range  {
		 := .world.componentID(.tp)
		.filter.without.Set(.id)
		.filter.hasWithout = true
	}
	return 
}

// Exclusive makes the filter exclusive in the sense that the component composition is matched exactly,
// and no other components are allowed. This includes components set via [Filter8.With].
//
// Overwrites components set via [Filter8.Without].
func ( *Filter8[, , , , , , , ]) () *Filter8[, , , , , , , ] {
	.checkModify()
	.filter = .filter.Exclusive()
	return 
}

// Relations sets permanent entity relation targets for this filter.
// Relation targets set here are included in filter caching.
// Contrary, relation targets specified in [Filter8.Query] or [Filter8.Batch] are not cached.
//
// Relation components used here must be in the filter's parameters
// or added via [Filter8.With] beforehand.
//
// Can be called multiple times in chains, or once with multiple arguments.
func ( *Filter8[, , , , , , , ]) ( ...Relation) *Filter8[, , , , , , , ] {
	.checkModify()
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	.numRelations = uint8(len(.relations))
	return 
}

// Register this filter to the world's filter cache.
//
// Registering filters is optional.
// It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func ( *Filter8[, , , , , , , ]) () *Filter8[, , , , , , , ] {
	if .filter.cache != maxCacheID {
		panic("filter is already registered, can't register")
	}
	.world.storage.registerFilter(&.filter, .relations[:.numRelations])
	return 
}

// Unregister this filter from the world's filter cache.
func ( *Filter8[, , , , , , , ]) () {
	if .filter.cache == maxCacheID {
		panic("filter is not registered, can't unregister")
	}
	.world.storage.unregisterFilter(&.filter)
}

// Query creates a [Query8] from this filter.
// This must be used each time before iterating a query.
//
// Relation targets provided here are added to those specified with [Filter8.Relations].
// Relation components must be in the filter's parameters or added via [Filter8.With] beforehand.
func ( *Filter8[, , , , , , , ]) ( ...Relation) Query8[, , , , , , , ] {
	 := relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], true)

	var  uint8
	var  *cacheEntry
	if .filter.cache != maxCacheID {
		 = .numRelations
		 = .world.storage.getRegisteredFilter(.filter.cache)
	} else {
		 := &.world.storage.registry
		 := .version
		if .generation !=  {
			.mutex.Lock()
			.rareComp = .rareComponent(.ids).id
			.generation = 
			.mutex.Unlock()
		}
	}

	return Query8[, , , , , , , ]{
		world:      .world,
		filter:     &.filter,
		relations:  [:],
		cache:      ,
		lock:       .world.lockSafe(),
		components: .components,
		cursor: cursor{
			archetype: -1,
			table:     -1,
			index:     0,
			maxIndex:  -1,
		},
		rareComp:   .rareComp,
		columnPtrA: unsafe.Pointer(nilDummy),
		columnPtrB: unsafe.Pointer(nilDummy),
		columnPtrC: unsafe.Pointer(nilDummy),
		columnPtrD: unsafe.Pointer(nilDummy),
		columnPtrE: unsafe.Pointer(nilDummy),
		columnPtrF: unsafe.Pointer(nilDummy),
		columnPtrG: unsafe.Pointer(nilDummy),
		columnPtrH: unsafe.Pointer(nilDummy),
	}
}

// Batch creates a [Batch] from this filter.
//
// Relation targets provided here are added to those specified with [Filter8.Relations].
// Relation components must be in the filter's parameters or added via [Filter8.With] beforehand.
//
// ⚠️ The returned [Batch] filter should not be stored, but used immediately and re-generated
// each time a batch operation is called.
// Otherwise, changes to the origin filter or calls to [Filter8.Batch] or [Filter8.Query]
// with different relationship targets may modify stored instances.
func ( *Filter8[, , , , , , , ]) ( ...Relation) Batch {
	.relations = relationSlice().ToRelations(.world, &.filter.mask, .ids, .relations[:.numRelations], false)
	var  uint8
	if .filter.cache != maxCacheID {
		 = .numRelations
	}
	return Batch{
		filter:    &.filter,
		relations: .relations[:],
	}
}

func ( *Filter8[, , , , , , , ]) () {
	if .filter.cache != maxCacheID {
		panic("can't modify a cached filter")
	}
	if .generation != 0 {
		panic("can't modify a filter that was already queried")
	}
}