package ecs

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

// Map1 is a mapper to access 1 components of an entity.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Map2] for a usage example.
type Map1[ any] struct {
	mask      bitMask
	ids       []ID
	relations []relationID
	world     *World
	storageA  *componentStorage
	archetype archetypeID
}

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

// NewMap1 creates a new [Map1].
//
// See also [Map1.New] for a shortcut when constructing an already defined instance.
func [ any]( *World) *Map1[] {
	 := []ID{
		ComponentID[](),
	}
	return &Map1[]{
		world:    ,
		ids:      ,
		mask:     newMask(...),
		storageA: &.storage.components[[0].id],
	}
}

// NewEntity creates a new entity with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map1[]) ( *,  ...Relation) Entity {
	return .NewEntityFn(func( *) {
		* = *
	}, ...)
}

// NewEntityFn creates a new entity with the mapped component and runs a callback instead of using a component for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map1[]) ( func(*),  ...Relation) Entity {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntity(.ids, .relations, .archetype)
	.archetype = 

	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireCreateEntityIfHas(, )
	if len() > 0 {
		.world.storage.observers.FireCreateEntityRelIfHas(, )
	}
	return 
}

// NewBatch creates a batch of new entities with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map1[]) ( int,  *,  ...Relation) {
	.NewBatchFn(, func( Entity,  *) {
		* = *
	}, ...)
}

// NewBatchFn creates a batch of new entities with the mapped components, running the given initializer function on each.
// The initializer function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map1[]) ( int,  func(Entity, *),  ...Relation) {
	.world.checkLocked()
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntities(, .ids, .relations, .archetype)
	.archetype = 

	 := .world.storage.observers.HasObservers(OnCreateEntity)
	 := len() > 0 && .world.storage.observers.HasObservers(OnAddRelations)
	 :=  ||  ||  != nil
	var  uint8
	if  {
		 = .world.lock()
	}

	if  != nil {
		 := &.world.storage.tables[]
		 := .storageA.columns[]
		for  := range  {
			 := uintptr( + )
			(
				.GetEntity(),
				(*)(.Get()),
			)
		}
	}

	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityBatch(, , &.mask)
	}
	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityRelBatch(, , &.mask)
	}

	if  {
		.world.unlock()
	}
}

// Get returns the mapped components for the given entity.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map1[]) ( Entity) * {
	if !.world.storage.entityPool.Alive() {
		panic("can't get components of a dead entity")
	}
	 := &.world.storage.entities[.id]
	return get[](.storageA, )
}

// GetUnchecked returns the mapped components for the given entity.
// In contrast to [Map1.Get], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map1[]) ( Entity) * {
	 := &.world.storage.entities[.id]
	return get[](.storageA, )
}

// HasAll return whether the given entity has all mapped components.
//
// Using [Map1.Get] and checking for nil pointer may be faster
// than calling [Map1.HasAll] and [Map1.Get] subsequently.
func ( *Map1[]) ( Entity) bool {
	if !.world.Alive() {
		panic("can't check components of a dead entity")
	}
	 := .world.storage.entities[.id].table
	return .storageA.columns[] != nil
}

// Add the mapped components to the given entity.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map1[]) ( Entity,  *,  ...Relation) {
	.AddFn(, func( *) {
		* = *
	}, ...)
}

// AddFn adds the mapped components to the given entity and runs a callback instead of using components for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map1[]) ( Entity,  func(*),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	,  := .world.add(, .ids, .relations)
	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireAddIfHas(OnAddComponents, , , )
	if len() > 0 {
		.world.storage.observers.FireAddIfHas(OnAddRelations, , , )
	}
}

// Set the mapped components of the given entity to the given values.
// Requires the entity to already have all the mapped components.
//
// Triggers an OnSetComponents event, which is not the case when assigning by
// pointer dereference or assigning to fields. This can be used to notify observers
// about component updates.
//
// This is not a component operation, so it can be performed on a locked world.
func ( *Map1[]) ( Entity,  *) {
	if !.world.Alive() {
		panic("can't set components of a dead entity")
	}
	.world.storage.checkHasComponent(, .ids[0])

	 := &.world.storage.entities[.id]
	 := uintptr(.row)
	*(*)(.storageA.columns[.table].Get()) = *

	if .world.storage.observers.HasObservers(OnSetComponents) {
		 := &.world.storage.archetypes[.world.storage.tables[.table].archetype].mask
		.world.storage.observers.FireSet(, &.mask, )
	}
}

// AddBatch adds the mapped components to all entities matching the given batch filter.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map1[]) ( Batch,  *,  ...Relation) {
	.AddBatchFn(, func( Entity,  *) {
		* = *
	}, ...)
}

// AddBatchFn adds the mapped components to all entities matching the given batch filter,
// running the given function on each. The function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map1[]) ( Batch,  func(Entity, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)

	var  func( tableID, ,  uint32)
	if  != nil {
		 = func( tableID, ,  uint32) {
			 := &.world.storage.tables[]
			 := .storageA.columns[]

			for  := range  {
				 := uintptr( + )
				(
					.GetEntity(),
					(*)(.Get()),
				)
			}
		}
	}
	.world.exchangeBatch(&, .ids, nil, .relations, )
}

// Remove the mapped components from the given entity.
func ( *Map1[]) ( Entity) {
	.world.remove(, .ids)
}

// RemoveBatch removes the mapped components from all entities matching the given batch filter,
// running the given function on each. The function can be nil.
func ( *Map1[]) ( Batch,  func( Entity)) {
	removeBatch(.world, &, .ids, )
}

// GetRelation returns the relation target of an entity for the component at the given index.
func ( *Map1[]) ( Entity,  int) Entity {
	if !.world.storage.entityPool.Alive() {
		panic("can't get entity relation target for a dead entity")
	}
	return .GetRelationUnchecked(, )
}

// GetRelationUnchecked returns the relation target of an entity for the component at the given index.
// In contrast to [Map1.GetRelation], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
func ( *Map1[]) ( Entity,  int) Entity {
	return .world.storage.getRelation(, .ids[])
}

// SetRelations sets relation targets for the given entity.
func ( *Map1[]) ( Entity,  ...Relation) {
	// alive check is done in World.setRelations
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	.world.setRelations(, .relations)
}

// SetRelationsBatch sets relation targets for all entities matching the given batch filter.
func ( *Map1[]) ( Batch,  func( Entity),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	setRelationsBatch(.world, &, , .relations)
}

// Map2 is a mapper to access 2 components of an entity.
//
// Instances should be created during initialization and stored, e.g. in systems.
type Map2[ any,  any] struct {
	mask      bitMask
	ids       []ID
	relations []relationID
	world     *World
	storageA  *componentStorage
	storageB  *componentStorage
	archetype archetypeID
}

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

// NewMap2 creates a new [Map2].
//
// See also [Map2.New] for a shortcut when constructing an already defined instance.
func [ any,  any]( *World) *Map2[, ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
	}
	return &Map2[, ]{
		world:    ,
		ids:      ,
		mask:     newMask(...),
		storageA: &.storage.components[[0].id],
		storageB: &.storage.components[[1].id],
	}
}

// NewEntity creates a new entity with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map2[, ]) ( *,  *,  ...Relation) Entity {
	return .NewEntityFn(func( *,  *) {
		* = *
		* = *
	}, ...)
}

// NewEntityFn creates a new entity with the mapped component and runs a callback instead of using a component for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map2[, ]) ( func(*, *),  ...Relation) Entity {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntity(.ids, .relations, .archetype)
	.archetype = 

	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireCreateEntityIfHas(, )
	if len() > 0 {
		.world.storage.observers.FireCreateEntityRelIfHas(, )
	}
	return 
}

// NewBatch creates a batch of new entities with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map2[, ]) ( int,  *,  *,  ...Relation) {
	.NewBatchFn(, func( Entity,  *,  *) {
		* = *
		* = *
	}, ...)
}

// NewBatchFn creates a batch of new entities with the mapped components, running the given initializer function on each.
// The initializer function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map2[, ]) ( int,  func(Entity, *, *),  ...Relation) {
	.world.checkLocked()
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntities(, .ids, .relations, .archetype)
	.archetype = 

	 := .world.storage.observers.HasObservers(OnCreateEntity)
	 := len() > 0 && .world.storage.observers.HasObservers(OnAddRelations)
	 :=  ||  ||  != nil
	var  uint8
	if  {
		 = .world.lock()
	}

	if  != nil {
		 := &.world.storage.tables[]
		 := .storageA.columns[]
		 := .storageB.columns[]
		for  := range  {
			 := uintptr( + )
			(
				.GetEntity(),
				(*)(.Get()),
				(*)(.Get()),
			)
		}
	}

	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityBatch(, , &.mask)
	}
	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityRelBatch(, , &.mask)
	}

	if  {
		.world.unlock()
	}
}

// Get returns the mapped components for the given entity.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map2[, ]) ( Entity) (*, *) {
	if !.world.storage.entityPool.Alive() {
		panic("can't get components of a dead entity")
	}
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, )
}

// GetUnchecked returns the mapped components for the given entity.
// In contrast to [Map2.Get], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map2[, ]) ( Entity) (*, *) {
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, )
}

// HasAll return whether the given entity has all mapped components.
//
// Using [Map2.Get] and checking for nil pointer may be faster
// than calling [Map2.HasAll] and [Map2.Get] subsequently.
func ( *Map2[, ]) ( Entity) bool {
	if !.world.Alive() {
		panic("can't check components of a dead entity")
	}
	 := .world.storage.entities[.id].table
	return .storageA.columns[] != nil &&
		.storageB.columns[] != nil
}

// Add the mapped components to the given entity.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map2[, ]) ( Entity,  *,  *,  ...Relation) {
	.AddFn(, func( *,  *) {
		* = *
		* = *
	}, ...)
}

// AddFn adds the mapped components to the given entity and runs a callback instead of using components for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map2[, ]) ( Entity,  func(*, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	,  := .world.add(, .ids, .relations)
	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireAddIfHas(OnAddComponents, , , )
	if len() > 0 {
		.world.storage.observers.FireAddIfHas(OnAddRelations, , , )
	}
}

// Set the mapped components of the given entity to the given values.
// Requires the entity to already have all the mapped components.
//
// Triggers an OnSetComponents event, which is not the case when assigning by
// pointer dereference or assigning to fields. This can be used to notify observers
// about component updates.
//
// This is not a component operation, so it can be performed on a locked world.
func ( *Map2[, ]) ( Entity,  *,  *) {
	if !.world.Alive() {
		panic("can't set components of a dead entity")
	}
	.world.storage.checkHasComponent(, .ids[0])
	.world.storage.checkHasComponent(, .ids[1])

	 := &.world.storage.entities[.id]
	 := uintptr(.row)
	*(*)(.storageA.columns[.table].Get()) = *
	*(*)(.storageB.columns[.table].Get()) = *

	if .world.storage.observers.HasObservers(OnSetComponents) {
		 := &.world.storage.archetypes[.world.storage.tables[.table].archetype].mask
		.world.storage.observers.FireSet(, &.mask, )
	}
}

// AddBatch adds the mapped components to all entities matching the given batch filter.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map2[, ]) ( Batch,  *,  *,  ...Relation) {
	.AddBatchFn(, func( Entity,  *,  *) {
		* = *
		* = *
	}, ...)
}

// AddBatchFn adds the mapped components to all entities matching the given batch filter,
// running the given function on each. The function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map2[, ]) ( Batch,  func(Entity, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)

	var  func( tableID, ,  uint32)
	if  != nil {
		 = func( tableID, ,  uint32) {
			 := &.world.storage.tables[]
			 := .storageA.columns[]
			 := .storageB.columns[]

			for  := range  {
				 := uintptr( + )
				(
					.GetEntity(),
					(*)(.Get()),
					(*)(.Get()),
				)
			}
		}
	}
	.world.exchangeBatch(&, .ids, nil, .relations, )
}

// Remove the mapped components from the given entity.
func ( *Map2[, ]) ( Entity) {
	.world.remove(, .ids)
}

// RemoveBatch removes the mapped components from all entities matching the given batch filter,
// running the given function on each. The function can be nil.
func ( *Map2[, ]) ( Batch,  func( Entity)) {
	removeBatch(.world, &, .ids, )
}

// GetRelation returns the relation target of an entity for the component at the given index.
func ( *Map2[, ]) ( Entity,  int) Entity {
	if !.world.storage.entityPool.Alive() {
		panic("can't get entity relation target for a dead entity")
	}
	return .GetRelationUnchecked(, )
}

// GetRelationUnchecked returns the relation target of an entity for the component at the given index.
// In contrast to [Map2.GetRelation], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
func ( *Map2[, ]) ( Entity,  int) Entity {
	return .world.storage.getRelation(, .ids[])
}

// SetRelations sets relation targets for the given entity.
func ( *Map2[, ]) ( Entity,  ...Relation) {
	// alive check is done in World.setRelations
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	.world.setRelations(, .relations)
}

// SetRelationsBatch sets relation targets for all entities matching the given batch filter.
func ( *Map2[, ]) ( Batch,  func( Entity),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	setRelationsBatch(.world, &, , .relations)
}

// Map3 is a mapper to access 3 components of an entity.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Map2] for a usage example.
type Map3[ any,  any,  any] struct {
	mask      bitMask
	ids       []ID
	relations []relationID
	world     *World
	storageA  *componentStorage
	storageB  *componentStorage
	storageC  *componentStorage
	archetype archetypeID
}

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

// NewMap3 creates a new [Map3].
//
// See also [Map3.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any]( *World) *Map3[, , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	return &Map3[, , ]{
		world:    ,
		ids:      ,
		mask:     newMask(...),
		storageA: &.storage.components[[0].id],
		storageB: &.storage.components[[1].id],
		storageC: &.storage.components[[2].id],
	}
}

// NewEntity creates a new entity with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map3[, , ]) ( *,  *,  *,  ...Relation) Entity {
	return .NewEntityFn(func( *,  *,  *) {
		* = *
		* = *
		* = *
	}, ...)
}

// NewEntityFn creates a new entity with the mapped component and runs a callback instead of using a component for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map3[, , ]) ( func(*, *, *),  ...Relation) Entity {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntity(.ids, .relations, .archetype)
	.archetype = 

	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireCreateEntityIfHas(, )
	if len() > 0 {
		.world.storage.observers.FireCreateEntityRelIfHas(, )
	}
	return 
}

// NewBatch creates a batch of new entities with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map3[, , ]) ( int,  *,  *,  *,  ...Relation) {
	.NewBatchFn(, func( Entity,  *,  *,  *) {
		* = *
		* = *
		* = *
	}, ...)
}

// NewBatchFn creates a batch of new entities with the mapped components, running the given initializer function on each.
// The initializer function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map3[, , ]) ( int,  func(Entity, *, *, *),  ...Relation) {
	.world.checkLocked()
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntities(, .ids, .relations, .archetype)
	.archetype = 

	 := .world.storage.observers.HasObservers(OnCreateEntity)
	 := len() > 0 && .world.storage.observers.HasObservers(OnAddRelations)
	 :=  ||  ||  != nil
	var  uint8
	if  {
		 = .world.lock()
	}

	if  != nil {
		 := &.world.storage.tables[]
		 := .storageA.columns[]
		 := .storageB.columns[]
		 := .storageC.columns[]
		for  := range  {
			 := uintptr( + )
			(
				.GetEntity(),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
			)
		}
	}

	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityBatch(, , &.mask)
	}
	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityRelBatch(, , &.mask)
	}

	if  {
		.world.unlock()
	}
}

// Get returns the mapped components for the given entity.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map3[, , ]) ( Entity) (*, *, *) {
	if !.world.storage.entityPool.Alive() {
		panic("can't get components of a dead entity")
	}
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, )
}

// GetUnchecked returns the mapped components for the given entity.
// In contrast to [Map3.Get], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map3[, , ]) ( Entity) (*, *, *) {
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, )
}

// HasAll return whether the given entity has all mapped components.
//
// Using [Map3.Get] and checking for nil pointer may be faster
// than calling [Map3.HasAll] and [Map3.Get] subsequently.
func ( *Map3[, , ]) ( Entity) bool {
	if !.world.Alive() {
		panic("can't check components of a dead entity")
	}
	 := .world.storage.entities[.id].table
	return .storageA.columns[] != nil &&
		.storageB.columns[] != nil &&
		.storageC.columns[] != nil
}

// Add the mapped components to the given entity.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map3[, , ]) ( Entity,  *,  *,  *,  ...Relation) {
	.AddFn(, func( *,  *,  *) {
		* = *
		* = *
		* = *
	}, ...)
}

// AddFn adds the mapped components to the given entity and runs a callback instead of using components for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map3[, , ]) ( Entity,  func(*, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	,  := .world.add(, .ids, .relations)
	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireAddIfHas(OnAddComponents, , , )
	if len() > 0 {
		.world.storage.observers.FireAddIfHas(OnAddRelations, , , )
	}
}

// Set the mapped components of the given entity to the given values.
// Requires the entity to already have all the mapped components.
//
// Triggers an OnSetComponents event, which is not the case when assigning by
// pointer dereference or assigning to fields. This can be used to notify observers
// about component updates.
//
// This is not a component operation, so it can be performed on a locked world.
func ( *Map3[, , ]) ( Entity,  *,  *,  *) {
	if !.world.Alive() {
		panic("can't set components of a dead entity")
	}
	.world.storage.checkHasComponent(, .ids[0])
	.world.storage.checkHasComponent(, .ids[1])
	.world.storage.checkHasComponent(, .ids[2])

	 := &.world.storage.entities[.id]
	 := uintptr(.row)
	*(*)(.storageA.columns[.table].Get()) = *
	*(*)(.storageB.columns[.table].Get()) = *
	*(*)(.storageC.columns[.table].Get()) = *

	if .world.storage.observers.HasObservers(OnSetComponents) {
		 := &.world.storage.archetypes[.world.storage.tables[.table].archetype].mask
		.world.storage.observers.FireSet(, &.mask, )
	}
}

// AddBatch adds the mapped components to all entities matching the given batch filter.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map3[, , ]) ( Batch,  *,  *,  *,  ...Relation) {
	.AddBatchFn(, func( Entity,  *,  *,  *) {
		* = *
		* = *
		* = *
	}, ...)
}

// AddBatchFn adds the mapped components to all entities matching the given batch filter,
// running the given function on each. The function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map3[, , ]) ( Batch,  func(Entity, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)

	var  func( tableID, ,  uint32)
	if  != nil {
		 = func( tableID, ,  uint32) {
			 := &.world.storage.tables[]
			 := .storageA.columns[]
			 := .storageB.columns[]
			 := .storageC.columns[]

			for  := range  {
				 := uintptr( + )
				(
					.GetEntity(),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
				)
			}
		}
	}
	.world.exchangeBatch(&, .ids, nil, .relations, )
}

// Remove the mapped components from the given entity.
func ( *Map3[, , ]) ( Entity) {
	.world.remove(, .ids)
}

// RemoveBatch removes the mapped components from all entities matching the given batch filter,
// running the given function on each. The function can be nil.
func ( *Map3[, , ]) ( Batch,  func( Entity)) {
	removeBatch(.world, &, .ids, )
}

// GetRelation returns the relation target of an entity for the component at the given index.
func ( *Map3[, , ]) ( Entity,  int) Entity {
	if !.world.storage.entityPool.Alive() {
		panic("can't get entity relation target for a dead entity")
	}
	return .GetRelationUnchecked(, )
}

// GetRelationUnchecked returns the relation target of an entity for the component at the given index.
// In contrast to [Map3.GetRelation], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
func ( *Map3[, , ]) ( Entity,  int) Entity {
	return .world.storage.getRelation(, .ids[])
}

// SetRelations sets relation targets for the given entity.
func ( *Map3[, , ]) ( Entity,  ...Relation) {
	// alive check is done in World.setRelations
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	.world.setRelations(, .relations)
}

// SetRelationsBatch sets relation targets for all entities matching the given batch filter.
func ( *Map3[, , ]) ( Batch,  func( Entity),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	setRelationsBatch(.world, &, , .relations)
}

// Map4 is a mapper to access 4 components of an entity.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Map2] for a usage example.
type Map4[ any,  any,  any,  any] struct {
	mask      bitMask
	ids       []ID
	relations []relationID
	world     *World
	storageA  *componentStorage
	storageB  *componentStorage
	storageC  *componentStorage
	storageD  *componentStorage
	archetype archetypeID
}

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

// NewMap4 creates a new [Map4].
//
// See also [Map4.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any]( *World) *Map4[, , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	return &Map4[, , , ]{
		world:    ,
		ids:      ,
		mask:     newMask(...),
		storageA: &.storage.components[[0].id],
		storageB: &.storage.components[[1].id],
		storageC: &.storage.components[[2].id],
		storageD: &.storage.components[[3].id],
	}
}

// NewEntity creates a new entity with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map4[, , , ]) ( *,  *,  *,  *,  ...Relation) Entity {
	return .NewEntityFn(func( *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewEntityFn creates a new entity with the mapped component and runs a callback instead of using a component for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map4[, , , ]) ( func(*, *, *, *),  ...Relation) Entity {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntity(.ids, .relations, .archetype)
	.archetype = 

	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireCreateEntityIfHas(, )
	if len() > 0 {
		.world.storage.observers.FireCreateEntityRelIfHas(, )
	}
	return 
}

// NewBatch creates a batch of new entities with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map4[, , , ]) ( int,  *,  *,  *,  *,  ...Relation) {
	.NewBatchFn(, func( Entity,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewBatchFn creates a batch of new entities with the mapped components, running the given initializer function on each.
// The initializer function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map4[, , , ]) ( int,  func(Entity, *, *, *, *),  ...Relation) {
	.world.checkLocked()
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntities(, .ids, .relations, .archetype)
	.archetype = 

	 := .world.storage.observers.HasObservers(OnCreateEntity)
	 := len() > 0 && .world.storage.observers.HasObservers(OnAddRelations)
	 :=  ||  ||  != nil
	var  uint8
	if  {
		 = .world.lock()
	}

	if  != nil {
		 := &.world.storage.tables[]
		 := .storageA.columns[]
		 := .storageB.columns[]
		 := .storageC.columns[]
		 := .storageD.columns[]
		for  := range  {
			 := uintptr( + )
			(
				.GetEntity(),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
			)
		}
	}

	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityBatch(, , &.mask)
	}
	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityRelBatch(, , &.mask)
	}

	if  {
		.world.unlock()
	}
}

// Get returns the mapped components for the given entity.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map4[, , , ]) ( Entity) (*, *, *, *) {
	if !.world.storage.entityPool.Alive() {
		panic("can't get components of a dead entity")
	}
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, )
}

// GetUnchecked returns the mapped components for the given entity.
// In contrast to [Map4.Get], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map4[, , , ]) ( Entity) (*, *, *, *) {
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, )
}

// HasAll return whether the given entity has all mapped components.
//
// Using [Map4.Get] and checking for nil pointer may be faster
// than calling [Map4.HasAll] and [Map4.Get] subsequently.
func ( *Map4[, , , ]) ( Entity) bool {
	if !.world.Alive() {
		panic("can't check components of a dead entity")
	}
	 := .world.storage.entities[.id].table
	return .storageA.columns[] != nil &&
		.storageB.columns[] != nil &&
		.storageC.columns[] != nil &&
		.storageD.columns[] != nil
}

// Add the mapped components to the given entity.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map4[, , , ]) ( Entity,  *,  *,  *,  *,  ...Relation) {
	.AddFn(, func( *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddFn adds the mapped components to the given entity and runs a callback instead of using components for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map4[, , , ]) ( Entity,  func(*, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	,  := .world.add(, .ids, .relations)
	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireAddIfHas(OnAddComponents, , , )
	if len() > 0 {
		.world.storage.observers.FireAddIfHas(OnAddRelations, , , )
	}
}

// Set the mapped components of the given entity to the given values.
// Requires the entity to already have all the mapped components.
//
// Triggers an OnSetComponents event, which is not the case when assigning by
// pointer dereference or assigning to fields. This can be used to notify observers
// about component updates.
//
// This is not a component operation, so it can be performed on a locked world.
func ( *Map4[, , , ]) ( Entity,  *,  *,  *,  *) {
	if !.world.Alive() {
		panic("can't set components of a dead entity")
	}
	.world.storage.checkHasComponent(, .ids[0])
	.world.storage.checkHasComponent(, .ids[1])
	.world.storage.checkHasComponent(, .ids[2])
	.world.storage.checkHasComponent(, .ids[3])

	 := &.world.storage.entities[.id]
	 := uintptr(.row)
	*(*)(.storageA.columns[.table].Get()) = *
	*(*)(.storageB.columns[.table].Get()) = *
	*(*)(.storageC.columns[.table].Get()) = *
	*(*)(.storageD.columns[.table].Get()) = *

	if .world.storage.observers.HasObservers(OnSetComponents) {
		 := &.world.storage.archetypes[.world.storage.tables[.table].archetype].mask
		.world.storage.observers.FireSet(, &.mask, )
	}
}

// AddBatch adds the mapped components to all entities matching the given batch filter.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map4[, , , ]) ( Batch,  *,  *,  *,  *,  ...Relation) {
	.AddBatchFn(, func( Entity,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddBatchFn adds the mapped components to all entities matching the given batch filter,
// running the given function on each. The function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map4[, , , ]) ( Batch,  func(Entity, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)

	var  func( tableID, ,  uint32)
	if  != nil {
		 = func( tableID, ,  uint32) {
			 := &.world.storage.tables[]
			 := .storageA.columns[]
			 := .storageB.columns[]
			 := .storageC.columns[]
			 := .storageD.columns[]

			for  := range  {
				 := uintptr( + )
				(
					.GetEntity(),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
				)
			}
		}
	}
	.world.exchangeBatch(&, .ids, nil, .relations, )
}

// Remove the mapped components from the given entity.
func ( *Map4[, , , ]) ( Entity) {
	.world.remove(, .ids)
}

// RemoveBatch removes the mapped components from all entities matching the given batch filter,
// running the given function on each. The function can be nil.
func ( *Map4[, , , ]) ( Batch,  func( Entity)) {
	removeBatch(.world, &, .ids, )
}

// GetRelation returns the relation target of an entity for the component at the given index.
func ( *Map4[, , , ]) ( Entity,  int) Entity {
	if !.world.storage.entityPool.Alive() {
		panic("can't get entity relation target for a dead entity")
	}
	return .GetRelationUnchecked(, )
}

// GetRelationUnchecked returns the relation target of an entity for the component at the given index.
// In contrast to [Map4.GetRelation], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
func ( *Map4[, , , ]) ( Entity,  int) Entity {
	return .world.storage.getRelation(, .ids[])
}

// SetRelations sets relation targets for the given entity.
func ( *Map4[, , , ]) ( Entity,  ...Relation) {
	// alive check is done in World.setRelations
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	.world.setRelations(, .relations)
}

// SetRelationsBatch sets relation targets for all entities matching the given batch filter.
func ( *Map4[, , , ]) ( Batch,  func( Entity),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	setRelationsBatch(.world, &, , .relations)
}

// Map5 is a mapper to access 5 components of an entity.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Map2] for a usage example.
type Map5[ any,  any,  any,  any,  any] struct {
	mask      bitMask
	ids       []ID
	relations []relationID
	world     *World
	storageA  *componentStorage
	storageB  *componentStorage
	storageC  *componentStorage
	storageD  *componentStorage
	storageE  *componentStorage
	archetype archetypeID
}

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

// NewMap5 creates a new [Map5].
//
// See also [Map5.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any,  any]( *World) *Map5[, , , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	return &Map5[, , , , ]{
		world:    ,
		ids:      ,
		mask:     newMask(...),
		storageA: &.storage.components[[0].id],
		storageB: &.storage.components[[1].id],
		storageC: &.storage.components[[2].id],
		storageD: &.storage.components[[3].id],
		storageE: &.storage.components[[4].id],
	}
}

// NewEntity creates a new entity with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map5[, , , , ]) ( *,  *,  *,  *,  *,  ...Relation) Entity {
	return .NewEntityFn(func( *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewEntityFn creates a new entity with the mapped component and runs a callback instead of using a component for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map5[, , , , ]) ( func(*, *, *, *, *),  ...Relation) Entity {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntity(.ids, .relations, .archetype)
	.archetype = 

	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireCreateEntityIfHas(, )
	if len() > 0 {
		.world.storage.observers.FireCreateEntityRelIfHas(, )
	}
	return 
}

// NewBatch creates a batch of new entities with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map5[, , , , ]) ( int,  *,  *,  *,  *,  *,  ...Relation) {
	.NewBatchFn(, func( Entity,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewBatchFn creates a batch of new entities with the mapped components, running the given initializer function on each.
// The initializer function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map5[, , , , ]) ( int,  func(Entity, *, *, *, *, *),  ...Relation) {
	.world.checkLocked()
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntities(, .ids, .relations, .archetype)
	.archetype = 

	 := .world.storage.observers.HasObservers(OnCreateEntity)
	 := len() > 0 && .world.storage.observers.HasObservers(OnAddRelations)
	 :=  ||  ||  != nil
	var  uint8
	if  {
		 = .world.lock()
	}

	if  != nil {
		 := &.world.storage.tables[]
		 := .storageA.columns[]
		 := .storageB.columns[]
		 := .storageC.columns[]
		 := .storageD.columns[]
		 := .storageE.columns[]
		for  := range  {
			 := uintptr( + )
			(
				.GetEntity(),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
			)
		}
	}

	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityBatch(, , &.mask)
	}
	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityRelBatch(, , &.mask)
	}

	if  {
		.world.unlock()
	}
}

// Get returns the mapped components for the given entity.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map5[, , , , ]) ( Entity) (*, *, *, *, *) {
	if !.world.storage.entityPool.Alive() {
		panic("can't get components of a dead entity")
	}
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, )
}

// GetUnchecked returns the mapped components for the given entity.
// In contrast to [Map5.Get], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map5[, , , , ]) ( Entity) (*, *, *, *, *) {
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, )
}

// HasAll return whether the given entity has all mapped components.
//
// Using [Map5.Get] and checking for nil pointer may be faster
// than calling [Map5.HasAll] and [Map5.Get] subsequently.
func ( *Map5[, , , , ]) ( Entity) bool {
	if !.world.Alive() {
		panic("can't check components of a dead entity")
	}
	 := .world.storage.entities[.id].table
	return .storageA.columns[] != nil &&
		.storageB.columns[] != nil &&
		.storageC.columns[] != nil &&
		.storageD.columns[] != nil &&
		.storageE.columns[] != nil
}

// Add the mapped components to the given entity.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map5[, , , , ]) ( Entity,  *,  *,  *,  *,  *,  ...Relation) {
	.AddFn(, func( *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddFn adds the mapped components to the given entity and runs a callback instead of using components for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map5[, , , , ]) ( Entity,  func(*, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	,  := .world.add(, .ids, .relations)
	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireAddIfHas(OnAddComponents, , , )
	if len() > 0 {
		.world.storage.observers.FireAddIfHas(OnAddRelations, , , )
	}
}

// Set the mapped components of the given entity to the given values.
// Requires the entity to already have all the mapped components.
//
// Triggers an OnSetComponents event, which is not the case when assigning by
// pointer dereference or assigning to fields. This can be used to notify observers
// about component updates.
//
// This is not a component operation, so it can be performed on a locked world.
func ( *Map5[, , , , ]) ( Entity,  *,  *,  *,  *,  *) {
	if !.world.Alive() {
		panic("can't set components of a dead entity")
	}
	.world.storage.checkHasComponent(, .ids[0])
	.world.storage.checkHasComponent(, .ids[1])
	.world.storage.checkHasComponent(, .ids[2])
	.world.storage.checkHasComponent(, .ids[3])
	.world.storage.checkHasComponent(, .ids[4])

	 := &.world.storage.entities[.id]
	 := uintptr(.row)
	*(*)(.storageA.columns[.table].Get()) = *
	*(*)(.storageB.columns[.table].Get()) = *
	*(*)(.storageC.columns[.table].Get()) = *
	*(*)(.storageD.columns[.table].Get()) = *
	*(*)(.storageE.columns[.table].Get()) = *

	if .world.storage.observers.HasObservers(OnSetComponents) {
		 := &.world.storage.archetypes[.world.storage.tables[.table].archetype].mask
		.world.storage.observers.FireSet(, &.mask, )
	}
}

// AddBatch adds the mapped components to all entities matching the given batch filter.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map5[, , , , ]) ( Batch,  *,  *,  *,  *,  *,  ...Relation) {
	.AddBatchFn(, func( Entity,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddBatchFn adds the mapped components to all entities matching the given batch filter,
// running the given function on each. The function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map5[, , , , ]) ( Batch,  func(Entity, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)

	var  func( tableID, ,  uint32)
	if  != nil {
		 = func( tableID, ,  uint32) {
			 := &.world.storage.tables[]
			 := .storageA.columns[]
			 := .storageB.columns[]
			 := .storageC.columns[]
			 := .storageD.columns[]
			 := .storageE.columns[]

			for  := range  {
				 := uintptr( + )
				(
					.GetEntity(),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
				)
			}
		}
	}
	.world.exchangeBatch(&, .ids, nil, .relations, )
}

// Remove the mapped components from the given entity.
func ( *Map5[, , , , ]) ( Entity) {
	.world.remove(, .ids)
}

// RemoveBatch removes the mapped components from all entities matching the given batch filter,
// running the given function on each. The function can be nil.
func ( *Map5[, , , , ]) ( Batch,  func( Entity)) {
	removeBatch(.world, &, .ids, )
}

// GetRelation returns the relation target of an entity for the component at the given index.
func ( *Map5[, , , , ]) ( Entity,  int) Entity {
	if !.world.storage.entityPool.Alive() {
		panic("can't get entity relation target for a dead entity")
	}
	return .GetRelationUnchecked(, )
}

// GetRelationUnchecked returns the relation target of an entity for the component at the given index.
// In contrast to [Map5.GetRelation], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
func ( *Map5[, , , , ]) ( Entity,  int) Entity {
	return .world.storage.getRelation(, .ids[])
}

// SetRelations sets relation targets for the given entity.
func ( *Map5[, , , , ]) ( Entity,  ...Relation) {
	// alive check is done in World.setRelations
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	.world.setRelations(, .relations)
}

// SetRelationsBatch sets relation targets for all entities matching the given batch filter.
func ( *Map5[, , , , ]) ( Batch,  func( Entity),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	setRelationsBatch(.world, &, , .relations)
}

// Map6 is a mapper to access 6 components of an entity.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Map2] for a usage example.
type Map6[ any,  any,  any,  any,  any,  any] struct {
	mask      bitMask
	ids       []ID
	relations []relationID
	world     *World
	storageA  *componentStorage
	storageB  *componentStorage
	storageC  *componentStorage
	storageD  *componentStorage
	storageE  *componentStorage
	storageF  *componentStorage
	archetype archetypeID
}

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

// NewMap6 creates a new [Map6].
//
// See also [Map6.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any,  any,  any]( *World) *Map6[, , , , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	return &Map6[, , , , , ]{
		world:    ,
		ids:      ,
		mask:     newMask(...),
		storageA: &.storage.components[[0].id],
		storageB: &.storage.components[[1].id],
		storageC: &.storage.components[[2].id],
		storageD: &.storage.components[[3].id],
		storageE: &.storage.components[[4].id],
		storageF: &.storage.components[[5].id],
	}
}

// NewEntity creates a new entity with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map6[, , , , , ]) ( *,  *,  *,  *,  *,  *,  ...Relation) Entity {
	return .NewEntityFn(func( *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewEntityFn creates a new entity with the mapped component and runs a callback instead of using a component for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map6[, , , , , ]) ( func(*, *, *, *, *, *),  ...Relation) Entity {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntity(.ids, .relations, .archetype)
	.archetype = 

	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireCreateEntityIfHas(, )
	if len() > 0 {
		.world.storage.observers.FireCreateEntityRelIfHas(, )
	}
	return 
}

// NewBatch creates a batch of new entities with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map6[, , , , , ]) ( int,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.NewBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewBatchFn creates a batch of new entities with the mapped components, running the given initializer function on each.
// The initializer function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map6[, , , , , ]) ( int,  func(Entity, *, *, *, *, *, *),  ...Relation) {
	.world.checkLocked()
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntities(, .ids, .relations, .archetype)
	.archetype = 

	 := .world.storage.observers.HasObservers(OnCreateEntity)
	 := len() > 0 && .world.storage.observers.HasObservers(OnAddRelations)
	 :=  ||  ||  != nil
	var  uint8
	if  {
		 = .world.lock()
	}

	if  != nil {
		 := &.world.storage.tables[]
		 := .storageA.columns[]
		 := .storageB.columns[]
		 := .storageC.columns[]
		 := .storageD.columns[]
		 := .storageE.columns[]
		 := .storageF.columns[]
		for  := range  {
			 := uintptr( + )
			(
				.GetEntity(),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
			)
		}
	}

	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityBatch(, , &.mask)
	}
	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityRelBatch(, , &.mask)
	}

	if  {
		.world.unlock()
	}
}

// Get returns the mapped components for the given entity.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map6[, , , , , ]) ( Entity) (*, *, *, *, *, *) {
	if !.world.storage.entityPool.Alive() {
		panic("can't get components of a dead entity")
	}
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, )
}

// GetUnchecked returns the mapped components for the given entity.
// In contrast to [Map6.Get], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map6[, , , , , ]) ( Entity) (*, *, *, *, *, *) {
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, )
}

// HasAll return whether the given entity has all mapped components.
//
// Using [Map6.Get] and checking for nil pointer may be faster
// than calling [Map6.HasAll] and [Map6.Get] subsequently.
func ( *Map6[, , , , , ]) ( Entity) bool {
	if !.world.Alive() {
		panic("can't check components of a dead entity")
	}
	 := .world.storage.entities[.id].table
	return .storageA.columns[] != nil &&
		.storageB.columns[] != nil &&
		.storageC.columns[] != nil &&
		.storageD.columns[] != nil &&
		.storageE.columns[] != nil &&
		.storageF.columns[] != nil
}

// Add the mapped components to the given entity.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map6[, , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddFn(, func( *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddFn adds the mapped components to the given entity and runs a callback instead of using components for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map6[, , , , , ]) ( Entity,  func(*, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	,  := .world.add(, .ids, .relations)
	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireAddIfHas(OnAddComponents, , , )
	if len() > 0 {
		.world.storage.observers.FireAddIfHas(OnAddRelations, , , )
	}
}

// Set the mapped components of the given entity to the given values.
// Requires the entity to already have all the mapped components.
//
// Triggers an OnSetComponents event, which is not the case when assigning by
// pointer dereference or assigning to fields. This can be used to notify observers
// about component updates.
//
// This is not a component operation, so it can be performed on a locked world.
func ( *Map6[, , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *) {
	if !.world.Alive() {
		panic("can't set components of a dead entity")
	}
	.world.storage.checkHasComponent(, .ids[0])
	.world.storage.checkHasComponent(, .ids[1])
	.world.storage.checkHasComponent(, .ids[2])
	.world.storage.checkHasComponent(, .ids[3])
	.world.storage.checkHasComponent(, .ids[4])
	.world.storage.checkHasComponent(, .ids[5])

	 := &.world.storage.entities[.id]
	 := uintptr(.row)
	*(*)(.storageA.columns[.table].Get()) = *
	*(*)(.storageB.columns[.table].Get()) = *
	*(*)(.storageC.columns[.table].Get()) = *
	*(*)(.storageD.columns[.table].Get()) = *
	*(*)(.storageE.columns[.table].Get()) = *
	*(*)(.storageF.columns[.table].Get()) = *

	if .world.storage.observers.HasObservers(OnSetComponents) {
		 := &.world.storage.archetypes[.world.storage.tables[.table].archetype].mask
		.world.storage.observers.FireSet(, &.mask, )
	}
}

// AddBatch adds the mapped components to all entities matching the given batch filter.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map6[, , , , , ]) ( Batch,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddBatchFn adds the mapped components to all entities matching the given batch filter,
// running the given function on each. The function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map6[, , , , , ]) ( Batch,  func(Entity, *, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)

	var  func( tableID, ,  uint32)
	if  != nil {
		 = func( tableID, ,  uint32) {
			 := &.world.storage.tables[]
			 := .storageA.columns[]
			 := .storageB.columns[]
			 := .storageC.columns[]
			 := .storageD.columns[]
			 := .storageE.columns[]
			 := .storageF.columns[]

			for  := range  {
				 := uintptr( + )
				(
					.GetEntity(),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
				)
			}
		}
	}
	.world.exchangeBatch(&, .ids, nil, .relations, )
}

// Remove the mapped components from the given entity.
func ( *Map6[, , , , , ]) ( Entity) {
	.world.remove(, .ids)
}

// RemoveBatch removes the mapped components from all entities matching the given batch filter,
// running the given function on each. The function can be nil.
func ( *Map6[, , , , , ]) ( Batch,  func( Entity)) {
	removeBatch(.world, &, .ids, )
}

// GetRelation returns the relation target of an entity for the component at the given index.
func ( *Map6[, , , , , ]) ( Entity,  int) Entity {
	if !.world.storage.entityPool.Alive() {
		panic("can't get entity relation target for a dead entity")
	}
	return .GetRelationUnchecked(, )
}

// GetRelationUnchecked returns the relation target of an entity for the component at the given index.
// In contrast to [Map6.GetRelation], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
func ( *Map6[, , , , , ]) ( Entity,  int) Entity {
	return .world.storage.getRelation(, .ids[])
}

// SetRelations sets relation targets for the given entity.
func ( *Map6[, , , , , ]) ( Entity,  ...Relation) {
	// alive check is done in World.setRelations
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	.world.setRelations(, .relations)
}

// SetRelationsBatch sets relation targets for all entities matching the given batch filter.
func ( *Map6[, , , , , ]) ( Batch,  func( Entity),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	setRelationsBatch(.world, &, , .relations)
}

// Map7 is a mapper to access 7 components of an entity.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Map2] for a usage example.
type Map7[ any,  any,  any,  any,  any,  any,  any] struct {
	mask      bitMask
	ids       []ID
	relations []relationID
	world     *World
	storageA  *componentStorage
	storageB  *componentStorage
	storageC  *componentStorage
	storageD  *componentStorage
	storageE  *componentStorage
	storageF  *componentStorage
	storageG  *componentStorage
	archetype archetypeID
}

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

// NewMap7 creates a new [Map7].
//
// See also [Map7.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any,  any,  any,  any]( *World) *Map7[, , , , , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	return &Map7[, , , , , , ]{
		world:    ,
		ids:      ,
		mask:     newMask(...),
		storageA: &.storage.components[[0].id],
		storageB: &.storage.components[[1].id],
		storageC: &.storage.components[[2].id],
		storageD: &.storage.components[[3].id],
		storageE: &.storage.components[[4].id],
		storageF: &.storage.components[[5].id],
		storageG: &.storage.components[[6].id],
	}
}

// NewEntity creates a new entity with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map7[, , , , , , ]) ( *,  *,  *,  *,  *,  *,  *,  ...Relation) Entity {
	return .NewEntityFn(func( *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewEntityFn creates a new entity with the mapped component and runs a callback instead of using a component for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map7[, , , , , , ]) ( func(*, *, *, *, *, *, *),  ...Relation) Entity {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntity(.ids, .relations, .archetype)
	.archetype = 

	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
			(*)(.storageG.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireCreateEntityIfHas(, )
	if len() > 0 {
		.world.storage.observers.FireCreateEntityRelIfHas(, )
	}
	return 
}

// NewBatch creates a batch of new entities with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map7[, , , , , , ]) ( int,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.NewBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewBatchFn creates a batch of new entities with the mapped components, running the given initializer function on each.
// The initializer function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map7[, , , , , , ]) ( int,  func(Entity, *, *, *, *, *, *, *),  ...Relation) {
	.world.checkLocked()
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntities(, .ids, .relations, .archetype)
	.archetype = 

	 := .world.storage.observers.HasObservers(OnCreateEntity)
	 := len() > 0 && .world.storage.observers.HasObservers(OnAddRelations)
	 :=  ||  ||  != nil
	var  uint8
	if  {
		 = .world.lock()
	}

	if  != nil {
		 := &.world.storage.tables[]
		 := .storageA.columns[]
		 := .storageB.columns[]
		 := .storageC.columns[]
		 := .storageD.columns[]
		 := .storageE.columns[]
		 := .storageF.columns[]
		 := .storageG.columns[]
		for  := range  {
			 := uintptr( + )
			(
				.GetEntity(),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
			)
		}
	}

	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityBatch(, , &.mask)
	}
	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityRelBatch(, , &.mask)
	}

	if  {
		.world.unlock()
	}
}

// Get returns the mapped components for the given entity.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map7[, , , , , , ]) ( Entity) (*, *, *, *, *, *, *) {
	if !.world.storage.entityPool.Alive() {
		panic("can't get components of a dead entity")
	}
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, ), get[](.storageG, )
}

// GetUnchecked returns the mapped components for the given entity.
// In contrast to [Map7.Get], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map7[, , , , , , ]) ( Entity) (*, *, *, *, *, *, *) {
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, ), get[](.storageG, )
}

// HasAll return whether the given entity has all mapped components.
//
// Using [Map7.Get] and checking for nil pointer may be faster
// than calling [Map7.HasAll] and [Map7.Get] subsequently.
func ( *Map7[, , , , , , ]) ( Entity) bool {
	if !.world.Alive() {
		panic("can't check components of a dead entity")
	}
	 := .world.storage.entities[.id].table
	return .storageA.columns[] != nil &&
		.storageB.columns[] != nil &&
		.storageC.columns[] != nil &&
		.storageD.columns[] != nil &&
		.storageE.columns[] != nil &&
		.storageF.columns[] != nil &&
		.storageG.columns[] != nil
}

// Add the mapped components to the given entity.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map7[, , , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddFn(, func( *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddFn adds the mapped components to the given entity and runs a callback instead of using components for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map7[, , , , , , ]) ( Entity,  func(*, *, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	,  := .world.add(, .ids, .relations)
	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
			(*)(.storageG.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireAddIfHas(OnAddComponents, , , )
	if len() > 0 {
		.world.storage.observers.FireAddIfHas(OnAddRelations, , , )
	}
}

// Set the mapped components of the given entity to the given values.
// Requires the entity to already have all the mapped components.
//
// Triggers an OnSetComponents event, which is not the case when assigning by
// pointer dereference or assigning to fields. This can be used to notify observers
// about component updates.
//
// This is not a component operation, so it can be performed on a locked world.
func ( *Map7[, , , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *,  *) {
	if !.world.Alive() {
		panic("can't set components of a dead entity")
	}
	.world.storage.checkHasComponent(, .ids[0])
	.world.storage.checkHasComponent(, .ids[1])
	.world.storage.checkHasComponent(, .ids[2])
	.world.storage.checkHasComponent(, .ids[3])
	.world.storage.checkHasComponent(, .ids[4])
	.world.storage.checkHasComponent(, .ids[5])
	.world.storage.checkHasComponent(, .ids[6])

	 := &.world.storage.entities[.id]
	 := uintptr(.row)
	*(*)(.storageA.columns[.table].Get()) = *
	*(*)(.storageB.columns[.table].Get()) = *
	*(*)(.storageC.columns[.table].Get()) = *
	*(*)(.storageD.columns[.table].Get()) = *
	*(*)(.storageE.columns[.table].Get()) = *
	*(*)(.storageF.columns[.table].Get()) = *
	*(*)(.storageG.columns[.table].Get()) = *

	if .world.storage.observers.HasObservers(OnSetComponents) {
		 := &.world.storage.archetypes[.world.storage.tables[.table].archetype].mask
		.world.storage.observers.FireSet(, &.mask, )
	}
}

// AddBatch adds the mapped components to all entities matching the given batch filter.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map7[, , , , , , ]) ( Batch,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddBatchFn adds the mapped components to all entities matching the given batch filter,
// running the given function on each. The function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map7[, , , , , , ]) ( Batch,  func(Entity, *, *, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)

	var  func( tableID, ,  uint32)
	if  != nil {
		 = func( tableID, ,  uint32) {
			 := &.world.storage.tables[]
			 := .storageA.columns[]
			 := .storageB.columns[]
			 := .storageC.columns[]
			 := .storageD.columns[]
			 := .storageE.columns[]
			 := .storageF.columns[]
			 := .storageG.columns[]

			for  := range  {
				 := uintptr( + )
				(
					.GetEntity(),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
				)
			}
		}
	}
	.world.exchangeBatch(&, .ids, nil, .relations, )
}

// Remove the mapped components from the given entity.
func ( *Map7[, , , , , , ]) ( Entity) {
	.world.remove(, .ids)
}

// RemoveBatch removes the mapped components from all entities matching the given batch filter,
// running the given function on each. The function can be nil.
func ( *Map7[, , , , , , ]) ( Batch,  func( Entity)) {
	removeBatch(.world, &, .ids, )
}

// GetRelation returns the relation target of an entity for the component at the given index.
func ( *Map7[, , , , , , ]) ( Entity,  int) Entity {
	if !.world.storage.entityPool.Alive() {
		panic("can't get entity relation target for a dead entity")
	}
	return .GetRelationUnchecked(, )
}

// GetRelationUnchecked returns the relation target of an entity for the component at the given index.
// In contrast to [Map7.GetRelation], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
func ( *Map7[, , , , , , ]) ( Entity,  int) Entity {
	return .world.storage.getRelation(, .ids[])
}

// SetRelations sets relation targets for the given entity.
func ( *Map7[, , , , , , ]) ( Entity,  ...Relation) {
	// alive check is done in World.setRelations
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	.world.setRelations(, .relations)
}

// SetRelationsBatch sets relation targets for all entities matching the given batch filter.
func ( *Map7[, , , , , , ]) ( Batch,  func( Entity),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	setRelationsBatch(.world, &, , .relations)
}

// Map8 is a mapper to access 8 components of an entity.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Map2] for a usage example.
type Map8[ any,  any,  any,  any,  any,  any,  any,  any] struct {
	mask      bitMask
	ids       []ID
	relations []relationID
	world     *World
	storageA  *componentStorage
	storageB  *componentStorage
	storageC  *componentStorage
	storageD  *componentStorage
	storageE  *componentStorage
	storageF  *componentStorage
	storageG  *componentStorage
	storageH  *componentStorage
	archetype archetypeID
}

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

// NewMap8 creates a new [Map8].
//
// See also [Map8.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any,  any,  any,  any,  any]( *World) *Map8[, , , , , , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	return &Map8[, , , , , , , ]{
		world:    ,
		ids:      ,
		mask:     newMask(...),
		storageA: &.storage.components[[0].id],
		storageB: &.storage.components[[1].id],
		storageC: &.storage.components[[2].id],
		storageD: &.storage.components[[3].id],
		storageE: &.storage.components[[4].id],
		storageF: &.storage.components[[5].id],
		storageG: &.storage.components[[6].id],
		storageH: &.storage.components[[7].id],
	}
}

// NewEntity creates a new entity with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map8[, , , , , , , ]) ( *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) Entity {
	return .NewEntityFn(func( *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewEntityFn creates a new entity with the mapped component and runs a callback instead of using a component for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map8[, , , , , , , ]) ( func(*, *, *, *, *, *, *, *),  ...Relation) Entity {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntity(.ids, .relations, .archetype)
	.archetype = 

	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
			(*)(.storageG.columns[.table].Get()),
			(*)(.storageH.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireCreateEntityIfHas(, )
	if len() > 0 {
		.world.storage.observers.FireCreateEntityRelIfHas(, )
	}
	return 
}

// NewBatch creates a batch of new entities with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map8[, , , , , , , ]) ( int,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.NewBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewBatchFn creates a batch of new entities with the mapped components, running the given initializer function on each.
// The initializer function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map8[, , , , , , , ]) ( int,  func(Entity, *, *, *, *, *, *, *, *),  ...Relation) {
	.world.checkLocked()
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntities(, .ids, .relations, .archetype)
	.archetype = 

	 := .world.storage.observers.HasObservers(OnCreateEntity)
	 := len() > 0 && .world.storage.observers.HasObservers(OnAddRelations)
	 :=  ||  ||  != nil
	var  uint8
	if  {
		 = .world.lock()
	}

	if  != nil {
		 := &.world.storage.tables[]
		 := .storageA.columns[]
		 := .storageB.columns[]
		 := .storageC.columns[]
		 := .storageD.columns[]
		 := .storageE.columns[]
		 := .storageF.columns[]
		 := .storageG.columns[]
		 := .storageH.columns[]
		for  := range  {
			 := uintptr( + )
			(
				.GetEntity(),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
			)
		}
	}

	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityBatch(, , &.mask)
	}
	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityRelBatch(, , &.mask)
	}

	if  {
		.world.unlock()
	}
}

// Get returns the mapped components for the given entity.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map8[, , , , , , , ]) ( Entity) (*, *, *, *, *, *, *, *) {
	if !.world.storage.entityPool.Alive() {
		panic("can't get components of a dead entity")
	}
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, ), get[](.storageG, ), get[](.storageH, )
}

// GetUnchecked returns the mapped components for the given entity.
// In contrast to [Map8.Get], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map8[, , , , , , , ]) ( Entity) (*, *, *, *, *, *, *, *) {
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, ), get[](.storageG, ), get[](.storageH, )
}

// HasAll return whether the given entity has all mapped components.
//
// Using [Map8.Get] and checking for nil pointer may be faster
// than calling [Map8.HasAll] and [Map8.Get] subsequently.
func ( *Map8[, , , , , , , ]) ( Entity) bool {
	if !.world.Alive() {
		panic("can't check components of a dead entity")
	}
	 := .world.storage.entities[.id].table
	return .storageA.columns[] != nil &&
		.storageB.columns[] != nil &&
		.storageC.columns[] != nil &&
		.storageD.columns[] != nil &&
		.storageE.columns[] != nil &&
		.storageF.columns[] != nil &&
		.storageG.columns[] != nil &&
		.storageH.columns[] != nil
}

// Add the mapped components to the given entity.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map8[, , , , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddFn(, func( *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddFn adds the mapped components to the given entity and runs a callback instead of using components for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map8[, , , , , , , ]) ( Entity,  func(*, *, *, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	,  := .world.add(, .ids, .relations)
	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
			(*)(.storageG.columns[.table].Get()),
			(*)(.storageH.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireAddIfHas(OnAddComponents, , , )
	if len() > 0 {
		.world.storage.observers.FireAddIfHas(OnAddRelations, , , )
	}
}

// Set the mapped components of the given entity to the given values.
// Requires the entity to already have all the mapped components.
//
// Triggers an OnSetComponents event, which is not the case when assigning by
// pointer dereference or assigning to fields. This can be used to notify observers
// about component updates.
//
// This is not a component operation, so it can be performed on a locked world.
func ( *Map8[, , , , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *,  *,  *) {
	if !.world.Alive() {
		panic("can't set components of a dead entity")
	}
	.world.storage.checkHasComponent(, .ids[0])
	.world.storage.checkHasComponent(, .ids[1])
	.world.storage.checkHasComponent(, .ids[2])
	.world.storage.checkHasComponent(, .ids[3])
	.world.storage.checkHasComponent(, .ids[4])
	.world.storage.checkHasComponent(, .ids[5])
	.world.storage.checkHasComponent(, .ids[6])
	.world.storage.checkHasComponent(, .ids[7])

	 := &.world.storage.entities[.id]
	 := uintptr(.row)
	*(*)(.storageA.columns[.table].Get()) = *
	*(*)(.storageB.columns[.table].Get()) = *
	*(*)(.storageC.columns[.table].Get()) = *
	*(*)(.storageD.columns[.table].Get()) = *
	*(*)(.storageE.columns[.table].Get()) = *
	*(*)(.storageF.columns[.table].Get()) = *
	*(*)(.storageG.columns[.table].Get()) = *
	*(*)(.storageH.columns[.table].Get()) = *

	if .world.storage.observers.HasObservers(OnSetComponents) {
		 := &.world.storage.archetypes[.world.storage.tables[.table].archetype].mask
		.world.storage.observers.FireSet(, &.mask, )
	}
}

// AddBatch adds the mapped components to all entities matching the given batch filter.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map8[, , , , , , , ]) ( Batch,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddBatchFn adds the mapped components to all entities matching the given batch filter,
// running the given function on each. The function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map8[, , , , , , , ]) ( Batch,  func(Entity, *, *, *, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)

	var  func( tableID, ,  uint32)
	if  != nil {
		 = func( tableID, ,  uint32) {
			 := &.world.storage.tables[]
			 := .storageA.columns[]
			 := .storageB.columns[]
			 := .storageC.columns[]
			 := .storageD.columns[]
			 := .storageE.columns[]
			 := .storageF.columns[]
			 := .storageG.columns[]
			 := .storageH.columns[]

			for  := range  {
				 := uintptr( + )
				(
					.GetEntity(),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
				)
			}
		}
	}
	.world.exchangeBatch(&, .ids, nil, .relations, )
}

// Remove the mapped components from the given entity.
func ( *Map8[, , , , , , , ]) ( Entity) {
	.world.remove(, .ids)
}

// RemoveBatch removes the mapped components from all entities matching the given batch filter,
// running the given function on each. The function can be nil.
func ( *Map8[, , , , , , , ]) ( Batch,  func( Entity)) {
	removeBatch(.world, &, .ids, )
}

// GetRelation returns the relation target of an entity for the component at the given index.
func ( *Map8[, , , , , , , ]) ( Entity,  int) Entity {
	if !.world.storage.entityPool.Alive() {
		panic("can't get entity relation target for a dead entity")
	}
	return .GetRelationUnchecked(, )
}

// GetRelationUnchecked returns the relation target of an entity for the component at the given index.
// In contrast to [Map8.GetRelation], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
func ( *Map8[, , , , , , , ]) ( Entity,  int) Entity {
	return .world.storage.getRelation(, .ids[])
}

// SetRelations sets relation targets for the given entity.
func ( *Map8[, , , , , , , ]) ( Entity,  ...Relation) {
	// alive check is done in World.setRelations
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	.world.setRelations(, .relations)
}

// SetRelationsBatch sets relation targets for all entities matching the given batch filter.
func ( *Map8[, , , , , , , ]) ( Batch,  func( Entity),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	setRelationsBatch(.world, &, , .relations)
}

// Map9 is a mapper to access 9 components of an entity.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Map2] for a usage example.
type Map9[ any,  any,  any,  any,  any,  any,  any,  any,  any] struct {
	mask      bitMask
	ids       []ID
	relations []relationID
	world     *World
	storageA  *componentStorage
	storageB  *componentStorage
	storageC  *componentStorage
	storageD  *componentStorage
	storageE  *componentStorage
	storageF  *componentStorage
	storageG  *componentStorage
	storageH  *componentStorage
	storageI  *componentStorage
	archetype archetypeID
}

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

// NewMap9 creates a new [Map9].
//
// See also [Map9.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any,  any,  any,  any,  any,  any]( *World) *Map9[, , , , , , , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	return &Map9[, , , , , , , , ]{
		world:    ,
		ids:      ,
		mask:     newMask(...),
		storageA: &.storage.components[[0].id],
		storageB: &.storage.components[[1].id],
		storageC: &.storage.components[[2].id],
		storageD: &.storage.components[[3].id],
		storageE: &.storage.components[[4].id],
		storageF: &.storage.components[[5].id],
		storageG: &.storage.components[[6].id],
		storageH: &.storage.components[[7].id],
		storageI: &.storage.components[[8].id],
	}
}

// NewEntity creates a new entity with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map9[, , , , , , , , ]) ( *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) Entity {
	return .NewEntityFn(func( *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewEntityFn creates a new entity with the mapped component and runs a callback instead of using a component for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map9[, , , , , , , , ]) ( func(*, *, *, *, *, *, *, *, *),  ...Relation) Entity {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntity(.ids, .relations, .archetype)
	.archetype = 

	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
			(*)(.storageG.columns[.table].Get()),
			(*)(.storageH.columns[.table].Get()),
			(*)(.storageI.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireCreateEntityIfHas(, )
	if len() > 0 {
		.world.storage.observers.FireCreateEntityRelIfHas(, )
	}
	return 
}

// NewBatch creates a batch of new entities with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map9[, , , , , , , , ]) ( int,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.NewBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewBatchFn creates a batch of new entities with the mapped components, running the given initializer function on each.
// The initializer function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map9[, , , , , , , , ]) ( int,  func(Entity, *, *, *, *, *, *, *, *, *),  ...Relation) {
	.world.checkLocked()
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntities(, .ids, .relations, .archetype)
	.archetype = 

	 := .world.storage.observers.HasObservers(OnCreateEntity)
	 := len() > 0 && .world.storage.observers.HasObservers(OnAddRelations)
	 :=  ||  ||  != nil
	var  uint8
	if  {
		 = .world.lock()
	}

	if  != nil {
		 := &.world.storage.tables[]
		 := .storageA.columns[]
		 := .storageB.columns[]
		 := .storageC.columns[]
		 := .storageD.columns[]
		 := .storageE.columns[]
		 := .storageF.columns[]
		 := .storageG.columns[]
		 := .storageH.columns[]
		 := .storageI.columns[]
		for  := range  {
			 := uintptr( + )
			(
				.GetEntity(),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
			)
		}
	}

	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityBatch(, , &.mask)
	}
	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityRelBatch(, , &.mask)
	}

	if  {
		.world.unlock()
	}
}

// Get returns the mapped components for the given entity.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map9[, , , , , , , , ]) ( Entity) (*, *, *, *, *, *, *, *, *) {
	if !.world.storage.entityPool.Alive() {
		panic("can't get components of a dead entity")
	}
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, ), get[](.storageG, ), get[](.storageH, ), get[](.storageI, )
}

// GetUnchecked returns the mapped components for the given entity.
// In contrast to [Map9.Get], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map9[, , , , , , , , ]) ( Entity) (*, *, *, *, *, *, *, *, *) {
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, ), get[](.storageG, ), get[](.storageH, ), get[](.storageI, )
}

// HasAll return whether the given entity has all mapped components.
//
// Using [Map9.Get] and checking for nil pointer may be faster
// than calling [Map9.HasAll] and [Map9.Get] subsequently.
func ( *Map9[, , , , , , , , ]) ( Entity) bool {
	if !.world.Alive() {
		panic("can't check components of a dead entity")
	}
	 := .world.storage.entities[.id].table
	return .storageA.columns[] != nil &&
		.storageB.columns[] != nil &&
		.storageC.columns[] != nil &&
		.storageD.columns[] != nil &&
		.storageE.columns[] != nil &&
		.storageF.columns[] != nil &&
		.storageG.columns[] != nil &&
		.storageH.columns[] != nil &&
		.storageI.columns[] != nil
}

// Add the mapped components to the given entity.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map9[, , , , , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddFn(, func( *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddFn adds the mapped components to the given entity and runs a callback instead of using components for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map9[, , , , , , , , ]) ( Entity,  func(*, *, *, *, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	,  := .world.add(, .ids, .relations)
	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
			(*)(.storageG.columns[.table].Get()),
			(*)(.storageH.columns[.table].Get()),
			(*)(.storageI.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireAddIfHas(OnAddComponents, , , )
	if len() > 0 {
		.world.storage.observers.FireAddIfHas(OnAddRelations, , , )
	}
}

// Set the mapped components of the given entity to the given values.
// Requires the entity to already have all the mapped components.
//
// Triggers an OnSetComponents event, which is not the case when assigning by
// pointer dereference or assigning to fields. This can be used to notify observers
// about component updates.
//
// This is not a component operation, so it can be performed on a locked world.
func ( *Map9[, , , , , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
	if !.world.Alive() {
		panic("can't set components of a dead entity")
	}
	.world.storage.checkHasComponent(, .ids[0])
	.world.storage.checkHasComponent(, .ids[1])
	.world.storage.checkHasComponent(, .ids[2])
	.world.storage.checkHasComponent(, .ids[3])
	.world.storage.checkHasComponent(, .ids[4])
	.world.storage.checkHasComponent(, .ids[5])
	.world.storage.checkHasComponent(, .ids[6])
	.world.storage.checkHasComponent(, .ids[7])
	.world.storage.checkHasComponent(, .ids[8])

	 := &.world.storage.entities[.id]
	 := uintptr(.row)
	*(*)(.storageA.columns[.table].Get()) = *
	*(*)(.storageB.columns[.table].Get()) = *
	*(*)(.storageC.columns[.table].Get()) = *
	*(*)(.storageD.columns[.table].Get()) = *
	*(*)(.storageE.columns[.table].Get()) = *
	*(*)(.storageF.columns[.table].Get()) = *
	*(*)(.storageG.columns[.table].Get()) = *
	*(*)(.storageH.columns[.table].Get()) = *
	*(*)(.storageI.columns[.table].Get()) = *

	if .world.storage.observers.HasObservers(OnSetComponents) {
		 := &.world.storage.archetypes[.world.storage.tables[.table].archetype].mask
		.world.storage.observers.FireSet(, &.mask, )
	}
}

// AddBatch adds the mapped components to all entities matching the given batch filter.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map9[, , , , , , , , ]) ( Batch,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddBatchFn adds the mapped components to all entities matching the given batch filter,
// running the given function on each. The function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map9[, , , , , , , , ]) ( Batch,  func(Entity, *, *, *, *, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)

	var  func( tableID, ,  uint32)
	if  != nil {
		 = func( tableID, ,  uint32) {
			 := &.world.storage.tables[]
			 := .storageA.columns[]
			 := .storageB.columns[]
			 := .storageC.columns[]
			 := .storageD.columns[]
			 := .storageE.columns[]
			 := .storageF.columns[]
			 := .storageG.columns[]
			 := .storageH.columns[]
			 := .storageI.columns[]

			for  := range  {
				 := uintptr( + )
				(
					.GetEntity(),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
				)
			}
		}
	}
	.world.exchangeBatch(&, .ids, nil, .relations, )
}

// Remove the mapped components from the given entity.
func ( *Map9[, , , , , , , , ]) ( Entity) {
	.world.remove(, .ids)
}

// RemoveBatch removes the mapped components from all entities matching the given batch filter,
// running the given function on each. The function can be nil.
func ( *Map9[, , , , , , , , ]) ( Batch,  func( Entity)) {
	removeBatch(.world, &, .ids, )
}

// GetRelation returns the relation target of an entity for the component at the given index.
func ( *Map9[, , , , , , , , ]) ( Entity,  int) Entity {
	if !.world.storage.entityPool.Alive() {
		panic("can't get entity relation target for a dead entity")
	}
	return .GetRelationUnchecked(, )
}

// GetRelationUnchecked returns the relation target of an entity for the component at the given index.
// In contrast to [Map9.GetRelation], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
func ( *Map9[, , , , , , , , ]) ( Entity,  int) Entity {
	return .world.storage.getRelation(, .ids[])
}

// SetRelations sets relation targets for the given entity.
func ( *Map9[, , , , , , , , ]) ( Entity,  ...Relation) {
	// alive check is done in World.setRelations
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	.world.setRelations(, .relations)
}

// SetRelationsBatch sets relation targets for all entities matching the given batch filter.
func ( *Map9[, , , , , , , , ]) ( Batch,  func( Entity),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	setRelationsBatch(.world, &, , .relations)
}

// Map10 is a mapper to access 10 components of an entity.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Map2] for a usage example.
type Map10[ any,  any,  any,  any,  any,  any,  any,  any,  any,  any] struct {
	mask      bitMask
	ids       []ID
	relations []relationID
	world     *World
	storageA  *componentStorage
	storageB  *componentStorage
	storageC  *componentStorage
	storageD  *componentStorage
	storageE  *componentStorage
	storageF  *componentStorage
	storageG  *componentStorage
	storageH  *componentStorage
	storageI  *componentStorage
	storageJ  *componentStorage
	archetype archetypeID
}

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

// NewMap10 creates a new [Map10].
//
// See also [Map10.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any,  any,  any,  any,  any,  any,  any]( *World) *Map10[, , , , , , , , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	return &Map10[, , , , , , , , , ]{
		world:    ,
		ids:      ,
		mask:     newMask(...),
		storageA: &.storage.components[[0].id],
		storageB: &.storage.components[[1].id],
		storageC: &.storage.components[[2].id],
		storageD: &.storage.components[[3].id],
		storageE: &.storage.components[[4].id],
		storageF: &.storage.components[[5].id],
		storageG: &.storage.components[[6].id],
		storageH: &.storage.components[[7].id],
		storageI: &.storage.components[[8].id],
		storageJ: &.storage.components[[9].id],
	}
}

// NewEntity creates a new entity with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map10[, , , , , , , , , ]) ( *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) Entity {
	return .NewEntityFn(func( *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewEntityFn creates a new entity with the mapped component and runs a callback instead of using a component for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map10[, , , , , , , , , ]) ( func(*, *, *, *, *, *, *, *, *, *),  ...Relation) Entity {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntity(.ids, .relations, .archetype)
	.archetype = 

	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
			(*)(.storageG.columns[.table].Get()),
			(*)(.storageH.columns[.table].Get()),
			(*)(.storageI.columns[.table].Get()),
			(*)(.storageJ.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireCreateEntityIfHas(, )
	if len() > 0 {
		.world.storage.observers.FireCreateEntityRelIfHas(, )
	}
	return 
}

// NewBatch creates a batch of new entities with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map10[, , , , , , , , , ]) ( int,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.NewBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewBatchFn creates a batch of new entities with the mapped components, running the given initializer function on each.
// The initializer function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map10[, , , , , , , , , ]) ( int,  func(Entity, *, *, *, *, *, *, *, *, *, *),  ...Relation) {
	.world.checkLocked()
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntities(, .ids, .relations, .archetype)
	.archetype = 

	 := .world.storage.observers.HasObservers(OnCreateEntity)
	 := len() > 0 && .world.storage.observers.HasObservers(OnAddRelations)
	 :=  ||  ||  != nil
	var  uint8
	if  {
		 = .world.lock()
	}

	if  != nil {
		 := &.world.storage.tables[]
		 := .storageA.columns[]
		 := .storageB.columns[]
		 := .storageC.columns[]
		 := .storageD.columns[]
		 := .storageE.columns[]
		 := .storageF.columns[]
		 := .storageG.columns[]
		 := .storageH.columns[]
		 := .storageI.columns[]
		 := .storageJ.columns[]
		for  := range  {
			 := uintptr( + )
			(
				.GetEntity(),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
			)
		}
	}

	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityBatch(, , &.mask)
	}
	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityRelBatch(, , &.mask)
	}

	if  {
		.world.unlock()
	}
}

// Get returns the mapped components for the given entity.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map10[, , , , , , , , , ]) ( Entity) (*, *, *, *, *, *, *, *, *, *) {
	if !.world.storage.entityPool.Alive() {
		panic("can't get components of a dead entity")
	}
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, ), get[](.storageG, ), get[](.storageH, ), get[](.storageI, ), get[](.storageJ, )
}

// GetUnchecked returns the mapped components for the given entity.
// In contrast to [Map10.Get], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map10[, , , , , , , , , ]) ( Entity) (*, *, *, *, *, *, *, *, *, *) {
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, ), get[](.storageG, ), get[](.storageH, ), get[](.storageI, ), get[](.storageJ, )
}

// HasAll return whether the given entity has all mapped components.
//
// Using [Map10.Get] and checking for nil pointer may be faster
// than calling [Map10.HasAll] and [Map10.Get] subsequently.
func ( *Map10[, , , , , , , , , ]) ( Entity) bool {
	if !.world.Alive() {
		panic("can't check components of a dead entity")
	}
	 := .world.storage.entities[.id].table
	return .storageA.columns[] != nil &&
		.storageB.columns[] != nil &&
		.storageC.columns[] != nil &&
		.storageD.columns[] != nil &&
		.storageE.columns[] != nil &&
		.storageF.columns[] != nil &&
		.storageG.columns[] != nil &&
		.storageH.columns[] != nil &&
		.storageI.columns[] != nil &&
		.storageJ.columns[] != nil
}

// Add the mapped components to the given entity.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map10[, , , , , , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddFn(, func( *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddFn adds the mapped components to the given entity and runs a callback instead of using components for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map10[, , , , , , , , , ]) ( Entity,  func(*, *, *, *, *, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	,  := .world.add(, .ids, .relations)
	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
			(*)(.storageG.columns[.table].Get()),
			(*)(.storageH.columns[.table].Get()),
			(*)(.storageI.columns[.table].Get()),
			(*)(.storageJ.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireAddIfHas(OnAddComponents, , , )
	if len() > 0 {
		.world.storage.observers.FireAddIfHas(OnAddRelations, , , )
	}
}

// Set the mapped components of the given entity to the given values.
// Requires the entity to already have all the mapped components.
//
// Triggers an OnSetComponents event, which is not the case when assigning by
// pointer dereference or assigning to fields. This can be used to notify observers
// about component updates.
//
// This is not a component operation, so it can be performed on a locked world.
func ( *Map10[, , , , , , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
	if !.world.Alive() {
		panic("can't set components of a dead entity")
	}
	.world.storage.checkHasComponent(, .ids[0])
	.world.storage.checkHasComponent(, .ids[1])
	.world.storage.checkHasComponent(, .ids[2])
	.world.storage.checkHasComponent(, .ids[3])
	.world.storage.checkHasComponent(, .ids[4])
	.world.storage.checkHasComponent(, .ids[5])
	.world.storage.checkHasComponent(, .ids[6])
	.world.storage.checkHasComponent(, .ids[7])
	.world.storage.checkHasComponent(, .ids[8])
	.world.storage.checkHasComponent(, .ids[9])

	 := &.world.storage.entities[.id]
	 := uintptr(.row)
	*(*)(.storageA.columns[.table].Get()) = *
	*(*)(.storageB.columns[.table].Get()) = *
	*(*)(.storageC.columns[.table].Get()) = *
	*(*)(.storageD.columns[.table].Get()) = *
	*(*)(.storageE.columns[.table].Get()) = *
	*(*)(.storageF.columns[.table].Get()) = *
	*(*)(.storageG.columns[.table].Get()) = *
	*(*)(.storageH.columns[.table].Get()) = *
	*(*)(.storageI.columns[.table].Get()) = *
	*(*)(.storageJ.columns[.table].Get()) = *

	if .world.storage.observers.HasObservers(OnSetComponents) {
		 := &.world.storage.archetypes[.world.storage.tables[.table].archetype].mask
		.world.storage.observers.FireSet(, &.mask, )
	}
}

// AddBatch adds the mapped components to all entities matching the given batch filter.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map10[, , , , , , , , , ]) ( Batch,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddBatchFn adds the mapped components to all entities matching the given batch filter,
// running the given function on each. The function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map10[, , , , , , , , , ]) ( Batch,  func(Entity, *, *, *, *, *, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)

	var  func( tableID, ,  uint32)
	if  != nil {
		 = func( tableID, ,  uint32) {
			 := &.world.storage.tables[]
			 := .storageA.columns[]
			 := .storageB.columns[]
			 := .storageC.columns[]
			 := .storageD.columns[]
			 := .storageE.columns[]
			 := .storageF.columns[]
			 := .storageG.columns[]
			 := .storageH.columns[]
			 := .storageI.columns[]
			 := .storageJ.columns[]

			for  := range  {
				 := uintptr( + )
				(
					.GetEntity(),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
				)
			}
		}
	}
	.world.exchangeBatch(&, .ids, nil, .relations, )
}

// Remove the mapped components from the given entity.
func ( *Map10[, , , , , , , , , ]) ( Entity) {
	.world.remove(, .ids)
}

// RemoveBatch removes the mapped components from all entities matching the given batch filter,
// running the given function on each. The function can be nil.
func ( *Map10[, , , , , , , , , ]) ( Batch,  func( Entity)) {
	removeBatch(.world, &, .ids, )
}

// GetRelation returns the relation target of an entity for the component at the given index.
func ( *Map10[, , , , , , , , , ]) ( Entity,  int) Entity {
	if !.world.storage.entityPool.Alive() {
		panic("can't get entity relation target for a dead entity")
	}
	return .GetRelationUnchecked(, )
}

// GetRelationUnchecked returns the relation target of an entity for the component at the given index.
// In contrast to [Map10.GetRelation], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
func ( *Map10[, , , , , , , , , ]) ( Entity,  int) Entity {
	return .world.storage.getRelation(, .ids[])
}

// SetRelations sets relation targets for the given entity.
func ( *Map10[, , , , , , , , , ]) ( Entity,  ...Relation) {
	// alive check is done in World.setRelations
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	.world.setRelations(, .relations)
}

// SetRelationsBatch sets relation targets for all entities matching the given batch filter.
func ( *Map10[, , , , , , , , , ]) ( Batch,  func( Entity),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	setRelationsBatch(.world, &, , .relations)
}

// Map11 is a mapper to access 11 components of an entity.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Map2] for a usage example.
type Map11[ any,  any,  any,  any,  any,  any,  any,  any,  any,  any,  any] struct {
	mask      bitMask
	ids       []ID
	relations []relationID
	world     *World
	storageA  *componentStorage
	storageB  *componentStorage
	storageC  *componentStorage
	storageD  *componentStorage
	storageE  *componentStorage
	storageF  *componentStorage
	storageG  *componentStorage
	storageH  *componentStorage
	storageI  *componentStorage
	storageJ  *componentStorage
	storageK  *componentStorage
	archetype archetypeID
}

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

// NewMap11 creates a new [Map11].
//
// See also [Map11.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any,  any,  any,  any,  any,  any,  any,  any]( *World) *Map11[, , , , , , , , , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	return &Map11[, , , , , , , , , , ]{
		world:    ,
		ids:      ,
		mask:     newMask(...),
		storageA: &.storage.components[[0].id],
		storageB: &.storage.components[[1].id],
		storageC: &.storage.components[[2].id],
		storageD: &.storage.components[[3].id],
		storageE: &.storage.components[[4].id],
		storageF: &.storage.components[[5].id],
		storageG: &.storage.components[[6].id],
		storageH: &.storage.components[[7].id],
		storageI: &.storage.components[[8].id],
		storageJ: &.storage.components[[9].id],
		storageK: &.storage.components[[10].id],
	}
}

// NewEntity creates a new entity with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map11[, , , , , , , , , , ]) ( *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) Entity {
	return .NewEntityFn(func( *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewEntityFn creates a new entity with the mapped component and runs a callback instead of using a component for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map11[, , , , , , , , , , ]) ( func(*, *, *, *, *, *, *, *, *, *, *),  ...Relation) Entity {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntity(.ids, .relations, .archetype)
	.archetype = 

	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
			(*)(.storageG.columns[.table].Get()),
			(*)(.storageH.columns[.table].Get()),
			(*)(.storageI.columns[.table].Get()),
			(*)(.storageJ.columns[.table].Get()),
			(*)(.storageK.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireCreateEntityIfHas(, )
	if len() > 0 {
		.world.storage.observers.FireCreateEntityRelIfHas(, )
	}
	return 
}

// NewBatch creates a batch of new entities with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map11[, , , , , , , , , , ]) ( int,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.NewBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewBatchFn creates a batch of new entities with the mapped components, running the given initializer function on each.
// The initializer function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map11[, , , , , , , , , , ]) ( int,  func(Entity, *, *, *, *, *, *, *, *, *, *, *),  ...Relation) {
	.world.checkLocked()
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntities(, .ids, .relations, .archetype)
	.archetype = 

	 := .world.storage.observers.HasObservers(OnCreateEntity)
	 := len() > 0 && .world.storage.observers.HasObservers(OnAddRelations)
	 :=  ||  ||  != nil
	var  uint8
	if  {
		 = .world.lock()
	}

	if  != nil {
		 := &.world.storage.tables[]
		 := .storageA.columns[]
		 := .storageB.columns[]
		 := .storageC.columns[]
		 := .storageD.columns[]
		 := .storageE.columns[]
		 := .storageF.columns[]
		 := .storageG.columns[]
		 := .storageH.columns[]
		 := .storageI.columns[]
		 := .storageJ.columns[]
		 := .storageK.columns[]
		for  := range  {
			 := uintptr( + )
			(
				.GetEntity(),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
			)
		}
	}

	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityBatch(, , &.mask)
	}
	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityRelBatch(, , &.mask)
	}

	if  {
		.world.unlock()
	}
}

// Get returns the mapped components for the given entity.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map11[, , , , , , , , , , ]) ( Entity) (*, *, *, *, *, *, *, *, *, *, *) {
	if !.world.storage.entityPool.Alive() {
		panic("can't get components of a dead entity")
	}
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, ), get[](.storageG, ), get[](.storageH, ), get[](.storageI, ), get[](.storageJ, ), get[](.storageK, )
}

// GetUnchecked returns the mapped components for the given entity.
// In contrast to [Map11.Get], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map11[, , , , , , , , , , ]) ( Entity) (*, *, *, *, *, *, *, *, *, *, *) {
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, ), get[](.storageG, ), get[](.storageH, ), get[](.storageI, ), get[](.storageJ, ), get[](.storageK, )
}

// HasAll return whether the given entity has all mapped components.
//
// Using [Map11.Get] and checking for nil pointer may be faster
// than calling [Map11.HasAll] and [Map11.Get] subsequently.
func ( *Map11[, , , , , , , , , , ]) ( Entity) bool {
	if !.world.Alive() {
		panic("can't check components of a dead entity")
	}
	 := .world.storage.entities[.id].table
	return .storageA.columns[] != nil &&
		.storageB.columns[] != nil &&
		.storageC.columns[] != nil &&
		.storageD.columns[] != nil &&
		.storageE.columns[] != nil &&
		.storageF.columns[] != nil &&
		.storageG.columns[] != nil &&
		.storageH.columns[] != nil &&
		.storageI.columns[] != nil &&
		.storageJ.columns[] != nil &&
		.storageK.columns[] != nil
}

// Add the mapped components to the given entity.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map11[, , , , , , , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddFn(, func( *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddFn adds the mapped components to the given entity and runs a callback instead of using components for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map11[, , , , , , , , , , ]) ( Entity,  func(*, *, *, *, *, *, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	,  := .world.add(, .ids, .relations)
	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
			(*)(.storageG.columns[.table].Get()),
			(*)(.storageH.columns[.table].Get()),
			(*)(.storageI.columns[.table].Get()),
			(*)(.storageJ.columns[.table].Get()),
			(*)(.storageK.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireAddIfHas(OnAddComponents, , , )
	if len() > 0 {
		.world.storage.observers.FireAddIfHas(OnAddRelations, , , )
	}
}

// Set the mapped components of the given entity to the given values.
// Requires the entity to already have all the mapped components.
//
// Triggers an OnSetComponents event, which is not the case when assigning by
// pointer dereference or assigning to fields. This can be used to notify observers
// about component updates.
//
// This is not a component operation, so it can be performed on a locked world.
func ( *Map11[, , , , , , , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
	if !.world.Alive() {
		panic("can't set components of a dead entity")
	}
	.world.storage.checkHasComponent(, .ids[0])
	.world.storage.checkHasComponent(, .ids[1])
	.world.storage.checkHasComponent(, .ids[2])
	.world.storage.checkHasComponent(, .ids[3])
	.world.storage.checkHasComponent(, .ids[4])
	.world.storage.checkHasComponent(, .ids[5])
	.world.storage.checkHasComponent(, .ids[6])
	.world.storage.checkHasComponent(, .ids[7])
	.world.storage.checkHasComponent(, .ids[8])
	.world.storage.checkHasComponent(, .ids[9])
	.world.storage.checkHasComponent(, .ids[10])

	 := &.world.storage.entities[.id]
	 := uintptr(.row)
	*(*)(.storageA.columns[.table].Get()) = *
	*(*)(.storageB.columns[.table].Get()) = *
	*(*)(.storageC.columns[.table].Get()) = *
	*(*)(.storageD.columns[.table].Get()) = *
	*(*)(.storageE.columns[.table].Get()) = *
	*(*)(.storageF.columns[.table].Get()) = *
	*(*)(.storageG.columns[.table].Get()) = *
	*(*)(.storageH.columns[.table].Get()) = *
	*(*)(.storageI.columns[.table].Get()) = *
	*(*)(.storageJ.columns[.table].Get()) = *
	*(*)(.storageK.columns[.table].Get()) = *

	if .world.storage.observers.HasObservers(OnSetComponents) {
		 := &.world.storage.archetypes[.world.storage.tables[.table].archetype].mask
		.world.storage.observers.FireSet(, &.mask, )
	}
}

// AddBatch adds the mapped components to all entities matching the given batch filter.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map11[, , , , , , , , , , ]) ( Batch,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddBatchFn adds the mapped components to all entities matching the given batch filter,
// running the given function on each. The function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map11[, , , , , , , , , , ]) ( Batch,  func(Entity, *, *, *, *, *, *, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)

	var  func( tableID, ,  uint32)
	if  != nil {
		 = func( tableID, ,  uint32) {
			 := &.world.storage.tables[]
			 := .storageA.columns[]
			 := .storageB.columns[]
			 := .storageC.columns[]
			 := .storageD.columns[]
			 := .storageE.columns[]
			 := .storageF.columns[]
			 := .storageG.columns[]
			 := .storageH.columns[]
			 := .storageI.columns[]
			 := .storageJ.columns[]
			 := .storageK.columns[]

			for  := range  {
				 := uintptr( + )
				(
					.GetEntity(),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
				)
			}
		}
	}
	.world.exchangeBatch(&, .ids, nil, .relations, )
}

// Remove the mapped components from the given entity.
func ( *Map11[, , , , , , , , , , ]) ( Entity) {
	.world.remove(, .ids)
}

// RemoveBatch removes the mapped components from all entities matching the given batch filter,
// running the given function on each. The function can be nil.
func ( *Map11[, , , , , , , , , , ]) ( Batch,  func( Entity)) {
	removeBatch(.world, &, .ids, )
}

// GetRelation returns the relation target of an entity for the component at the given index.
func ( *Map11[, , , , , , , , , , ]) ( Entity,  int) Entity {
	if !.world.storage.entityPool.Alive() {
		panic("can't get entity relation target for a dead entity")
	}
	return .GetRelationUnchecked(, )
}

// GetRelationUnchecked returns the relation target of an entity for the component at the given index.
// In contrast to [Map11.GetRelation], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
func ( *Map11[, , , , , , , , , , ]) ( Entity,  int) Entity {
	return .world.storage.getRelation(, .ids[])
}

// SetRelations sets relation targets for the given entity.
func ( *Map11[, , , , , , , , , , ]) ( Entity,  ...Relation) {
	// alive check is done in World.setRelations
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	.world.setRelations(, .relations)
}

// SetRelationsBatch sets relation targets for all entities matching the given batch filter.
func ( *Map11[, , , , , , , , , , ]) ( Batch,  func( Entity),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	setRelationsBatch(.world, &, , .relations)
}

// Map12 is a mapper to access 12 components of an entity.
//
// Instances should be created during initialization and stored, e.g. in systems.
//
// See [Map2] for a usage example.
type Map12[ any,  any,  any,  any,  any,  any,  any,  any,  any,  any,  any,  any] struct {
	mask      bitMask
	ids       []ID
	relations []relationID
	world     *World
	storageA  *componentStorage
	storageB  *componentStorage
	storageC  *componentStorage
	storageD  *componentStorage
	storageE  *componentStorage
	storageF  *componentStorage
	storageG  *componentStorage
	storageH  *componentStorage
	storageI  *componentStorage
	storageJ  *componentStorage
	storageK  *componentStorage
	storageL  *componentStorage
	archetype archetypeID
}

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

// NewMap12 creates a new [Map12].
//
// See also [Map12.New] for a shortcut when constructing an already defined instance.
func [ any,  any,  any,  any,  any,  any,  any,  any,  any,  any,  any,  any]( *World) *Map12[, , , , , , , , , , , ] {
	 := []ID{
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
		ComponentID[](),
	}
	return &Map12[, , , , , , , , , , , ]{
		world:    ,
		ids:      ,
		mask:     newMask(...),
		storageA: &.storage.components[[0].id],
		storageB: &.storage.components[[1].id],
		storageC: &.storage.components[[2].id],
		storageD: &.storage.components[[3].id],
		storageE: &.storage.components[[4].id],
		storageF: &.storage.components[[5].id],
		storageG: &.storage.components[[6].id],
		storageH: &.storage.components[[7].id],
		storageI: &.storage.components[[8].id],
		storageJ: &.storage.components[[9].id],
		storageK: &.storage.components[[10].id],
		storageL: &.storage.components[[11].id],
	}
}

// NewEntity creates a new entity with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map12[, , , , , , , , , , , ]) ( *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) Entity {
	return .NewEntityFn(func( *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewEntityFn creates a new entity with the mapped component and runs a callback instead of using a component for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map12[, , , , , , , , , , , ]) ( func(*, *, *, *, *, *, *, *, *, *, *, *),  ...Relation) Entity {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntity(.ids, .relations, .archetype)
	.archetype = 

	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
			(*)(.storageG.columns[.table].Get()),
			(*)(.storageH.columns[.table].Get()),
			(*)(.storageI.columns[.table].Get()),
			(*)(.storageJ.columns[.table].Get()),
			(*)(.storageK.columns[.table].Get()),
			(*)(.storageL.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireCreateEntityIfHas(, )
	if len() > 0 {
		.world.storage.observers.FireCreateEntityRelIfHas(, )
	}
	return 
}

// NewBatch creates a batch of new entities with the mapped components.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
func ( *Map12[, , , , , , , , , , , ]) ( int,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.NewBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// NewBatchFn creates a batch of new entities with the mapped components, running the given initializer function on each.
// The initializer function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided via the variadic arguments.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map12[, , , , , , , , , , , ]) ( int,  func(Entity, *, *, *, *, *, *, *, *, *, *, *, *),  ...Relation) {
	.world.checkLocked()
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	, ,  := .world.newEntities(, .ids, .relations, .archetype)
	.archetype = 

	 := .world.storage.observers.HasObservers(OnCreateEntity)
	 := len() > 0 && .world.storage.observers.HasObservers(OnAddRelations)
	 :=  ||  ||  != nil
	var  uint8
	if  {
		 = .world.lock()
	}

	if  != nil {
		 := &.world.storage.tables[]
		 := .storageA.columns[]
		 := .storageB.columns[]
		 := .storageC.columns[]
		 := .storageD.columns[]
		 := .storageE.columns[]
		 := .storageF.columns[]
		 := .storageG.columns[]
		 := .storageH.columns[]
		 := .storageI.columns[]
		 := .storageJ.columns[]
		 := .storageK.columns[]
		 := .storageL.columns[]
		for  := range  {
			 := uintptr( + )
			(
				.GetEntity(),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
				(*)(.Get()),
			)
		}
	}

	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityBatch(, , &.mask)
	}
	if  {
		 := &.world.storage.tables[]
		.world.storage.observers.FireCreateEntityRelBatch(, , &.mask)
	}

	if  {
		.world.unlock()
	}
}

// Get returns the mapped components for the given entity.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map12[, , , , , , , , , , , ]) ( Entity) (*, *, *, *, *, *, *, *, *, *, *, *) {
	if !.world.storage.entityPool.Alive() {
		panic("can't get components of a dead entity")
	}
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, ), get[](.storageG, ), get[](.storageH, ), get[](.storageI, ), get[](.storageJ, ), get[](.storageK, ), get[](.storageL, )
}

// GetUnchecked returns the mapped components for the given entity.
// In contrast to [Map12.Get], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
//
// Return nil for components the entity is missing.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map12[, , , , , , , , , , , ]) ( Entity) (*, *, *, *, *, *, *, *, *, *, *, *) {
	 := &.world.storage.entities[.id]
	return get[](.storageA, ), get[](.storageB, ), get[](.storageC, ), get[](.storageD, ), get[](.storageE, ), get[](.storageF, ), get[](.storageG, ), get[](.storageH, ), get[](.storageI, ), get[](.storageJ, ), get[](.storageK, ), get[](.storageL, )
}

// HasAll return whether the given entity has all mapped components.
//
// Using [Map12.Get] and checking for nil pointer may be faster
// than calling [Map12.HasAll] and [Map12.Get] subsequently.
func ( *Map12[, , , , , , , , , , , ]) ( Entity) bool {
	if !.world.Alive() {
		panic("can't check components of a dead entity")
	}
	 := .world.storage.entities[.id].table
	return .storageA.columns[] != nil &&
		.storageB.columns[] != nil &&
		.storageC.columns[] != nil &&
		.storageD.columns[] != nil &&
		.storageE.columns[] != nil &&
		.storageF.columns[] != nil &&
		.storageG.columns[] != nil &&
		.storageH.columns[] != nil &&
		.storageI.columns[] != nil &&
		.storageJ.columns[] != nil &&
		.storageK.columns[] != nil &&
		.storageL.columns[] != nil
}

// Add the mapped components to the given entity.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map12[, , , , , , , , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddFn(, func( *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddFn adds the mapped components to the given entity and runs a callback instead of using components for initialization.
// The callback can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map12[, , , , , , , , , , , ]) ( Entity,  func(*, *, *, *, *, *, *, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	,  := .world.add(, .ids, .relations)
	if  != nil {
		 := &.world.storage.entities[.id]
		 := uintptr(.row)
		(
			(*)(.storageA.columns[.table].Get()),
			(*)(.storageB.columns[.table].Get()),
			(*)(.storageC.columns[.table].Get()),
			(*)(.storageD.columns[.table].Get()),
			(*)(.storageE.columns[.table].Get()),
			(*)(.storageF.columns[.table].Get()),
			(*)(.storageG.columns[.table].Get()),
			(*)(.storageH.columns[.table].Get()),
			(*)(.storageI.columns[.table].Get()),
			(*)(.storageJ.columns[.table].Get()),
			(*)(.storageK.columns[.table].Get()),
			(*)(.storageL.columns[.table].Get()),
		)
	}
	.world.storage.observers.FireAddIfHas(OnAddComponents, , , )
	if len() > 0 {
		.world.storage.observers.FireAddIfHas(OnAddRelations, , , )
	}
}

// Set the mapped components of the given entity to the given values.
// Requires the entity to already have all the mapped components.
//
// Triggers an OnSetComponents event, which is not the case when assigning by
// pointer dereference or assigning to fields. This can be used to notify observers
// about component updates.
//
// This is not a component operation, so it can be performed on a locked world.
func ( *Map12[, , , , , , , , , , , ]) ( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
	if !.world.Alive() {
		panic("can't set components of a dead entity")
	}
	.world.storage.checkHasComponent(, .ids[0])
	.world.storage.checkHasComponent(, .ids[1])
	.world.storage.checkHasComponent(, .ids[2])
	.world.storage.checkHasComponent(, .ids[3])
	.world.storage.checkHasComponent(, .ids[4])
	.world.storage.checkHasComponent(, .ids[5])
	.world.storage.checkHasComponent(, .ids[6])
	.world.storage.checkHasComponent(, .ids[7])
	.world.storage.checkHasComponent(, .ids[8])
	.world.storage.checkHasComponent(, .ids[9])
	.world.storage.checkHasComponent(, .ids[10])
	.world.storage.checkHasComponent(, .ids[11])

	 := &.world.storage.entities[.id]
	 := uintptr(.row)
	*(*)(.storageA.columns[.table].Get()) = *
	*(*)(.storageB.columns[.table].Get()) = *
	*(*)(.storageC.columns[.table].Get()) = *
	*(*)(.storageD.columns[.table].Get()) = *
	*(*)(.storageE.columns[.table].Get()) = *
	*(*)(.storageF.columns[.table].Get()) = *
	*(*)(.storageG.columns[.table].Get()) = *
	*(*)(.storageH.columns[.table].Get()) = *
	*(*)(.storageI.columns[.table].Get()) = *
	*(*)(.storageJ.columns[.table].Get()) = *
	*(*)(.storageK.columns[.table].Get()) = *
	*(*)(.storageL.columns[.table].Get()) = *

	if .world.storage.observers.HasObservers(OnSetComponents) {
		 := &.world.storage.archetypes[.world.storage.tables[.table].archetype].mask
		.world.storage.observers.FireSet(, &.mask, )
	}
}

// AddBatch adds the mapped components to all entities matching the given batch filter.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
func ( *Map12[, , , , , , , , , , , ]) ( Batch,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  ...Relation) {
	.AddBatchFn(, func( Entity,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *,  *) {
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
		* = *
	}, ...)
}

// AddBatchFn adds the mapped components to all entities matching the given batch filter,
// running the given function on each. The function can be nil.
//
// For each mapped component that is a relationships (see [RelationMarker]),
// a relation target entity must be provided.
//
// ⚠️ Do not store the obtained pointers outside of the current context!
func ( *Map12[, , , , , , , , , , , ]) ( Batch,  func(Entity, *, *, *, *, *, *, *, *, *, *, *, *),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)

	var  func( tableID, ,  uint32)
	if  != nil {
		 = func( tableID, ,  uint32) {
			 := &.world.storage.tables[]
			 := .storageA.columns[]
			 := .storageB.columns[]
			 := .storageC.columns[]
			 := .storageD.columns[]
			 := .storageE.columns[]
			 := .storageF.columns[]
			 := .storageG.columns[]
			 := .storageH.columns[]
			 := .storageI.columns[]
			 := .storageJ.columns[]
			 := .storageK.columns[]
			 := .storageL.columns[]

			for  := range  {
				 := uintptr( + )
				(
					.GetEntity(),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
					(*)(.Get()),
				)
			}
		}
	}
	.world.exchangeBatch(&, .ids, nil, .relations, )
}

// Remove the mapped components from the given entity.
func ( *Map12[, , , , , , , , , , , ]) ( Entity) {
	.world.remove(, .ids)
}

// RemoveBatch removes the mapped components from all entities matching the given batch filter,
// running the given function on each. The function can be nil.
func ( *Map12[, , , , , , , , , , , ]) ( Batch,  func( Entity)) {
	removeBatch(.world, &, .ids, )
}

// GetRelation returns the relation target of an entity for the component at the given index.
func ( *Map12[, , , , , , , , , , , ]) ( Entity,  int) Entity {
	if !.world.storage.entityPool.Alive() {
		panic("can't get entity relation target for a dead entity")
	}
	return .GetRelationUnchecked(, )
}

// GetRelationUnchecked returns the relation target of an entity for the component at the given index.
// In contrast to [Map12.GetRelation], it does not check whether the entity is alive.
// Can be used as an optimization when it is certain that the entity is alive.
func ( *Map12[, , , , , , , , , , , ]) ( Entity,  int) Entity {
	return .world.storage.getRelation(, .ids[])
}

// SetRelations sets relation targets for the given entity.
func ( *Map12[, , , , , , , , , , , ]) ( Entity,  ...Relation) {
	// alive check is done in World.setRelations
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	.world.setRelations(, .relations)
}

// SetRelationsBatch sets relation targets for all entities matching the given batch filter.
func ( *Map12[, , , , , , , , , , , ]) ( Batch,  func( Entity),  ...Relation) {
	.relations = relationSlice().ToRelations(.world, &.mask, .ids, .relations[:0], false)
	setRelationsBatch(.world, &, , .relations)
}