Documentation
¶
Overview ¶
Package ecs provides the core API of Ark, an Entity Component System (ECS) for Go.
See the top-level module github.com/mlange-42/ark for an overview.
🕮 Also read Ark's User Guide and take a look at the examples!
Outline ¶
- World provides basic functionality that does not require generics, like World.NewEntity, World.Alive, World.RemoveEntity, etc.
- Filter1, Filter2, etc. provide filters for querying entities by their components.
- Query1, Query2, etc. are the actual query iterators, and provide functionality like Query1.Next, Query1.Get and Query1.Entity.
- Map1, Map2, etc. provide access to and manipulation of multiple components. like Map1.Get, Map1.Add, Map1.Remove, etc.
- Map provides access to a single component, like Map.Get and Map.Add, Map.Remove.
- Exchange1, Exchange2 etc. allows to add, remove and exchange components.
- Resource provides access the world's Resources.
- See the separate module ark-serde for serialization.
ECS Manipulations ¶
This section gives an overview on how to achieve typical ECS operations in Ark.
Access data:
- Create a filter: NewFilter2.
- Create a Query2: Filter2.Query.
- Iterate a Query: Query2.Next, Query2.Get.
- Access components of entities: Map.Get, Map2.Get.
- Access relationship targets: Map.GetRelation, Map2.GetRelation.
Manipulate a single Entity:
- Create an entity: World.NewEntity
- Create an entity with components: Map2.NewEntity, Map2.NewEntityFn.
- Add components to an entity: Map.Add, Map.AddFn, Map2.Add, Map2.AddFn, Exchange2.Add, Exchange2.AddFn.
- Remove components from an entity: Map.Remove, Map2.Remove, Exchange2.Remove.
- Exchange components of an entity: Exchange2.Exchange, Exchange2.ExchangeFn.
- Change relationship targets: Map.SetRelation, Map2.SetRelations.
- Remove an entity from the world: World.RemoveEntity.
Manipulate entities in batches:
- Create entities: World.NewEntities
- Create entities with components: Map2.NewBatch, Map2.NewBatchFn.
- Add components to entities: Map2.AddBatch, Map2.AddBatchFn, Exchange2.AddBatch, Exchange2.AddBatchFn.
- Remove components from entities: Map2.RemoveBatch, Exchange2.RemoveBatch.
- Exchange components of entities: Exchange2.ExchangeBatch, Exchange2.ExchangeBatchFn.
- Change relationship targets: Map2.SetRelationsBatch.
- Remove entities from the world: World.RemoveEntities.
Build tags ¶
Ark provides two build tags:
- ark_tiny: Reduces the maximum number of components to 64, for faster mask-related operations and smaller archetype memory footprint.
- ark_debug: Improves error messages on incorrect use, at the cost of performance. Use this if you get panics from queries or maps.
When building your application, use them like this:
go build -tags ark_tiny . go build -tags ark_debug . go build -tags ark_tiny,ark_debug .
Index ¶
- func GetResource[T any](w *World) *T
- func ResourceType(w *World, id ResID) (reflect.Type, bool)
- type Batch
- type Comp
- type CompInfo
- type Entity
- type EntityDump
- type Exchange1
- func (ex *Exchange1[A]) Add(entity Entity, a *A, rel ...Relation)
- func (ex *Exchange1[A]) AddBatch(batch *Batch, a *A, rel ...Relation)
- func (ex *Exchange1[A]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A), rel ...Relation)
- func (ex *Exchange1[A]) AddFn(entity Entity, fn func(a *A), rel ...Relation)
- func (ex *Exchange1[A]) Exchange(entity Entity, a *A, rel ...Relation)
- func (ex *Exchange1[A]) ExchangeBatch(batch *Batch, a *A, rel ...Relation)
- func (ex *Exchange1[A]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A), rel ...Relation)
- func (ex *Exchange1[A]) ExchangeFn(entity Entity, fn func(a *A), rel ...Relation)
- func (_ *Exchange1[A]) New(world *World) *Exchange1[A]
- func (ex *Exchange1[A]) Remove(entity Entity)
- func (ex *Exchange1[A]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (ex *Exchange1[A]) Removes(components ...Comp) *Exchange1[A]
- type Exchange2
- func (ex *Exchange2[A, B]) Add(entity Entity, a *A, b *B, rel ...Relation)
- func (ex *Exchange2[A, B]) AddBatch(batch *Batch, a *A, b *B, rel ...Relation)
- func (ex *Exchange2[A, B]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B), rel ...Relation)
- func (ex *Exchange2[A, B]) AddFn(entity Entity, fn func(a *A, b *B), rel ...Relation)
- func (ex *Exchange2[A, B]) Exchange(entity Entity, a *A, b *B, rel ...Relation)
- func (ex *Exchange2[A, B]) ExchangeBatch(batch *Batch, a *A, b *B, rel ...Relation)
- func (ex *Exchange2[A, B]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B), rel ...Relation)
- func (ex *Exchange2[A, B]) ExchangeFn(entity Entity, fn func(a *A, b *B), rel ...Relation)
- func (_ *Exchange2[A, B]) New(world *World) *Exchange2[A, B]
- func (ex *Exchange2[A, B]) Remove(entity Entity)
- func (ex *Exchange2[A, B]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (ex *Exchange2[A, B]) Removes(components ...Comp) *Exchange2[A, B]
- type Exchange3
- func (ex *Exchange3[A, B, C]) Add(entity Entity, a *A, b *B, c *C, rel ...Relation)
- func (ex *Exchange3[A, B, C]) AddBatch(batch *Batch, a *A, b *B, c *C, rel ...Relation)
- func (ex *Exchange3[A, B, C]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C), rel ...Relation)
- func (ex *Exchange3[A, B, C]) AddFn(entity Entity, fn func(a *A, b *B, c *C), rel ...Relation)
- func (ex *Exchange3[A, B, C]) Exchange(entity Entity, a *A, b *B, c *C, rel ...Relation)
- func (ex *Exchange3[A, B, C]) ExchangeBatch(batch *Batch, a *A, b *B, c *C, rel ...Relation)
- func (ex *Exchange3[A, B, C]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C), rel ...Relation)
- func (ex *Exchange3[A, B, C]) ExchangeFn(entity Entity, fn func(a *A, b *B, c *C), rel ...Relation)
- func (_ *Exchange3[A, B, C]) New(world *World) *Exchange3[A, B, C]
- func (ex *Exchange3[A, B, C]) Remove(entity Entity)
- func (ex *Exchange3[A, B, C]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (ex *Exchange3[A, B, C]) Removes(components ...Comp) *Exchange3[A, B, C]
- type Exchange4
- func (ex *Exchange4[A, B, C, D]) Add(entity Entity, a *A, b *B, c *C, d *D, rel ...Relation)
- func (ex *Exchange4[A, B, C, D]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, rel ...Relation)
- func (ex *Exchange4[A, B, C, D]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D), rel ...Relation)
- func (ex *Exchange4[A, B, C, D]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D), rel ...Relation)
- func (ex *Exchange4[A, B, C, D]) Exchange(entity Entity, a *A, b *B, c *C, d *D, rel ...Relation)
- func (ex *Exchange4[A, B, C, D]) ExchangeBatch(batch *Batch, a *A, b *B, c *C, d *D, rel ...Relation)
- func (ex *Exchange4[A, B, C, D]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D), rel ...Relation)
- func (ex *Exchange4[A, B, C, D]) ExchangeFn(entity Entity, fn func(a *A, b *B, c *C, d *D), rel ...Relation)
- func (_ *Exchange4[A, B, C, D]) New(world *World) *Exchange4[A, B, C, D]
- func (ex *Exchange4[A, B, C, D]) Remove(entity Entity)
- func (ex *Exchange4[A, B, C, D]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (ex *Exchange4[A, B, C, D]) Removes(components ...Comp) *Exchange4[A, B, C, D]
- type Exchange5
- func (ex *Exchange5[A, B, C, D, E]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, rel ...Relation)
- func (ex *Exchange5[A, B, C, D, E]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, rel ...Relation)
- func (ex *Exchange5[A, B, C, D, E]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E), ...)
- func (ex *Exchange5[A, B, C, D, E]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E), rel ...Relation)
- func (ex *Exchange5[A, B, C, D, E]) Exchange(entity Entity, a *A, b *B, c *C, d *D, e *E, rel ...Relation)
- func (ex *Exchange5[A, B, C, D, E]) ExchangeBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, rel ...Relation)
- func (ex *Exchange5[A, B, C, D, E]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E), ...)
- func (ex *Exchange5[A, B, C, D, E]) ExchangeFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E), rel ...Relation)
- func (_ *Exchange5[A, B, C, D, E]) New(world *World) *Exchange5[A, B, C, D, E]
- func (ex *Exchange5[A, B, C, D, E]) Remove(entity Entity)
- func (ex *Exchange5[A, B, C, D, E]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (ex *Exchange5[A, B, C, D, E]) Removes(components ...Comp) *Exchange5[A, B, C, D, E]
- type Exchange6
- func (ex *Exchange6[A, B, C, D, E, F]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
- func (ex *Exchange6[A, B, C, D, E, F]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
- func (ex *Exchange6[A, B, C, D, E, F]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F), ...)
- func (ex *Exchange6[A, B, C, D, E, F]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F), rel ...Relation)
- func (ex *Exchange6[A, B, C, D, E, F]) Exchange(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
- func (ex *Exchange6[A, B, C, D, E, F]) ExchangeBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
- func (ex *Exchange6[A, B, C, D, E, F]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F), ...)
- func (ex *Exchange6[A, B, C, D, E, F]) ExchangeFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F), rel ...Relation)
- func (_ *Exchange6[A, B, C, D, E, F]) New(world *World) *Exchange6[A, B, C, D, E, F]
- func (ex *Exchange6[A, B, C, D, E, F]) Remove(entity Entity)
- func (ex *Exchange6[A, B, C, D, E, F]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (ex *Exchange6[A, B, C, D, E, F]) Removes(components ...Comp) *Exchange6[A, B, C, D, E, F]
- type Exchange7
- func (ex *Exchange7[A, B, C, D, E, F, G]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
- func (ex *Exchange7[A, B, C, D, E, F, G]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
- func (ex *Exchange7[A, B, C, D, E, F, G]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G), ...)
- func (ex *Exchange7[A, B, C, D, E, F, G]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G), ...)
- func (ex *Exchange7[A, B, C, D, E, F, G]) Exchange(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
- func (ex *Exchange7[A, B, C, D, E, F, G]) ExchangeBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
- func (ex *Exchange7[A, B, C, D, E, F, G]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G), ...)
- func (ex *Exchange7[A, B, C, D, E, F, G]) ExchangeFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G), ...)
- func (_ *Exchange7[A, B, C, D, E, F, G]) New(world *World) *Exchange7[A, B, C, D, E, F, G]
- func (ex *Exchange7[A, B, C, D, E, F, G]) Remove(entity Entity)
- func (ex *Exchange7[A, B, C, D, E, F, G]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (ex *Exchange7[A, B, C, D, E, F, G]) Removes(components ...Comp) *Exchange7[A, B, C, D, E, F, G]
- type Exchange8
- func (ex *Exchange8[A, B, C, D, E, F, G, H]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
- func (ex *Exchange8[A, B, C, D, E, F, G, H]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
- func (ex *Exchange8[A, B, C, D, E, F, G, H]) AddBatchFn(batch *Batch, ...)
- func (ex *Exchange8[A, B, C, D, E, F, G, H]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H), ...)
- func (ex *Exchange8[A, B, C, D, E, F, G, H]) Exchange(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
- func (ex *Exchange8[A, B, C, D, E, F, G, H]) ExchangeBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
- func (ex *Exchange8[A, B, C, D, E, F, G, H]) ExchangeBatchFn(batch *Batch, ...)
- func (ex *Exchange8[A, B, C, D, E, F, G, H]) ExchangeFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H), ...)
- func (_ *Exchange8[A, B, C, D, E, F, G, H]) New(world *World) *Exchange8[A, B, C, D, E, F, G, H]
- func (ex *Exchange8[A, B, C, D, E, F, G, H]) Remove(entity Entity)
- func (ex *Exchange8[A, B, C, D, E, F, G, H]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (ex *Exchange8[A, B, C, D, E, F, G, H]) Removes(components ...Comp) *Exchange8[A, B, C, D, E, F, G, H]
- type Filter0
- func (f *Filter0) Batch(rel ...Relation) *Batch
- func (f *Filter0) Exclusive() *Filter0
- func (*Filter0) New(world *World) *Filter0
- func (f *Filter0) Query(rel ...Relation) Query0
- func (f *Filter0) Register() *Filter0
- func (f *Filter0) Relations(rel ...Relation) *Filter0
- func (f *Filter0) Unregister()
- func (f *Filter0) With(comps ...Comp) *Filter0
- func (f *Filter0) Without(comps ...Comp) *Filter0
- type Filter1
- func (f *Filter1[A]) Batch(rel ...Relation) *Batch
- func (f *Filter1[A]) Exclusive() *Filter1[A]
- func (*Filter1[A]) New(world *World) *Filter1[A]
- func (f *Filter1[A]) Query(rel ...Relation) Query1[A]
- func (f *Filter1[A]) Register() *Filter1[A]
- func (f *Filter1[A]) Relations(rel ...Relation) *Filter1[A]
- func (f *Filter1[A]) Unregister()
- func (f *Filter1[A]) With(comps ...Comp) *Filter1[A]
- func (f *Filter1[A]) Without(comps ...Comp) *Filter1[A]
- type Filter2
- func (f *Filter2[A, B]) Batch(rel ...Relation) *Batch
- func (f *Filter2[A, B]) Exclusive() *Filter2[A, B]
- func (*Filter2[A, B]) New(world *World) *Filter2[A, B]
- func (f *Filter2[A, B]) Query(rel ...Relation) Query2[A, B]
- func (f *Filter2[A, B]) Register() *Filter2[A, B]
- func (f *Filter2[A, B]) Relations(rel ...Relation) *Filter2[A, B]
- func (f *Filter2[A, B]) Unregister()
- func (f *Filter2[A, B]) With(comps ...Comp) *Filter2[A, B]
- func (f *Filter2[A, B]) Without(comps ...Comp) *Filter2[A, B]
- type Filter3
- func (f *Filter3[A, B, C]) Batch(rel ...Relation) *Batch
- func (f *Filter3[A, B, C]) Exclusive() *Filter3[A, B, C]
- func (*Filter3[A, B, C]) New(world *World) *Filter3[A, B, C]
- func (f *Filter3[A, B, C]) Query(rel ...Relation) Query3[A, B, C]
- func (f *Filter3[A, B, C]) Register() *Filter3[A, B, C]
- func (f *Filter3[A, B, C]) Relations(rel ...Relation) *Filter3[A, B, C]
- func (f *Filter3[A, B, C]) Unregister()
- func (f *Filter3[A, B, C]) With(comps ...Comp) *Filter3[A, B, C]
- func (f *Filter3[A, B, C]) Without(comps ...Comp) *Filter3[A, B, C]
- type Filter4
- func (f *Filter4[A, B, C, D]) Batch(rel ...Relation) *Batch
- func (f *Filter4[A, B, C, D]) Exclusive() *Filter4[A, B, C, D]
- func (*Filter4[A, B, C, D]) New(world *World) *Filter4[A, B, C, D]
- func (f *Filter4[A, B, C, D]) Query(rel ...Relation) Query4[A, B, C, D]
- func (f *Filter4[A, B, C, D]) Register() *Filter4[A, B, C, D]
- func (f *Filter4[A, B, C, D]) Relations(rel ...Relation) *Filter4[A, B, C, D]
- func (f *Filter4[A, B, C, D]) Unregister()
- func (f *Filter4[A, B, C, D]) With(comps ...Comp) *Filter4[A, B, C, D]
- func (f *Filter4[A, B, C, D]) Without(comps ...Comp) *Filter4[A, B, C, D]
- type Filter5
- func (f *Filter5[A, B, C, D, E]) Batch(rel ...Relation) *Batch
- func (f *Filter5[A, B, C, D, E]) Exclusive() *Filter5[A, B, C, D, E]
- func (*Filter5[A, B, C, D, E]) New(world *World) *Filter5[A, B, C, D, E]
- func (f *Filter5[A, B, C, D, E]) Query(rel ...Relation) Query5[A, B, C, D, E]
- func (f *Filter5[A, B, C, D, E]) Register() *Filter5[A, B, C, D, E]
- func (f *Filter5[A, B, C, D, E]) Relations(rel ...Relation) *Filter5[A, B, C, D, E]
- func (f *Filter5[A, B, C, D, E]) Unregister()
- func (f *Filter5[A, B, C, D, E]) With(comps ...Comp) *Filter5[A, B, C, D, E]
- func (f *Filter5[A, B, C, D, E]) Without(comps ...Comp) *Filter5[A, B, C, D, E]
- type Filter6
- func (f *Filter6[A, B, C, D, E, F]) Batch(rel ...Relation) *Batch
- func (f *Filter6[A, B, C, D, E, F]) Exclusive() *Filter6[A, B, C, D, E, F]
- func (*Filter6[A, B, C, D, E, F]) New(world *World) *Filter6[A, B, C, D, E, F]
- func (f *Filter6[A, B, C, D, E, F]) Query(rel ...Relation) Query6[A, B, C, D, E, F]
- func (f *Filter6[A, B, C, D, E, F]) Register() *Filter6[A, B, C, D, E, F]
- func (f *Filter6[A, B, C, D, E, F]) Relations(rel ...Relation) *Filter6[A, B, C, D, E, F]
- func (f *Filter6[A, B, C, D, E, F]) Unregister()
- func (f *Filter6[A, B, C, D, E, F]) With(comps ...Comp) *Filter6[A, B, C, D, E, F]
- func (f *Filter6[A, B, C, D, E, F]) Without(comps ...Comp) *Filter6[A, B, C, D, E, F]
- type Filter7
- func (f *Filter7[A, B, C, D, E, F, G]) Batch(rel ...Relation) *Batch
- func (f *Filter7[A, B, C, D, E, F, G]) Exclusive() *Filter7[A, B, C, D, E, F, G]
- func (*Filter7[A, B, C, D, E, F, G]) New(world *World) *Filter7[A, B, C, D, E, F, G]
- func (f *Filter7[A, B, C, D, E, F, G]) Query(rel ...Relation) Query7[A, B, C, D, E, F, G]
- func (f *Filter7[A, B, C, D, E, F, G]) Register() *Filter7[A, B, C, D, E, F, G]
- func (f *Filter7[A, B, C, D, E, F, G]) Relations(rel ...Relation) *Filter7[A, B, C, D, E, F, G]
- func (f *Filter7[A, B, C, D, E, F, G]) Unregister()
- func (f *Filter7[A, B, C, D, E, F, G]) With(comps ...Comp) *Filter7[A, B, C, D, E, F, G]
- func (f *Filter7[A, B, C, D, E, F, G]) Without(comps ...Comp) *Filter7[A, B, C, D, E, F, G]
- type Filter8
- func (f *Filter8[A, B, C, D, E, F, G, H]) Batch(rel ...Relation) *Batch
- func (f *Filter8[A, B, C, D, E, F, G, H]) Exclusive() *Filter8[A, B, C, D, E, F, G, H]
- func (*Filter8[A, B, C, D, E, F, G, H]) New(world *World) *Filter8[A, B, C, D, E, F, G, H]
- func (f *Filter8[A, B, C, D, E, F, G, H]) Query(rel ...Relation) Query8[A, B, C, D, E, F, G, H]
- func (f *Filter8[A, B, C, D, E, F, G, H]) Register() *Filter8[A, B, C, D, E, F, G, H]
- func (f *Filter8[A, B, C, D, E, F, G, H]) Relations(rel ...Relation) *Filter8[A, B, C, D, E, F, G, H]
- func (f *Filter8[A, B, C, D, E, F, G, H]) Unregister()
- func (f *Filter8[A, B, C, D, E, F, G, H]) With(comps ...Comp) *Filter8[A, B, C, D, E, F, G, H]
- func (f *Filter8[A, B, C, D, E, F, G, H]) Without(comps ...Comp) *Filter8[A, B, C, D, E, F, G, H]
- type ID
- type IDs
- type Map
- func (m *Map[T]) Add(entity Entity, comp *T, target ...Entity)
- func (m *Map[T]) AddBatch(batch *Batch, comp *T, target ...Entity)
- func (m *Map[T]) AddBatchFn(batch *Batch, fn func(entity Entity, comp *T), target ...Entity)
- func (m *Map[T]) AddFn(entity Entity, fn func(a *T), target ...Entity)
- func (m *Map[T]) Get(entity Entity) *T
- func (m *Map[T]) GetRelation(entity Entity) Entity
- func (m *Map[T]) GetRelationUnchecked(entity Entity) Entity
- func (m *Map[T]) GetUnchecked(entity Entity) *T
- func (m *Map[T]) Has(entity Entity) bool
- func (m *Map[T]) HasUnchecked(entity Entity) bool
- func (m *Map[T]) NewBatch(count int, comp *T, target ...Entity)
- func (m *Map[T]) NewBatchFn(count int, fn func(entity Entity, comp *T), target ...Entity)
- func (m *Map[T]) NewEntity(comp *T, target ...Entity) Entity
- func (m *Map[T]) NewEntityFn(fn func(a *T), target ...Entity) Entity
- func (m *Map[T]) Remove(entity Entity)
- func (m *Map[T]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (m *Map[T]) Set(entity Entity, comp *T)
- func (m *Map[T]) SetRelation(entity Entity, target Entity)
- func (m *Map[T]) SetRelationBatch(batch *Batch, target Entity, fn func(entity Entity))
- type Map1
- func (m *Map1[A]) Add(entity Entity, a *A, rel ...Relation)
- func (m *Map1[A]) AddBatch(batch *Batch, a *A, rel ...Relation)
- func (m *Map1[A]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A), rel ...Relation)
- func (m *Map1[A]) AddFn(entity Entity, fn func(a *A), rel ...Relation)
- func (m *Map1[A]) Get(entity Entity) *A
- func (m *Map1[A]) GetRelation(entity Entity, index int) Entity
- func (m *Map1[A]) GetRelationUnchecked(entity Entity, index int) Entity
- func (m *Map1[A]) GetUnchecked(entity Entity) *A
- func (m *Map1[A]) HasAll(entity Entity) bool
- func (_ *Map1[A]) New(world *World) *Map1[A]
- func (m *Map1[A]) NewBatch(count int, a *A, rel ...Relation)
- func (m *Map1[A]) NewBatchFn(count int, fn func(entity Entity, a *A), rel ...Relation)
- func (m *Map1[A]) NewEntity(a *A, rel ...Relation) Entity
- func (m *Map1[A]) NewEntityFn(fn func(a *A), rel ...Relation) Entity
- func (m *Map1[A]) Remove(entity Entity)
- func (m *Map1[A]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (m *Map1[A]) Set(entity Entity, a *A)
- func (m *Map1[A]) SetRelations(entity Entity, rel ...Relation)
- func (m *Map1[A]) SetRelationsBatch(batch *Batch, fn func(entity Entity), rel ...Relation)
- type Map10
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, ...)
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, ...)
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) AddBatchFn(batch *Batch, ...)
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) AddFn(entity Entity, ...)
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) Get(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I, *J)
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) GetRelation(entity Entity, index int) Entity
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) GetRelationUnchecked(entity Entity, index int) Entity
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) GetUnchecked(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I, *J)
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) HasAll(entity Entity) bool
- func (_ *Map10[A, B, C, D, E, F, G, H, I, J]) New(world *World) *Map10[A, B, C, D, E, F, G, H, I, J]
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, ...)
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) NewBatchFn(count int, ...)
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, rel ...Relation) Entity
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J), ...) Entity
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) Remove(entity Entity)
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) Set(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J)
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) SetRelations(entity Entity, rel ...Relation)
- func (m *Map10[A, B, C, D, E, F, G, H, I, J]) SetRelationsBatch(batch *Batch, fn func(entity Entity), rel ...Relation)
- type Map11
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, ...)
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, ...)
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) AddBatchFn(batch *Batch, ...)
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) AddFn(entity Entity, ...)
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) Get(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I, *J, *K)
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) GetRelation(entity Entity, index int) Entity
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) GetRelationUnchecked(entity Entity, index int) Entity
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) GetUnchecked(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I, *J, *K)
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) HasAll(entity Entity) bool
- func (_ *Map11[A, B, C, D, E, F, G, H, I, J, K]) New(world *World) *Map11[A, B, C, D, E, F, G, H, I, J, K]
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, ...)
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) NewBatchFn(count int, ...)
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, ...) Entity
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K), ...) Entity
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) Remove(entity Entity)
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) Set(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, ...)
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) SetRelations(entity Entity, rel ...Relation)
- func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) SetRelationsBatch(batch *Batch, fn func(entity Entity), rel ...Relation)
- type Map12
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, ...)
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, ...)
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) AddBatchFn(batch *Batch, ...)
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) AddFn(entity Entity, ...)
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) Get(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I, *J, *K, *L)
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) GetRelation(entity Entity, index int) Entity
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) GetRelationUnchecked(entity Entity, index int) Entity
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) GetUnchecked(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I, *J, *K, *L)
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) HasAll(entity Entity) bool
- func (_ *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) New(world *World) *Map12[A, B, C, D, E, F, G, H, I, J, K, L]
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, ...)
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) NewBatchFn(count int, ...)
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, l *L, ...) Entity
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) NewEntityFn(...) Entity
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) Remove(entity Entity)
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) Set(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, ...)
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) SetRelations(entity Entity, rel ...Relation)
- func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) SetRelationsBatch(batch *Batch, fn func(entity Entity), rel ...Relation)
- type Map2
- func (m *Map2[A, B]) Add(entity Entity, a *A, b *B, rel ...Relation)
- func (m *Map2[A, B]) AddBatch(batch *Batch, a *A, b *B, rel ...Relation)
- func (m *Map2[A, B]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B), rel ...Relation)
- func (m *Map2[A, B]) AddFn(entity Entity, fn func(a *A, b *B), rel ...Relation)
- func (m *Map2[A, B]) Get(entity Entity) (*A, *B)
- func (m *Map2[A, B]) GetRelation(entity Entity, index int) Entity
- func (m *Map2[A, B]) GetRelationUnchecked(entity Entity, index int) Entity
- func (m *Map2[A, B]) GetUnchecked(entity Entity) (*A, *B)
- func (m *Map2[A, B]) HasAll(entity Entity) bool
- func (_ *Map2[A, B]) New(world *World) *Map2[A, B]
- func (m *Map2[A, B]) NewBatch(count int, a *A, b *B, rel ...Relation)
- func (m *Map2[A, B]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B), rel ...Relation)
- func (m *Map2[A, B]) NewEntity(a *A, b *B, rel ...Relation) Entity
- func (m *Map2[A, B]) NewEntityFn(fn func(a *A, b *B), rel ...Relation) Entity
- func (m *Map2[A, B]) Remove(entity Entity)
- func (m *Map2[A, B]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (m *Map2[A, B]) Set(entity Entity, a *A, b *B)
- func (m *Map2[A, B]) SetRelations(entity Entity, rel ...Relation)
- func (m *Map2[A, B]) SetRelationsBatch(batch *Batch, fn func(entity Entity), rel ...Relation)
- type Map3
- func (m *Map3[A, B, C]) Add(entity Entity, a *A, b *B, c *C, rel ...Relation)
- func (m *Map3[A, B, C]) AddBatch(batch *Batch, a *A, b *B, c *C, rel ...Relation)
- func (m *Map3[A, B, C]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C), rel ...Relation)
- func (m *Map3[A, B, C]) AddFn(entity Entity, fn func(a *A, b *B, c *C), rel ...Relation)
- func (m *Map3[A, B, C]) Get(entity Entity) (*A, *B, *C)
- func (m *Map3[A, B, C]) GetRelation(entity Entity, index int) Entity
- func (m *Map3[A, B, C]) GetRelationUnchecked(entity Entity, index int) Entity
- func (m *Map3[A, B, C]) GetUnchecked(entity Entity) (*A, *B, *C)
- func (m *Map3[A, B, C]) HasAll(entity Entity) bool
- func (_ *Map3[A, B, C]) New(world *World) *Map3[A, B, C]
- func (m *Map3[A, B, C]) NewBatch(count int, a *A, b *B, c *C, rel ...Relation)
- func (m *Map3[A, B, C]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C), rel ...Relation)
- func (m *Map3[A, B, C]) NewEntity(a *A, b *B, c *C, rel ...Relation) Entity
- func (m *Map3[A, B, C]) NewEntityFn(fn func(a *A, b *B, c *C), rel ...Relation) Entity
- func (m *Map3[A, B, C]) Remove(entity Entity)
- func (m *Map3[A, B, C]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (m *Map3[A, B, C]) Set(entity Entity, a *A, b *B, c *C)
- func (m *Map3[A, B, C]) SetRelations(entity Entity, rel ...Relation)
- func (m *Map3[A, B, C]) SetRelationsBatch(batch *Batch, fn func(entity Entity), rel ...Relation)
- type Map4
- func (m *Map4[A, B, C, D]) Add(entity Entity, a *A, b *B, c *C, d *D, rel ...Relation)
- func (m *Map4[A, B, C, D]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, rel ...Relation)
- func (m *Map4[A, B, C, D]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D), rel ...Relation)
- func (m *Map4[A, B, C, D]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D), rel ...Relation)
- func (m *Map4[A, B, C, D]) Get(entity Entity) (*A, *B, *C, *D)
- func (m *Map4[A, B, C, D]) GetRelation(entity Entity, index int) Entity
- func (m *Map4[A, B, C, D]) GetRelationUnchecked(entity Entity, index int) Entity
- func (m *Map4[A, B, C, D]) GetUnchecked(entity Entity) (*A, *B, *C, *D)
- func (m *Map4[A, B, C, D]) HasAll(entity Entity) bool
- func (_ *Map4[A, B, C, D]) New(world *World) *Map4[A, B, C, D]
- func (m *Map4[A, B, C, D]) NewBatch(count int, a *A, b *B, c *C, d *D, rel ...Relation)
- func (m *Map4[A, B, C, D]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C, d *D), rel ...Relation)
- func (m *Map4[A, B, C, D]) NewEntity(a *A, b *B, c *C, d *D, rel ...Relation) Entity
- func (m *Map4[A, B, C, D]) NewEntityFn(fn func(a *A, b *B, c *C, d *D), rel ...Relation) Entity
- func (m *Map4[A, B, C, D]) Remove(entity Entity)
- func (m *Map4[A, B, C, D]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (m *Map4[A, B, C, D]) Set(entity Entity, a *A, b *B, c *C, d *D)
- func (m *Map4[A, B, C, D]) SetRelations(entity Entity, rel ...Relation)
- func (m *Map4[A, B, C, D]) SetRelationsBatch(batch *Batch, fn func(entity Entity), rel ...Relation)
- type Map5
- func (m *Map5[A, B, C, D, E]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, rel ...Relation)
- func (m *Map5[A, B, C, D, E]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, rel ...Relation)
- func (m *Map5[A, B, C, D, E]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E), ...)
- func (m *Map5[A, B, C, D, E]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E), rel ...Relation)
- func (m *Map5[A, B, C, D, E]) Get(entity Entity) (*A, *B, *C, *D, *E)
- func (m *Map5[A, B, C, D, E]) GetRelation(entity Entity, index int) Entity
- func (m *Map5[A, B, C, D, E]) GetRelationUnchecked(entity Entity, index int) Entity
- func (m *Map5[A, B, C, D, E]) GetUnchecked(entity Entity) (*A, *B, *C, *D, *E)
- func (m *Map5[A, B, C, D, E]) HasAll(entity Entity) bool
- func (_ *Map5[A, B, C, D, E]) New(world *World) *Map5[A, B, C, D, E]
- func (m *Map5[A, B, C, D, E]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, rel ...Relation)
- func (m *Map5[A, B, C, D, E]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E), ...)
- func (m *Map5[A, B, C, D, E]) NewEntity(a *A, b *B, c *C, d *D, e *E, rel ...Relation) Entity
- func (m *Map5[A, B, C, D, E]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E), rel ...Relation) Entity
- func (m *Map5[A, B, C, D, E]) Remove(entity Entity)
- func (m *Map5[A, B, C, D, E]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (m *Map5[A, B, C, D, E]) Set(entity Entity, a *A, b *B, c *C, d *D, e *E)
- func (m *Map5[A, B, C, D, E]) SetRelations(entity Entity, rel ...Relation)
- func (m *Map5[A, B, C, D, E]) SetRelationsBatch(batch *Batch, fn func(entity Entity), rel ...Relation)
- type Map6
- func (m *Map6[A, B, C, D, E, F]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
- func (m *Map6[A, B, C, D, E, F]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
- func (m *Map6[A, B, C, D, E, F]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F), ...)
- func (m *Map6[A, B, C, D, E, F]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F), rel ...Relation)
- func (m *Map6[A, B, C, D, E, F]) Get(entity Entity) (*A, *B, *C, *D, *E, *F)
- func (m *Map6[A, B, C, D, E, F]) GetRelation(entity Entity, index int) Entity
- func (m *Map6[A, B, C, D, E, F]) GetRelationUnchecked(entity Entity, index int) Entity
- func (m *Map6[A, B, C, D, E, F]) GetUnchecked(entity Entity) (*A, *B, *C, *D, *E, *F)
- func (m *Map6[A, B, C, D, E, F]) HasAll(entity Entity) bool
- func (_ *Map6[A, B, C, D, E, F]) New(world *World) *Map6[A, B, C, D, E, F]
- func (m *Map6[A, B, C, D, E, F]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
- func (m *Map6[A, B, C, D, E, F]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F), ...)
- func (m *Map6[A, B, C, D, E, F]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation) Entity
- func (m *Map6[A, B, C, D, E, F]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E, f *F), rel ...Relation) Entity
- func (m *Map6[A, B, C, D, E, F]) Remove(entity Entity)
- func (m *Map6[A, B, C, D, E, F]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (m *Map6[A, B, C, D, E, F]) Set(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F)
- func (m *Map6[A, B, C, D, E, F]) SetRelations(entity Entity, rel ...Relation)
- func (m *Map6[A, B, C, D, E, F]) SetRelationsBatch(batch *Batch, fn func(entity Entity), rel ...Relation)
- type Map7
- func (m *Map7[A, B, C, D, E, F, G]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
- func (m *Map7[A, B, C, D, E, F, G]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
- func (m *Map7[A, B, C, D, E, F, G]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G), ...)
- func (m *Map7[A, B, C, D, E, F, G]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G), ...)
- func (m *Map7[A, B, C, D, E, F, G]) Get(entity Entity) (*A, *B, *C, *D, *E, *F, *G)
- func (m *Map7[A, B, C, D, E, F, G]) GetRelation(entity Entity, index int) Entity
- func (m *Map7[A, B, C, D, E, F, G]) GetRelationUnchecked(entity Entity, index int) Entity
- func (m *Map7[A, B, C, D, E, F, G]) GetUnchecked(entity Entity) (*A, *B, *C, *D, *E, *F, *G)
- func (m *Map7[A, B, C, D, E, F, G]) HasAll(entity Entity) bool
- func (_ *Map7[A, B, C, D, E, F, G]) New(world *World) *Map7[A, B, C, D, E, F, G]
- func (m *Map7[A, B, C, D, E, F, G]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
- func (m *Map7[A, B, C, D, E, F, G]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G), ...)
- func (m *Map7[A, B, C, D, E, F, G]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation) Entity
- func (m *Map7[A, B, C, D, E, F, G]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G), rel ...Relation) Entity
- func (m *Map7[A, B, C, D, E, F, G]) Remove(entity Entity)
- func (m *Map7[A, B, C, D, E, F, G]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (m *Map7[A, B, C, D, E, F, G]) Set(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G)
- func (m *Map7[A, B, C, D, E, F, G]) SetRelations(entity Entity, rel ...Relation)
- func (m *Map7[A, B, C, D, E, F, G]) SetRelationsBatch(batch *Batch, fn func(entity Entity), rel ...Relation)
- type Map8
- func (m *Map8[A, B, C, D, E, F, G, H]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
- func (m *Map8[A, B, C, D, E, F, G, H]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
- func (m *Map8[A, B, C, D, E, F, G, H]) AddBatchFn(batch *Batch, ...)
- func (m *Map8[A, B, C, D, E, F, G, H]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H), ...)
- func (m *Map8[A, B, C, D, E, F, G, H]) Get(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H)
- func (m *Map8[A, B, C, D, E, F, G, H]) GetRelation(entity Entity, index int) Entity
- func (m *Map8[A, B, C, D, E, F, G, H]) GetRelationUnchecked(entity Entity, index int) Entity
- func (m *Map8[A, B, C, D, E, F, G, H]) GetUnchecked(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H)
- func (m *Map8[A, B, C, D, E, F, G, H]) HasAll(entity Entity) bool
- func (_ *Map8[A, B, C, D, E, F, G, H]) New(world *World) *Map8[A, B, C, D, E, F, G, H]
- func (m *Map8[A, B, C, D, E, F, G, H]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
- func (m *Map8[A, B, C, D, E, F, G, H]) NewBatchFn(count int, ...)
- func (m *Map8[A, B, C, D, E, F, G, H]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation) Entity
- func (m *Map8[A, B, C, D, E, F, G, H]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H), rel ...Relation) Entity
- func (m *Map8[A, B, C, D, E, F, G, H]) Remove(entity Entity)
- func (m *Map8[A, B, C, D, E, F, G, H]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (m *Map8[A, B, C, D, E, F, G, H]) Set(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H)
- func (m *Map8[A, B, C, D, E, F, G, H]) SetRelations(entity Entity, rel ...Relation)
- func (m *Map8[A, B, C, D, E, F, G, H]) SetRelationsBatch(batch *Batch, fn func(entity Entity), rel ...Relation)
- type Map9
- func (m *Map9[A, B, C, D, E, F, G, H, I]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, ...)
- func (m *Map9[A, B, C, D, E, F, G, H, I]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, ...)
- func (m *Map9[A, B, C, D, E, F, G, H, I]) AddBatchFn(batch *Batch, ...)
- func (m *Map9[A, B, C, D, E, F, G, H, I]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I), ...)
- func (m *Map9[A, B, C, D, E, F, G, H, I]) Get(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I)
- func (m *Map9[A, B, C, D, E, F, G, H, I]) GetRelation(entity Entity, index int) Entity
- func (m *Map9[A, B, C, D, E, F, G, H, I]) GetRelationUnchecked(entity Entity, index int) Entity
- func (m *Map9[A, B, C, D, E, F, G, H, I]) GetUnchecked(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I)
- func (m *Map9[A, B, C, D, E, F, G, H, I]) HasAll(entity Entity) bool
- func (_ *Map9[A, B, C, D, E, F, G, H, I]) New(world *World) *Map9[A, B, C, D, E, F, G, H, I]
- func (m *Map9[A, B, C, D, E, F, G, H, I]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, ...)
- func (m *Map9[A, B, C, D, E, F, G, H, I]) NewBatchFn(count int, ...)
- func (m *Map9[A, B, C, D, E, F, G, H, I]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, rel ...Relation) Entity
- func (m *Map9[A, B, C, D, E, F, G, H, I]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I), rel ...Relation) Entity
- func (m *Map9[A, B, C, D, E, F, G, H, I]) Remove(entity Entity)
- func (m *Map9[A, B, C, D, E, F, G, H, I]) RemoveBatch(batch *Batch, fn func(entity Entity))
- func (m *Map9[A, B, C, D, E, F, G, H, I]) Set(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I)
- func (m *Map9[A, B, C, D, E, F, G, H, I]) SetRelations(entity Entity, rel ...Relation)
- func (m *Map9[A, B, C, D, E, F, G, H, I]) SetRelationsBatch(batch *Batch, fn func(entity Entity), rel ...Relation)
- type Query0
- type Query1
- type Query2
- type Query3
- func (q *Query3[A, B, C]) Close()
- func (q *Query3[A, B, C]) Count() int
- func (q *Query3[A, B, C]) Entity() Entity
- func (q *Query3[A, B, C]) EntityAt(index int) Entity
- func (q *Query3[A, B, C]) Get() (*A, *B, *C)
- func (q *Query3[A, B, C]) GetRelation(index int) Entity
- func (q *Query3[A, B, C]) Next() bool
- type Query4
- func (q *Query4[A, B, C, D]) Close()
- func (q *Query4[A, B, C, D]) Count() int
- func (q *Query4[A, B, C, D]) Entity() Entity
- func (q *Query4[A, B, C, D]) EntityAt(index int) Entity
- func (q *Query4[A, B, C, D]) Get() (*A, *B, *C, *D)
- func (q *Query4[A, B, C, D]) GetRelation(index int) Entity
- func (q *Query4[A, B, C, D]) Next() bool
- type Query5
- func (q *Query5[A, B, C, D, E]) Close()
- func (q *Query5[A, B, C, D, E]) Count() int
- func (q *Query5[A, B, C, D, E]) Entity() Entity
- func (q *Query5[A, B, C, D, E]) EntityAt(index int) Entity
- func (q *Query5[A, B, C, D, E]) Get() (*A, *B, *C, *D, *E)
- func (q *Query5[A, B, C, D, E]) GetRelation(index int) Entity
- func (q *Query5[A, B, C, D, E]) Next() bool
- type Query6
- func (q *Query6[A, B, C, D, E, F]) Close()
- func (q *Query6[A, B, C, D, E, F]) Count() int
- func (q *Query6[A, B, C, D, E, F]) Entity() Entity
- func (q *Query6[A, B, C, D, E, F]) EntityAt(index int) Entity
- func (q *Query6[A, B, C, D, E, F]) Get() (*A, *B, *C, *D, *E, *F)
- func (q *Query6[A, B, C, D, E, F]) GetRelation(index int) Entity
- func (q *Query6[A, B, C, D, E, F]) Next() bool
- type Query7
- func (q *Query7[A, B, C, D, E, F, G]) Close()
- func (q *Query7[A, B, C, D, E, F, G]) Count() int
- func (q *Query7[A, B, C, D, E, F, G]) Entity() Entity
- func (q *Query7[A, B, C, D, E, F, G]) EntityAt(index int) Entity
- func (q *Query7[A, B, C, D, E, F, G]) Get() (*A, *B, *C, *D, *E, *F, *G)
- func (q *Query7[A, B, C, D, E, F, G]) GetRelation(index int) Entity
- func (q *Query7[A, B, C, D, E, F, G]) Next() bool
- type Query8
- func (q *Query8[A, B, C, D, E, F, G, H]) Close()
- func (q *Query8[A, B, C, D, E, F, G, H]) Count() int
- func (q *Query8[A, B, C, D, E, F, G, H]) Entity() Entity
- func (q *Query8[A, B, C, D, E, F, G, H]) EntityAt(index int) Entity
- func (q *Query8[A, B, C, D, E, F, G, H]) Get() (*A, *B, *C, *D, *E, *F, *G, *H)
- func (q *Query8[A, B, C, D, E, F, G, H]) GetRelation(index int) Entity
- func (q *Query8[A, B, C, D, E, F, G, H]) Next() bool
- type Relation
- type RelationMarker
- type ResID
- type Resource
- type Resources
- type Unsafe
- func (u Unsafe) Add(entity Entity, comp ...ID)
- func (u Unsafe) AddRel(entity Entity, comps []ID, relations ...Relation)
- func (u Unsafe) DumpEntities() EntityDump
- func (u Unsafe) Exchange(entity Entity, add []ID, remove []ID, relations ...Relation)
- func (u Unsafe) Get(entity Entity, comp ID) unsafe.Pointer
- func (u Unsafe) GetRelation(entity Entity, comp ID) Entity
- func (u Unsafe) GetRelationUnchecked(entity Entity, comp ID) Entity
- func (u Unsafe) GetUnchecked(entity Entity, comp ID) unsafe.Pointer
- func (u Unsafe) Has(entity Entity, comp ID) bool
- func (u Unsafe) HasUnchecked(entity Entity, comp ID) bool
- func (u Unsafe) IDs(entity Entity) IDs
- func (u Unsafe) LoadEntities(data *EntityDump)
- func (u Unsafe) NewEntity(ids ...ID) Entity
- func (u Unsafe) NewEntityRel(ids []ID, relations ...Relation) Entity
- func (u Unsafe) Remove(entity Entity, comp ...ID)
- func (u Unsafe) SetRelations(entity Entity, relations ...Relation)
- type UnsafeFilter
- type UnsafeQuery
- func (q *UnsafeQuery) Close()
- func (q *UnsafeQuery) Count() int
- func (q *UnsafeQuery) Entity() Entity
- func (q *UnsafeQuery) EntityAt(index int) Entity
- func (q *UnsafeQuery) Get(comp ID) unsafe.Pointer
- func (q *UnsafeQuery) GetRelation(comp ID) Entity
- func (q *UnsafeQuery) Has(comp ID) bool
- func (q *UnsafeQuery) IDs() IDs
- func (q *UnsafeQuery) Next() bool
- type World
- func (w *World) Alive(entity Entity) bool
- func (w *World) IsLocked() bool
- func (w *World) NewEntities(count int, fn func(entity Entity))
- func (w *World) NewEntity() Entity
- func (w *World) RemoveEntities(batch *Batch, fn func(entity Entity))
- func (w *World) RemoveEntity(entity Entity)
- func (w *World) Reset()
- func (w *World) Resources() *Resources
- func (w *World) Stats() *stats.World
- func (w *World) Unsafe() Unsafe
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetResource ¶
GetResource returns a pointer to the given resource type in the world. Returns nil if there is no such resource.
Uses reflection. For more efficient repeated access, use Resource. Once created, it is more than 20 times faster than the GetResource function.
See also AddResource.
Example ¶
world := ecs.NewWorld() gridResource := NewGrid(100, 100) ecs.AddResource(&world, &gridResource) grid := ecs.GetResource[Grid](&world) entity := grid.Get(13, 42) _ = entity
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch is like a filter for batch processing of entities. Create it using Filter2.Batch etc.
⚠️ This should not be stored, but used immediately and re-generated each time a batch operation is called. Otherwise, changes to the origin filter or calls to Filter2.Batch with different relationship targets may modify stored instances.
type Comp ¶
type Comp struct {
// contains filtered or unexported fields
}
Comp is a helper to pass component types to functions and methods. Use function C to create one.
type CompInfo ¶
CompInfo provides information about a registered component. Returned by ComponentInfo.
type Entity ¶
type Entity struct {
// contains filtered or unexported fields
}
Entity is an identifier for entities.
Can be stored safely in components, resources or elsewhere. For stored entities, it may be necessary to check their alive status with World.Alive.
⚠️ Always store entities by value, never by pointer!
In Ark, entities are returned to a pool when they are removed from the world. These entities can be recycled, with the same ID (Entity.ID), but an incremented generation (Entity.Gen). This allows to determine whether an entity hold by the user is still alive, despite it was potentially recycled.
func (Entity) MarshalJSON ¶
MarshalJSON returns a JSON representation of the entity, for serialization purposes.
The JSON representation of an entity is a two-element array of entity ID and generation.
func (*Entity) UnmarshalJSON ¶
UnmarshalJSON into an entity.
For serialization purposes only. Do not use this to create entities!
type EntityDump ¶
type EntityDump struct {
Entities []Entity // Entities in the World's entity pool.
Alive []uint32 // IDs of all alive entities in query iteration order.
Next uint32 // The next free entity of the World's entity pool.
Available uint32 // The number of allocated and available entities in the World's entity pool.
}
EntityDump is a dump of the entire entity data of the world.
See [World.DumpEntities] and [World.LoadEntities].
type Exchange1 ¶
type Exchange1[A any] struct { // contains filtered or unexported fields }
Exchange1 allows to exchange components of entities. It adds the given components. Use Exchange1.Removes to set components to be removed.
Instances should be created during initialization and stored, e.g. in systems.
See Exchange2 for a usage example.
func NewExchange1 ¶
NewExchange1 creates an Exchange1.
func (*Exchange1[A]) Add ¶
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 via the variadic arguments.
func (*Exchange1[A]) AddBatch ¶
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 via the variadic arguments.
func (*Exchange1[A]) AddBatchFn ¶
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange1[A]) AddFn ¶
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange1[A]) Exchange ¶
Exchange performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange1.Removes.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange1[A]) ExchangeBatch ¶
ExchangeBatch performs the exchange on all entities matching the given batch filter.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange1[A]) ExchangeBatchFn ¶
func (ex *Exchange1[A]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A), rel ...Relation)
ExchangeBatchFn performs the exchange on 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange1[A]) ExchangeFn ¶
ExchangeFn performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange1.Removes. It 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange1[A]) New ¶
New creates a new Exchange1. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Exchange2.New for an example.
func (*Exchange1[A]) Remove ¶
Remove the components previously specified with Exchange1.Removes from the given entity.
func (*Exchange1[A]) RemoveBatch ¶
RemoveBatch removes the components previously specified with Exchange1.Removes from all entities matching the given batch filter, running the given function on each. The function can be nil.
type Exchange2 ¶
Exchange2 allows to exchange components of entities. It adds the given components. Use Exchange2.Removes to set components to be removed.
Instances should be created during initialization and stored, e.g. in systems.
Example ¶
world := ecs.NewWorld()
// Create a component mapper.
mapper := ecs.NewMap[Altitude](&world)
// Create an exchange helper.
// Adds Position and Velocity, removes Altitude.
exchange := ecs.NewExchange2[Position, Velocity](&world).
Removes(ecs.C[Altitude]())
// Create an entity with an Altitude component.
entity := mapper.NewEntity(&Altitude{Z: 10_000})
// Remove Altitude and add Position and Velocity.
exchange.Exchange(entity, &Position{X: 100, Y: 100}, &Velocity{X: 1, Y: -1})
// Create another entity.
entity = mapper.NewEntity(&Altitude{Z: 10_000})
// Remove Altitude.
exchange.Remove(entity)
// Add Position and Velocity.
exchange.Add(entity, &Position{X: 100, Y: 100}, &Velocity{X: 1, Y: -1})
func NewExchange2 ¶
NewExchange2 creates an Exchange2.
func (*Exchange2[A, B]) Add ¶
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 via the variadic arguments.
func (*Exchange2[A, B]) AddBatch ¶
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 via the variadic arguments.
func (*Exchange2[A, B]) AddBatchFn ¶
func (ex *Exchange2[A, B]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B), rel ...Relation)
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange2[A, B]) AddFn ¶
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange2[A, B]) Exchange ¶
Exchange performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange2.Removes.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange2[A, B]) ExchangeBatch ¶
ExchangeBatch performs the exchange on all entities matching the given batch filter.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange2[A, B]) ExchangeBatchFn ¶
func (ex *Exchange2[A, B]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B), rel ...Relation)
ExchangeBatchFn performs the exchange on 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange2[A, B]) ExchangeFn ¶
ExchangeFn performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange2.Removes. It 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange2[A, B]) New ¶
New creates a new Exchange2. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
Example ¶
world := ecs.NewWorld() // Declare the exchange helper, e.g. in your system struct. var exchange *ecs.Exchange2[Position, Velocity] // Construct the exchange helper, avoiding repeated listing of generics. exchange = exchange.New(&world).Removes(ecs.C[Altitude]())
func (*Exchange2[A, B]) Remove ¶
Remove the components previously specified with Exchange2.Removes from the given entity.
func (*Exchange2[A, B]) RemoveBatch ¶
RemoveBatch removes the components previously specified with Exchange2.Removes from all entities matching the given batch filter, running the given function on each. The function can be nil.
type Exchange3 ¶
Exchange3 allows to exchange components of entities. It adds the given components. Use Exchange3.Removes to set components to be removed.
Instances should be created during initialization and stored, e.g. in systems.
See Exchange2 for a usage example.
func NewExchange3 ¶
NewExchange3 creates an Exchange3.
func (*Exchange3[A, B, C]) Add ¶
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 via the variadic arguments.
func (*Exchange3[A, B, C]) AddBatch ¶
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 via the variadic arguments.
func (*Exchange3[A, B, C]) AddBatchFn ¶
func (ex *Exchange3[A, B, C]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C), rel ...Relation)
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange3[A, B, C]) AddFn ¶
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange3[A, B, C]) Exchange ¶
Exchange performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange3.Removes.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange3[A, B, C]) ExchangeBatch ¶
ExchangeBatch performs the exchange on all entities matching the given batch filter.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange3[A, B, C]) ExchangeBatchFn ¶
func (ex *Exchange3[A, B, C]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C), rel ...Relation)
ExchangeBatchFn performs the exchange on 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange3[A, B, C]) ExchangeFn ¶
ExchangeFn performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange3.Removes. It 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange3[A, B, C]) New ¶
New creates a new Exchange3. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Exchange2.New for an example.
func (*Exchange3[A, B, C]) Remove ¶
Remove the components previously specified with Exchange3.Removes from the given entity.
func (*Exchange3[A, B, C]) RemoveBatch ¶
RemoveBatch removes the components previously specified with Exchange3.Removes from all entities matching the given batch filter, running the given function on each. The function can be nil.
type Exchange4 ¶
Exchange4 allows to exchange components of entities. It adds the given components. Use Exchange4.Removes to set components to be removed.
Instances should be created during initialization and stored, e.g. in systems.
See Exchange2 for a usage example.
func NewExchange4 ¶
NewExchange4 creates an Exchange4.
func (*Exchange4[A, B, C, D]) Add ¶
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 via the variadic arguments.
func (*Exchange4[A, B, C, D]) AddBatch ¶
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 via the variadic arguments.
func (*Exchange4[A, B, C, D]) AddBatchFn ¶
func (ex *Exchange4[A, B, C, D]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D), rel ...Relation)
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange4[A, B, C, D]) AddFn ¶
func (ex *Exchange4[A, B, C, D]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D), rel ...Relation)
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange4[A, B, C, D]) Exchange ¶
Exchange performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange4.Removes.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange4[A, B, C, D]) ExchangeBatch ¶
func (ex *Exchange4[A, B, C, D]) ExchangeBatch(batch *Batch, a *A, b *B, c *C, d *D, rel ...Relation)
ExchangeBatch performs the exchange on all entities matching the given batch filter.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange4[A, B, C, D]) ExchangeBatchFn ¶
func (ex *Exchange4[A, B, C, D]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D), rel ...Relation)
ExchangeBatchFn performs the exchange on 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange4[A, B, C, D]) ExchangeFn ¶
func (ex *Exchange4[A, B, C, D]) ExchangeFn(entity Entity, fn func(a *A, b *B, c *C, d *D), rel ...Relation)
ExchangeFn performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange4.Removes. It 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange4[A, B, C, D]) New ¶
New creates a new Exchange4. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Exchange2.New for an example.
func (*Exchange4[A, B, C, D]) Remove ¶
Remove the components previously specified with Exchange4.Removes from the given entity.
func (*Exchange4[A, B, C, D]) RemoveBatch ¶
RemoveBatch removes the components previously specified with Exchange4.Removes from all entities matching the given batch filter, running the given function on each. The function can be nil.
type Exchange5 ¶
type Exchange5[A any, B any, C any, D any, E any] struct { // contains filtered or unexported fields }
Exchange5 allows to exchange components of entities. It adds the given components. Use Exchange5.Removes to set components to be removed.
Instances should be created during initialization and stored, e.g. in systems.
See Exchange2 for a usage example.
func NewExchange5 ¶
NewExchange5 creates an Exchange5.
func (*Exchange5[A, B, C, D, E]) Add ¶
func (ex *Exchange5[A, B, C, D, E]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, rel ...Relation)
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 via the variadic arguments.
func (*Exchange5[A, B, C, D, E]) AddBatch ¶
func (ex *Exchange5[A, B, C, D, E]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, rel ...Relation)
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 via the variadic arguments.
func (*Exchange5[A, B, C, D, E]) AddBatchFn ¶
func (ex *Exchange5[A, B, C, D, E]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E), rel ...Relation)
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange5[A, B, C, D, E]) AddFn ¶
func (ex *Exchange5[A, B, C, D, E]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E), rel ...Relation)
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange5[A, B, C, D, E]) Exchange ¶
func (ex *Exchange5[A, B, C, D, E]) Exchange(entity Entity, a *A, b *B, c *C, d *D, e *E, rel ...Relation)
Exchange performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange5.Removes.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange5[A, B, C, D, E]) ExchangeBatch ¶
func (ex *Exchange5[A, B, C, D, E]) ExchangeBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, rel ...Relation)
ExchangeBatch performs the exchange on all entities matching the given batch filter.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange5[A, B, C, D, E]) ExchangeBatchFn ¶
func (ex *Exchange5[A, B, C, D, E]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E), rel ...Relation)
ExchangeBatchFn performs the exchange on 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange5[A, B, C, D, E]) ExchangeFn ¶
func (ex *Exchange5[A, B, C, D, E]) ExchangeFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E), rel ...Relation)
ExchangeFn performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange5.Removes. It 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange5[A, B, C, D, E]) New ¶
New creates a new Exchange5. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Exchange2.New for an example.
func (*Exchange5[A, B, C, D, E]) Remove ¶
Remove the components previously specified with Exchange5.Removes from the given entity.
func (*Exchange5[A, B, C, D, E]) RemoveBatch ¶
RemoveBatch removes the components previously specified with Exchange5.Removes from all entities matching the given batch filter, running the given function on each. The function can be nil.
type Exchange6 ¶
type Exchange6[A any, B any, C any, D any, E any, F any] struct { // contains filtered or unexported fields }
Exchange6 allows to exchange components of entities. It adds the given components. Use Exchange6.Removes to set components to be removed.
Instances should be created during initialization and stored, e.g. in systems.
See Exchange2 for a usage example.
func NewExchange6 ¶
func NewExchange6[A any, B any, C any, D any, E any, F any](world *World) *Exchange6[A, B, C, D, E, F]
NewExchange6 creates an Exchange6.
func (*Exchange6[A, B, C, D, E, F]) Add ¶
func (ex *Exchange6[A, B, C, D, E, F]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
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 via the variadic arguments.
func (*Exchange6[A, B, C, D, E, F]) AddBatch ¶
func (ex *Exchange6[A, B, C, D, E, F]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
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 via the variadic arguments.
func (*Exchange6[A, B, C, D, E, F]) AddBatchFn ¶
func (ex *Exchange6[A, B, C, D, E, F]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F), rel ...Relation)
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange6[A, B, C, D, E, F]) AddFn ¶
func (ex *Exchange6[A, B, C, D, E, F]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F), rel ...Relation)
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange6[A, B, C, D, E, F]) Exchange ¶
func (ex *Exchange6[A, B, C, D, E, F]) Exchange(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
Exchange performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange6.Removes.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange6[A, B, C, D, E, F]) ExchangeBatch ¶
func (ex *Exchange6[A, B, C, D, E, F]) ExchangeBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
ExchangeBatch performs the exchange on all entities matching the given batch filter.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange6[A, B, C, D, E, F]) ExchangeBatchFn ¶
func (ex *Exchange6[A, B, C, D, E, F]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F), rel ...Relation)
ExchangeBatchFn performs the exchange on 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange6[A, B, C, D, E, F]) ExchangeFn ¶
func (ex *Exchange6[A, B, C, D, E, F]) ExchangeFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F), rel ...Relation)
ExchangeFn performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange6.Removes. It 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange6[A, B, C, D, E, F]) New ¶
New creates a new Exchange6. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Exchange2.New for an example.
func (*Exchange6[A, B, C, D, E, F]) Remove ¶
Remove the components previously specified with Exchange6.Removes from the given entity.
func (*Exchange6[A, B, C, D, E, F]) RemoveBatch ¶
RemoveBatch removes the components previously specified with Exchange6.Removes from all entities matching the given batch filter, running the given function on each. The function can be nil.
type Exchange7 ¶
type Exchange7[A any, B any, C any, D any, E any, F any, G any] struct { // contains filtered or unexported fields }
Exchange7 allows to exchange components of entities. It adds the given components. Use Exchange7.Removes to set components to be removed.
Instances should be created during initialization and stored, e.g. in systems.
See Exchange2 for a usage example.
func NewExchange7 ¶
func NewExchange7[A any, B any, C any, D any, E any, F any, G any](world *World) *Exchange7[A, B, C, D, E, F, G]
NewExchange7 creates an Exchange7.
func (*Exchange7[A, B, C, D, E, F, G]) Add ¶
func (ex *Exchange7[A, B, C, D, E, F, G]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
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 via the variadic arguments.
func (*Exchange7[A, B, C, D, E, F, G]) AddBatch ¶
func (ex *Exchange7[A, B, C, D, E, F, G]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
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 via the variadic arguments.
func (*Exchange7[A, B, C, D, E, F, G]) AddBatchFn ¶
func (ex *Exchange7[A, B, C, D, E, F, G]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G), rel ...Relation)
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange7[A, B, C, D, E, F, G]) AddFn ¶
func (ex *Exchange7[A, B, C, D, E, F, G]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G), rel ...Relation)
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange7[A, B, C, D, E, F, G]) Exchange ¶
func (ex *Exchange7[A, B, C, D, E, F, G]) Exchange(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
Exchange performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange7.Removes.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange7[A, B, C, D, E, F, G]) ExchangeBatch ¶
func (ex *Exchange7[A, B, C, D, E, F, G]) ExchangeBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
ExchangeBatch performs the exchange on all entities matching the given batch filter.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange7[A, B, C, D, E, F, G]) ExchangeBatchFn ¶
func (ex *Exchange7[A, B, C, D, E, F, G]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G), rel ...Relation)
ExchangeBatchFn performs the exchange on 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange7[A, B, C, D, E, F, G]) ExchangeFn ¶
func (ex *Exchange7[A, B, C, D, E, F, G]) ExchangeFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G), rel ...Relation)
ExchangeFn performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange7.Removes. It 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange7[A, B, C, D, E, F, G]) New ¶
New creates a new Exchange7. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Exchange2.New for an example.
func (*Exchange7[A, B, C, D, E, F, G]) Remove ¶
Remove the components previously specified with Exchange7.Removes from the given entity.
func (*Exchange7[A, B, C, D, E, F, G]) RemoveBatch ¶
RemoveBatch removes the components previously specified with Exchange7.Removes from all entities matching the given batch filter, running the given function on each. The function can be nil.
type Exchange8 ¶
type Exchange8[A any, B any, C any, D any, E any, F any, G any, H any] struct { // contains filtered or unexported fields }
Exchange8 allows to exchange components of entities. It adds the given components. Use Exchange8.Removes to set components to be removed.
Instances should be created during initialization and stored, e.g. in systems.
See Exchange2 for a usage example.
func NewExchange8 ¶
func NewExchange8[A any, B any, C any, D any, E any, F any, G any, H any](world *World) *Exchange8[A, B, C, D, E, F, G, H]
NewExchange8 creates an Exchange8.
func (*Exchange8[A, B, C, D, E, F, G, H]) Add ¶
func (ex *Exchange8[A, B, C, D, E, F, G, H]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
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 via the variadic arguments.
func (*Exchange8[A, B, C, D, E, F, G, H]) AddBatch ¶
func (ex *Exchange8[A, B, C, D, E, F, G, H]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
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 via the variadic arguments.
func (*Exchange8[A, B, C, D, E, F, G, H]) AddBatchFn ¶
func (ex *Exchange8[A, B, C, D, E, F, G, H]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H), rel ...Relation)
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange8[A, B, C, D, E, F, G, H]) AddFn ¶
func (ex *Exchange8[A, B, C, D, E, F, G, H]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H), rel ...Relation)
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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange8[A, B, C, D, E, F, G, H]) Exchange ¶
func (ex *Exchange8[A, B, C, D, E, F, G, H]) Exchange(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
Exchange performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange8.Removes.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange8[A, B, C, D, E, F, G, H]) ExchangeBatch ¶
func (ex *Exchange8[A, B, C, D, E, F, G, H]) ExchangeBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
ExchangeBatch performs the exchange on all entities matching the given batch filter.
For each mapped component that is a relationships (see RelationMarker), a relation target entity must be provided via the variadic arguments.
func (*Exchange8[A, B, C, D, E, F, G, H]) ExchangeBatchFn ¶
func (ex *Exchange8[A, B, C, D, E, F, G, H]) ExchangeBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H), rel ...Relation)
ExchangeBatchFn performs the exchange on 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange8[A, B, C, D, E, F, G, H]) ExchangeFn ¶
func (ex *Exchange8[A, B, C, D, E, F, G, H]) ExchangeFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H), rel ...Relation)
ExchangeFn performs the exchange on the given entity, adding the provided components and removing those previously specified with Exchange8.Removes. It 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 via the variadic arguments.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Exchange8[A, B, C, D, E, F, G, H]) New ¶
New creates a new Exchange8. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Exchange2.New for an example.
func (*Exchange8[A, B, C, D, E, F, G, H]) Remove ¶
Remove the components previously specified with Exchange8.Removes from the given entity.
func (*Exchange8[A, B, C, D, E, F, G, H]) RemoveBatch ¶
RemoveBatch removes the components previously specified with Exchange8.Removes from all entities matching the given batch filter, running the given function on each. The function can be nil.
type Filter0 ¶
type Filter0 struct {
// contains filtered or unexported fields
}
Filter0 is a filter for 0 components. Used to create Query0 iterators.
Instances should be created during initialization and stored, e.g. in systems.
See Filter2 for a usage example.
func (*Filter0) Batch ¶
Batch creates a Batch from this filter.
Relation targets provided here are added to those specified with Filter0.Relations. Relation components must be in the filter's parameters or added via Filter0.With beforehand.
⚠️ The returned Batch filter should not be stored, but used immediately and re-generated each time a batch operation is called. Otherwise, changes to the origin filter or calls to Filter0.Batch or Filter0.Query with different relationship targets may modify stored instances.
func (*Filter0) Exclusive ¶
Exclusive makes the filter exclusive in the sense that the component composition is matched exactly, and no other components are allowed.
func (*Filter0) New ¶
New creates a new Filter0. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Filter2.New for an example.
func (*Filter0) Query ¶
Query creates a Query0 from this filter. This must be used each time before iterating a query.
Relation targets provided here are added to those specified with Filter0.Relations. Relation components must be in the filter's parameters or added via Filter0.With beforehand.
⚠️ The returned Query0 should not be stored, but used immediately and re-generated each time before query iteration. Otherwise, changes to the origin filter or calls to Filter0.Batch or Filter0.Query with different relationship targets may modify stored instances.
func (*Filter0) Register ¶
Register this filter to the world's filter cache.
Registering filters is optional. It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func (*Filter0) Relations ¶
Relations sets permanent entity relation targets for this filter. Relation targets set here are included in filter caching. Contrary, relation targets specified in Filter0.Query or Filter0.Batch are not cached.
Relation components used here must be in the filter's parameters or added via Filter0.With beforehand.
Can be called multiple times in chains, or once with multiple arguments.
func (*Filter0) Unregister ¶
func (f *Filter0) Unregister()
Unregister this filter from the world's filter cache.
type Filter1 ¶
type Filter1[A any] struct { // contains filtered or unexported fields }
Filter1 is a filter for 1 components. Used to create Query1 iterators.
Instances should be created during initialization and stored, e.g. in systems.
See Filter2 for a usage example.
func (*Filter1[A]) Batch ¶
Batch creates a Batch from this filter.
Relation targets provided here are added to those specified with Filter1.Relations. Relation components must be in the filter's parameters or added via Filter1.With beforehand.
⚠️ The returned Batch filter should not be stored, but used immediately and re-generated each time a batch operation is called. Otherwise, changes to the origin filter or calls to Filter1.Batch or Filter1.Query with different relationship targets may modify stored instances.
func (*Filter1[A]) Exclusive ¶
Exclusive makes the filter exclusive in the sense that the component composition is matched exactly, and no other components are allowed.
func (*Filter1[A]) New ¶
New creates a new Filter1. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Filter2.New for an example.
func (*Filter1[A]) Query ¶
Query creates a Query1 from this filter. This must be used each time before iterating a query.
Relation targets provided here are added to those specified with Filter1.Relations. Relation components must be in the filter's parameters or added via Filter1.With beforehand.
⚠️ The returned Query1 should not be stored, but used immediately and re-generated each time before query iteration. Otherwise, changes to the origin filter or calls to Filter1.Batch or Filter1.Query with different relationship targets may modify stored instances.
func (*Filter1[A]) Register ¶
Register this filter to the world's filter cache.
Registering filters is optional. It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func (*Filter1[A]) Relations ¶
Relations sets permanent entity relation targets for this filter. Relation targets set here are included in filter caching. Contrary, relation targets specified in Filter1.Query or Filter1.Batch are not cached.
Relation components used here must be in the filter's parameters or added via Filter1.With beforehand.
Can be called multiple times in chains, or once with multiple arguments.
func (*Filter1[A]) Unregister ¶
func (f *Filter1[A]) Unregister()
Unregister this filter from the world's filter cache.
type Filter2 ¶
Filter2 is a filter for 2 components. Used to create Query2 iterators.
Instances should be created during initialization and stored, e.g. in systems.
Example ¶
world := ecs.NewWorld()
// A simple filter for components (non-exclusive).
simpleFilter := ecs.NewFilter2[Position, Velocity](&world)
// A simple filter with an additional (unused) and an excluded component.
complexFilter := ecs.NewFilter2[Position, Velocity](&world).
With(ecs.C[Altitude]()).
Without(ecs.C[ChildOf]())
// A cached/registered filter, with an additional (unused) component.
cachedFilter := ecs.NewFilter2[Position, Velocity](&world).
With(ecs.C[Altitude]()).
Register()
// Create a query from a filter, and iterate it.
query := simpleFilter.Query()
for query.Next() {
// ...
}
_, _ = complexFilter, cachedFilter
func (*Filter2[A, B]) Batch ¶
Batch creates a Batch from this filter.
Relation targets provided here are added to those specified with Filter2.Relations. Relation components must be in the filter's parameters or added via Filter2.With beforehand.
⚠️ The returned Batch filter should not be stored, but used immediately and re-generated each time a batch operation is called. Otherwise, changes to the origin filter or calls to Filter2.Batch or Filter2.Query with different relationship targets may modify stored instances.
func (*Filter2[A, B]) Exclusive ¶
Exclusive makes the filter exclusive in the sense that the component composition is matched exactly, and no other components are allowed.
func (*Filter2[A, B]) New ¶
New creates a new Filter2. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
Example ¶
world := ecs.NewWorld() // Declare the filter, e.g. in your system struct. var filter *ecs.Filter2[Position, Velocity] // Construct the filter, avoiding repeated listing of generics. filter = filter.New(&world)
func (*Filter2[A, B]) Query ¶
Query creates a Query2 from this filter. This must be used each time before iterating a query.
Relation targets provided here are added to those specified with Filter2.Relations. Relation components must be in the filter's parameters or added via Filter2.With beforehand.
⚠️ The returned Query2 should not be stored, but used immediately and re-generated each time before query iteration. Otherwise, changes to the origin filter or calls to Filter2.Batch or Filter2.Query with different relationship targets may modify stored instances.
func (*Filter2[A, B]) Register ¶
Register this filter to the world's filter cache.
Registering filters is optional. It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func (*Filter2[A, B]) Relations ¶
Relations sets permanent entity relation targets for this filter. Relation targets set here are included in filter caching. Contrary, relation targets specified in Filter2.Query or Filter2.Batch are not cached.
Relation components used here must be in the filter's parameters or added via Filter2.With beforehand.
Can be called multiple times in chains, or once with multiple arguments.
func (*Filter2[A, B]) Unregister ¶
func (f *Filter2[A, B]) Unregister()
Unregister this filter from the world's filter cache.
type Filter3 ¶
Filter3 is a filter for 3 components. Used to create Query3 iterators.
Instances should be created during initialization and stored, e.g. in systems.
See Filter2 for a usage example.
func (*Filter3[A, B, C]) Batch ¶
Batch creates a Batch from this filter.
Relation targets provided here are added to those specified with Filter3.Relations. Relation components must be in the filter's parameters or added via Filter3.With beforehand.
⚠️ The returned Batch filter should not be stored, but used immediately and re-generated each time a batch operation is called. Otherwise, changes to the origin filter or calls to Filter3.Batch or Filter3.Query with different relationship targets may modify stored instances.
func (*Filter3[A, B, C]) Exclusive ¶
Exclusive makes the filter exclusive in the sense that the component composition is matched exactly, and no other components are allowed.
func (*Filter3[A, B, C]) New ¶
New creates a new Filter3. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Filter2.New for an example.
func (*Filter3[A, B, C]) Query ¶
Query creates a Query3 from this filter. This must be used each time before iterating a query.
Relation targets provided here are added to those specified with Filter3.Relations. Relation components must be in the filter's parameters or added via Filter3.With beforehand.
⚠️ The returned Query3 should not be stored, but used immediately and re-generated each time before query iteration. Otherwise, changes to the origin filter or calls to Filter3.Batch or Filter3.Query with different relationship targets may modify stored instances.
func (*Filter3[A, B, C]) Register ¶
Register this filter to the world's filter cache.
Registering filters is optional. It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func (*Filter3[A, B, C]) Relations ¶
Relations sets permanent entity relation targets for this filter. Relation targets set here are included in filter caching. Contrary, relation targets specified in Filter3.Query or Filter3.Batch are not cached.
Relation components used here must be in the filter's parameters or added via Filter3.With beforehand.
Can be called multiple times in chains, or once with multiple arguments.
func (*Filter3[A, B, C]) Unregister ¶
func (f *Filter3[A, B, C]) Unregister()
Unregister this filter from the world's filter cache.
type Filter4 ¶
Filter4 is a filter for 4 components. Used to create Query4 iterators.
Instances should be created during initialization and stored, e.g. in systems.
See Filter2 for a usage example.
func (*Filter4[A, B, C, D]) Batch ¶
Batch creates a Batch from this filter.
Relation targets provided here are added to those specified with Filter4.Relations. Relation components must be in the filter's parameters or added via Filter4.With beforehand.
⚠️ The returned Batch filter should not be stored, but used immediately and re-generated each time a batch operation is called. Otherwise, changes to the origin filter or calls to Filter4.Batch or Filter4.Query with different relationship targets may modify stored instances.
func (*Filter4[A, B, C, D]) Exclusive ¶
Exclusive makes the filter exclusive in the sense that the component composition is matched exactly, and no other components are allowed.
func (*Filter4[A, B, C, D]) New ¶
New creates a new Filter4. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Filter2.New for an example.
func (*Filter4[A, B, C, D]) Query ¶
Query creates a Query4 from this filter. This must be used each time before iterating a query.
Relation targets provided here are added to those specified with Filter4.Relations. Relation components must be in the filter's parameters or added via Filter4.With beforehand.
⚠️ The returned Query4 should not be stored, but used immediately and re-generated each time before query iteration. Otherwise, changes to the origin filter or calls to Filter4.Batch or Filter4.Query with different relationship targets may modify stored instances.
func (*Filter4[A, B, C, D]) Register ¶
Register this filter to the world's filter cache.
Registering filters is optional. It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func (*Filter4[A, B, C, D]) Relations ¶
Relations sets permanent entity relation targets for this filter. Relation targets set here are included in filter caching. Contrary, relation targets specified in Filter4.Query or Filter4.Batch are not cached.
Relation components used here must be in the filter's parameters or added via Filter4.With beforehand.
Can be called multiple times in chains, or once with multiple arguments.
func (*Filter4[A, B, C, D]) Unregister ¶
func (f *Filter4[A, B, C, D]) Unregister()
Unregister this filter from the world's filter cache.
type Filter5 ¶
type Filter5[A any, B any, C any, D any, E any] struct { // contains filtered or unexported fields }
Filter5 is a filter for 5 components. Used to create Query5 iterators.
Instances should be created during initialization and stored, e.g. in systems.
See Filter2 for a usage example.
func (*Filter5[A, B, C, D, E]) Batch ¶
Batch creates a Batch from this filter.
Relation targets provided here are added to those specified with Filter5.Relations. Relation components must be in the filter's parameters or added via Filter5.With beforehand.
⚠️ The returned Batch filter should not be stored, but used immediately and re-generated each time a batch operation is called. Otherwise, changes to the origin filter or calls to Filter5.Batch or Filter5.Query with different relationship targets may modify stored instances.
func (*Filter5[A, B, C, D, E]) Exclusive ¶
Exclusive makes the filter exclusive in the sense that the component composition is matched exactly, and no other components are allowed.
func (*Filter5[A, B, C, D, E]) New ¶
New creates a new Filter5. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Filter2.New for an example.
func (*Filter5[A, B, C, D, E]) Query ¶
Query creates a Query5 from this filter. This must be used each time before iterating a query.
Relation targets provided here are added to those specified with Filter5.Relations. Relation components must be in the filter's parameters or added via Filter5.With beforehand.
⚠️ The returned Query5 should not be stored, but used immediately and re-generated each time before query iteration. Otherwise, changes to the origin filter or calls to Filter5.Batch or Filter5.Query with different relationship targets may modify stored instances.
func (*Filter5[A, B, C, D, E]) Register ¶
Register this filter to the world's filter cache.
Registering filters is optional. It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func (*Filter5[A, B, C, D, E]) Relations ¶
Relations sets permanent entity relation targets for this filter. Relation targets set here are included in filter caching. Contrary, relation targets specified in Filter5.Query or Filter5.Batch are not cached.
Relation components used here must be in the filter's parameters or added via Filter5.With beforehand.
Can be called multiple times in chains, or once with multiple arguments.
func (*Filter5[A, B, C, D, E]) Unregister ¶
func (f *Filter5[A, B, C, D, E]) Unregister()
Unregister this filter from the world's filter cache.
type Filter6 ¶
type Filter6[A any, B any, C any, D any, E any, F any] struct { // contains filtered or unexported fields }
Filter6 is a filter for 6 components. Used to create Query6 iterators.
Instances should be created during initialization and stored, e.g. in systems.
See Filter2 for a usage example.
func (*Filter6[A, B, C, D, E, F]) Batch ¶
Batch creates a Batch from this filter.
Relation targets provided here are added to those specified with Filter6.Relations. Relation components must be in the filter's parameters or added via Filter6.With beforehand.
⚠️ The returned Batch filter should not be stored, but used immediately and re-generated each time a batch operation is called. Otherwise, changes to the origin filter or calls to Filter6.Batch or Filter6.Query with different relationship targets may modify stored instances.
func (*Filter6[A, B, C, D, E, F]) Exclusive ¶
Exclusive makes the filter exclusive in the sense that the component composition is matched exactly, and no other components are allowed.
func (*Filter6[A, B, C, D, E, F]) New ¶
New creates a new Filter6. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Filter2.New for an example.
func (*Filter6[A, B, C, D, E, F]) Query ¶
Query creates a Query6 from this filter. This must be used each time before iterating a query.
Relation targets provided here are added to those specified with Filter6.Relations. Relation components must be in the filter's parameters or added via Filter6.With beforehand.
⚠️ The returned Query6 should not be stored, but used immediately and re-generated each time before query iteration. Otherwise, changes to the origin filter or calls to Filter6.Batch or Filter6.Query with different relationship targets may modify stored instances.
func (*Filter6[A, B, C, D, E, F]) Register ¶
Register this filter to the world's filter cache.
Registering filters is optional. It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func (*Filter6[A, B, C, D, E, F]) Relations ¶
Relations sets permanent entity relation targets for this filter. Relation targets set here are included in filter caching. Contrary, relation targets specified in Filter6.Query or Filter6.Batch are not cached.
Relation components used here must be in the filter's parameters or added via Filter6.With beforehand.
Can be called multiple times in chains, or once with multiple arguments.
func (*Filter6[A, B, C, D, E, F]) Unregister ¶
func (f *Filter6[A, B, C, D, E, F]) Unregister()
Unregister this filter from the world's filter cache.
type Filter7 ¶
type Filter7[A any, B any, C any, D any, E any, F any, G any] struct { // contains filtered or unexported fields }
Filter7 is a filter for 7 components. Used to create Query7 iterators.
Instances should be created during initialization and stored, e.g. in systems.
See Filter2 for a usage example.
func NewFilter7 ¶
func NewFilter7[A any, B any, C any, D any, E any, F any, G any](world *World) *Filter7[A, B, C, D, E, F, G]
NewFilter7 creates a new Filter7.
Use Filter7.Query to obtain a Query7.
func (*Filter7[A, B, C, D, E, F, G]) Batch ¶
Batch creates a Batch from this filter.
Relation targets provided here are added to those specified with Filter7.Relations. Relation components must be in the filter's parameters or added via Filter7.With beforehand.
⚠️ The returned Batch filter should not be stored, but used immediately and re-generated each time a batch operation is called. Otherwise, changes to the origin filter or calls to Filter7.Batch or Filter7.Query with different relationship targets may modify stored instances.
func (*Filter7[A, B, C, D, E, F, G]) Exclusive ¶
Exclusive makes the filter exclusive in the sense that the component composition is matched exactly, and no other components are allowed.
func (*Filter7[A, B, C, D, E, F, G]) New ¶
New creates a new Filter7. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Filter2.New for an example.
func (*Filter7[A, B, C, D, E, F, G]) Query ¶
Query creates a Query7 from this filter. This must be used each time before iterating a query.
Relation targets provided here are added to those specified with Filter7.Relations. Relation components must be in the filter's parameters or added via Filter7.With beforehand.
⚠️ The returned Query7 should not be stored, but used immediately and re-generated each time before query iteration. Otherwise, changes to the origin filter or calls to Filter7.Batch or Filter7.Query with different relationship targets may modify stored instances.
func (*Filter7[A, B, C, D, E, F, G]) Register ¶
Register this filter to the world's filter cache.
Registering filters is optional. It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func (*Filter7[A, B, C, D, E, F, G]) Relations ¶
Relations sets permanent entity relation targets for this filter. Relation targets set here are included in filter caching. Contrary, relation targets specified in Filter7.Query or Filter7.Batch are not cached.
Relation components used here must be in the filter's parameters or added via Filter7.With beforehand.
Can be called multiple times in chains, or once with multiple arguments.
func (*Filter7[A, B, C, D, E, F, G]) Unregister ¶
func (f *Filter7[A, B, C, D, E, F, G]) Unregister()
Unregister this filter from the world's filter cache.
type Filter8 ¶
type Filter8[A any, B any, C any, D any, E any, F any, G any, H any] struct { // contains filtered or unexported fields }
Filter8 is a filter for 8 components. Used to create Query8 iterators.
Instances should be created during initialization and stored, e.g. in systems.
See Filter2 for a usage example.
func NewFilter8 ¶
func NewFilter8[A any, B any, C any, D any, E any, F any, G any, H any](world *World) *Filter8[A, B, C, D, E, F, G, H]
NewFilter8 creates a new Filter8.
Use Filter8.Query to obtain a Query8.
func (*Filter8[A, B, C, D, E, F, G, H]) Batch ¶
Batch creates a Batch from this filter.
Relation targets provided here are added to those specified with Filter8.Relations. Relation components must be in the filter's parameters or added via Filter8.With beforehand.
⚠️ The returned Batch filter should not be stored, but used immediately and re-generated each time a batch operation is called. Otherwise, changes to the origin filter or calls to Filter8.Batch or Filter8.Query with different relationship targets may modify stored instances.
func (*Filter8[A, B, C, D, E, F, G, H]) Exclusive ¶
Exclusive makes the filter exclusive in the sense that the component composition is matched exactly, and no other components are allowed.
func (*Filter8[A, B, C, D, E, F, G, H]) New ¶
New creates a new Filter8. It is safe to call on `nil` instance. It is a helper method, intended to avoid repeated listing of type parameters.
See Filter2.New for an example.
func (*Filter8[A, B, C, D, E, F, G, H]) Query ¶
Query creates a Query8 from this filter. This must be used each time before iterating a query.
Relation targets provided here are added to those specified with Filter8.Relations. Relation components must be in the filter's parameters or added via Filter8.With beforehand.
⚠️ The returned Query8 should not be stored, but used immediately and re-generated each time before query iteration. Otherwise, changes to the origin filter or calls to Filter8.Batch or Filter8.Query with different relationship targets may modify stored instances.
func (*Filter8[A, B, C, D, E, F, G, H]) Register ¶
Register this filter to the world's filter cache.
Registering filters is optional. It avoids a potential slowdown that may be caused by a very high number of archetypes, like hundreds or thousands.
func (*Filter8[A, B, C, D, E, F, G, H]) Relations ¶
func (f *Filter8[A, B, C, D, E, F, G, H]) Relations(rel ...Relation) *Filter8[A, B, C, D, E, F, G, H]
Relations sets permanent entity relation targets for this filter. Relation targets set here are included in filter caching. Contrary, relation targets specified in Filter8.Query or Filter8.Batch are not cached.
Relation components used here must be in the filter's parameters or added via Filter8.With beforehand.
Can be called multiple times in chains, or once with multiple arguments.
func (*Filter8[A, B, C, D, E, F, G, H]) Unregister ¶
func (f *Filter8[A, B, C, D, E, F, G, H]) Unregister()
Unregister this filter from the world's filter cache.
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
ID is the component identifier. It is not relevant when using the default generic API.
func ComponentID ¶
ComponentID returns the ID for a component type via generics. Registers the type if it is not already registered.
The number of unique component types per World is limited to 256 (64 with build tag ark_tiny).
Panics if called on a locked world and the type is not registered yet.
Note that type aliases are not considered separate component types. Type re-definitions, however, are separate types.
⚠️ Warning: Using IDs that are outside of the range of registered IDs anywhere in World or other places will result in undefined behavior!
func ComponentIDs ¶
ComponentIDs returns a list of all registered component IDs.
type IDs ¶
type IDs struct {
// contains filtered or unexported fields
}
IDs is an immutable list of ID values.
type Map ¶
type Map[T any] struct { // contains filtered or unexported fields }
Map is a mapper to access and manipulate components of an entity.
Instances should be created during initialization and stored, e.g. in systems.
Example ¶
world := ecs.NewWorld()
// Create a component mapper.
mapper := ecs.NewMap[Position](&world)
// Create an entity.
entity := mapper.NewEntity(&Position{X: 100, Y: 100})
// Remove component from the entity.
mapper.Remove(entity)
// Add component to the entity.
mapper.Add(entity, &Position{X: 100, Y: 100})
func (*Map[T]) Add ¶
Add the mapped component to the given entity.
If the mapped component is a relationship (see RelationMarker), a relation target entity must be provided.
func (*Map[T]) AddBatch ¶
AddBatch adds the mapped component to all entities matching the given batch filter.
If the mapped component is a relationship (see RelationMarker), a relation target entity must be provided.
func (*Map[T]) AddBatchFn ¶
AddBatchFn adds the mapped component to all entities matching the given batch filter, running the given function on each. The function can be nil.
If the mapped component is a relationship (see RelationMarker), a relation target entity must be provided.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Map[T]) AddFn ¶
AddFn adds the mapped component to the given entity and runs a callback instead of using a component for initialization. The callback can be nil.
If the mapped component is a relationship (see RelationMarker), a relation target entity must be provided.
⚠️ Do not store the obtained pointer outside of the current context!
func (*Map[T]) Get ¶
Get returns the mapped component for the given entity.
Returns nil if the entity does not have the mapped component.
⚠️ Do not store the obtained pointer outside of the current context!
func (*Map[T]) GetRelation ¶
GetRelation returns the relation target for the entity and the mapped component.
func (*Map[T]) GetRelationUnchecked ¶
GetRelationUnchecked returns the relation target for the entity and the mapped component. In contrast to Map.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 (*Map[T]) GetUnchecked ¶
GetUnchecked returns the mapped component for the given entity. In contrast to Map.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.
Returns nil if the entity does not have the mapped component.
⚠️ Do not store the obtained pointer outside of the current context!
func (*Map[T]) Has ¶
Has return whether the given entity has the mapped component.
Using Map.Get and checking for nil pointer may be faster than calling Map.Has and Map.Get subsequently.
func (*Map[T]) HasUnchecked ¶
HasUnchecked return whether the given entity has the mapped component. In contrast to Map.Has, 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 (*Map[T]) NewBatch ¶
NewBatch creates a batch of new entities with the mapped component.
If the mapped component is a relationship (see RelationMarker), a relation target entity must be provided.
func (*Map[T]) NewBatchFn ¶
NewBatchFn creates a batch of new entities with the mapped components, running the given initializer function on each. The initializer function can be nil.
If the mapped component is a relationship (see RelationMarker), a relation target entity must be provided.
⚠️ Do not store the obtained pointers outside of the current context!
func (*Map[T]) NewEntity ¶
NewEntity creates a new entity with the mapped component.
If the mapped component is a relationship (see RelationMarker), a relation target entity must be provided.
func (*Map[T]) NewEntityFn ¶
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.
If the mapped component is a relationship (see RelationMarker), a relation target entity must be provided.
⚠️ Do not store the obtained pointer outside of the current context!
func (*Map[T]) RemoveBatch ¶
RemoveBatch removes the mapped component from all entities matching the given batch filter, running the given function on each. The function can be nil.
func (*Map[T]) Set ¶
Set the mapped component of the given entity to the given values.
Requires the entity to already have the mapped component. This is not a component operation, so it can be performed on a locked world.
func (*Map[T]) SetRelation ¶
SetRelation sets the relation target for the entity and the mapped component.
type Map1 ¶
type Map1[A any] struct { // contains filtered or unexported fields }
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.
func (*Map1[A]) Add ¶
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[A]) AddBatch ¶
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[A]) AddBatchFn ¶
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[A]) AddFn ¶
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[A]) Get ¶
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[A]) GetRelation ¶
GetRelation returns the relation target of an entity for the component at the given index.
func (*Map1[A]) 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[A]) GetUnchecked ¶
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[A]) HasAll ¶
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[A]) New ¶
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[A]) NewBatch ¶
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[A]) NewBatchFn ¶
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[A]) NewEntity ¶
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[A]) NewEntityFn ¶
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[A]) RemoveBatch ¶
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[A]) Set ¶
Set the mapped components of the given entity to the given values.
Requires the entity to already have all the mapped components. This is not a component operation, so it can be performed on a locked world.
func (*Map1[A]) SetRelations ¶
SetRelations sets relation targets for the given entity.
type Map10 ¶
type Map10[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any] struct { // contains filtered or unexported fields }
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.
func NewMap10 ¶
func NewMap10[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any](world *World) *Map10[A, B, C, D, E, F, G, H, I, J]
NewMap10 creates a new Map10.
func (*Map10[A, B, C, D, E, F, G, H, I, J]) Add ¶
func (m *Map10[A, B, C, D, E, F, G, H, I, J]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J]) AddBatch ¶
func (m *Map10[A, B, C, D, E, F, G, H, I, J]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J]) AddBatchFn ¶
func (m *Map10[A, B, C, D, E, F, G, H, I, J]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J), rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J]) AddFn ¶
func (m *Map10[A, B, C, D, E, F, G, H, I, J]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J), rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J]) Get ¶
func (m *Map10[A, B, C, D, E, F, G, H, I, J]) Get(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I, *J)
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[A, B, C, D, E, F, G, H, I, J]) GetRelation ¶
GetRelation returns the relation target of an entity for the component at the given index.
func (*Map10[A, B, C, D, E, F, G, H, I, J]) 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[A, B, C, D, E, F, G, H, I, J]) GetUnchecked ¶
func (m *Map10[A, B, C, D, E, F, G, H, I, J]) GetUnchecked(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I, *J)
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[A, B, C, D, E, F, G, H, I, J]) HasAll ¶
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[A, B, C, D, E, F, G, H, I, J]) New ¶
func (_ *Map10[A, B, C, D, E, F, G, H, I, J]) New(world *World) *Map10[A, B, C, D, E, F, G, H, I, J]
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[A, B, C, D, E, F, G, H, I, J]) NewBatch ¶
func (m *Map10[A, B, C, D, E, F, G, H, I, J]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J]) NewBatchFn ¶
func (m *Map10[A, B, C, D, E, F, G, H, I, J]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J), rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J]) NewEntity ¶
func (m *Map10[A, B, C, D, E, F, G, H, I, J]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, rel ...Relation) Entity
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[A, B, C, D, E, F, G, H, I, J]) NewEntityFn ¶
func (m *Map10[A, B, C, D, E, F, G, H, I, J]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J), rel ...Relation) Entity
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[A, B, C, D, E, F, G, H, I, J]) Remove ¶
Remove the mapped components from the given entity.
func (*Map10[A, B, C, D, E, F, G, H, I, J]) RemoveBatch ¶
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[A, B, C, D, E, F, G, H, I, J]) Set ¶
func (m *Map10[A, B, C, D, E, F, G, H, I, J]) Set(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J)
Set the mapped components of the given entity to the given values.
Requires the entity to already have all the mapped components. This is not a component operation, so it can be performed on a locked world.
func (*Map10[A, B, C, D, E, F, G, H, I, J]) SetRelations ¶
SetRelations sets relation targets for the given entity.
type Map11 ¶
type Map11[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any, K any] struct { // contains filtered or unexported fields }
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.
func NewMap11 ¶
func NewMap11[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any, K any](world *World) *Map11[A, B, C, D, E, F, G, H, I, J, K]
NewMap11 creates a new Map11.
func (*Map11[A, B, C, D, E, F, G, H, I, J, K]) Add ¶
func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J, K]) AddBatch ¶
func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J, K]) AddBatchFn ¶
func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K), rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J, K]) AddFn ¶
func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K), rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J, K]) Get ¶
func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) Get(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I, *J, *K)
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[A, B, C, D, E, F, G, H, I, J, K]) GetRelation ¶
GetRelation returns the relation target of an entity for the component at the given index.
func (*Map11[A, B, C, D, E, F, G, H, I, J, K]) GetRelationUnchecked ¶
func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) GetRelationUnchecked(entity Entity, index int) Entity
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[A, B, C, D, E, F, G, H, I, J, K]) GetUnchecked ¶
func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) GetUnchecked(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I, *J, *K)
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[A, B, C, D, E, F, G, H, I, J, K]) HasAll ¶
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[A, B, C, D, E, F, G, H, I, J, K]) New ¶
func (_ *Map11[A, B, C, D, E, F, G, H, I, J, K]) New(world *World) *Map11[A, B, C, D, E, F, G, H, I, J, K]
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[A, B, C, D, E, F, G, H, I, J, K]) NewBatch ¶
func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J, K]) NewBatchFn ¶
func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K), rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J, K]) NewEntity ¶
func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, rel ...Relation) Entity
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[A, B, C, D, E, F, G, H, I, J, K]) NewEntityFn ¶
func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K), rel ...Relation) Entity
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[A, B, C, D, E, F, G, H, I, J, K]) Remove ¶
Remove the mapped components from the given entity.
func (*Map11[A, B, C, D, E, F, G, H, I, J, K]) RemoveBatch ¶
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[A, B, C, D, E, F, G, H, I, J, K]) Set ¶
func (m *Map11[A, B, C, D, E, F, G, H, I, J, K]) Set(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K)
Set the mapped components of the given entity to the given values.
Requires the entity to already have all the mapped components. This is not a component operation, so it can be performed on a locked world.
func (*Map11[A, B, C, D, E, F, G, H, I, J, K]) SetRelations ¶
SetRelations sets relation targets for the given entity.
type Map12 ¶
type Map12[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any, K any, L any] struct { // contains filtered or unexported fields }
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.
func NewMap12 ¶
func NewMap12[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any, K any, L any](world *World) *Map12[A, B, C, D, E, F, G, H, I, J, K, L]
NewMap12 creates a new Map12.
func (*Map12[A, B, C, D, E, F, G, H, I, J, K, L]) Add ¶
func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, l *L, rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J, K, L]) AddBatch ¶
func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, l *L, rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J, K, L]) AddBatchFn ¶
func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, l *L), rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J, K, L]) AddFn ¶
func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, l *L), rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J, K, L]) Get ¶
func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) Get(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I, *J, *K, *L)
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[A, B, C, D, E, F, G, H, I, J, K, L]) GetRelation ¶
GetRelation returns the relation target of an entity for the component at the given index.
func (*Map12[A, B, C, D, E, F, G, H, I, J, K, L]) GetRelationUnchecked ¶
func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) GetRelationUnchecked(entity Entity, index int) Entity
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[A, B, C, D, E, F, G, H, I, J, K, L]) GetUnchecked ¶
func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) GetUnchecked(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I, *J, *K, *L)
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[A, B, C, D, E, F, G, H, I, J, K, L]) HasAll ¶
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[A, B, C, D, E, F, G, H, I, J, K, L]) New ¶
func (_ *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) New(world *World) *Map12[A, B, C, D, E, F, G, H, I, J, K, L]
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[A, B, C, D, E, F, G, H, I, J, K, L]) NewBatch ¶
func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, l *L, rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J, K, L]) NewBatchFn ¶
func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, l *L), rel ...Relation)
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[A, B, C, D, E, F, G, H, I, J, K, L]) NewEntity ¶
func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, l *L, rel ...Relation) Entity
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[A, B, C, D, E, F, G, H, I, J, K, L]) NewEntityFn ¶
func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, l *L), rel ...Relation) Entity
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[A, B, C, D, E, F, G, H, I, J, K, L]) Remove ¶
Remove the mapped components from the given entity.
func (*Map12[A, B, C, D, E, F, G, H, I, J, K, L]) RemoveBatch ¶
func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) RemoveBatch(batch *Batch, fn func(entity Entity))
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[A, B, C, D, E, F, G, H, I, J, K, L]) Set ¶
func (m *Map12[A, B, C, D, E, F, G, H, I, J, K, L]) Set(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, j *J, k *K, l *L)
Set the mapped components of the given entity to the given values.
Requires the entity to already have all the mapped components. This is not a component operation, so it can be performed on a locked world.
func (*Map12[A, B, C, D, E, F, G, H, I, J, K, L]) SetRelations ¶
SetRelations sets relation targets for the given entity.
type Map2 ¶
Map2 is a mapper to access 2 components of an entity.
Instances should be created during initialization and stored, e.g. in systems.
Example ¶
world := ecs.NewWorld()
// Create a component mapper.
mapper := ecs.NewMap2[Position, Velocity](&world)
// Create an entity.
entity := mapper.NewEntity(&Position{X: 100, Y: 100}, &Velocity{X: 1, Y: -1})
// Remove components from the entity.
mapper.Remove(entity)
// Add components to the entity.
mapper.Add(entity, &Position{X: 100, Y: 100}, &Velocity{X: 1, Y: -1})
func (*Map2[A, B]) Add ¶
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[A, B]) AddBatch ¶
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[A, B]) AddBatchFn ¶
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[A, B]) AddFn ¶
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[A, B]) Get ¶
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[A, B]) GetRelation ¶
GetRelation returns the relation target of an entity for the component at the given index.
func (*Map2[A, B]) 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[A, B]) GetUnchecked ¶
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[A, B]) HasAll ¶
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[A, B]) New ¶
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.
Example ¶
world := ecs.NewWorld() // Declare the mapper, e.g. in your system struct. var mapper *ecs.Map2[Position, Velocity] // Construct the mapper, avoiding repeated listing of generics. mapper = mapper.New(&world)
func (*Map2[A, B]) NewBatch ¶
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[A, B]) NewBatchFn ¶
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[A, B]) NewEntity ¶
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[A, B]) NewEntityFn ¶
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[A, B]) RemoveBatch ¶
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[A, B]) Set ¶
Set the mapped components of the given entity to the given values.
Requires the entity to already have all the mapped components. This is not a component operation, so it can be performed on a locked world.
func (*Map2[A, B]) SetRelations ¶
SetRelations sets relation targets for the given entity.
type Map3 ¶
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.
func (*Map3[A, B, C]) Add ¶
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[A, B, C]) AddBatch ¶
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[A, B, C]) AddBatchFn ¶
func (m *Map3[A, B, C]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C), rel ...Relation)
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[A, B, C]) AddFn ¶
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[A, B, C]) Get ¶
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[A, B, C]) GetRelation ¶
GetRelation returns the relation target of an entity for the component at the given index.
func (*Map3[A, B, C]) 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[A, B, C]) GetUnchecked ¶
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[A, B, C]) HasAll ¶
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[A, B, C]) New ¶
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[A, B, C]) NewBatch ¶
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[A, B, C]) NewBatchFn ¶
func (m *Map3[A, B, C]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C), rel ...Relation)
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[A, B, C]) NewEntity ¶
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[A, B, C]) NewEntityFn ¶
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[A, B, C]) RemoveBatch ¶
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[A, B, C]) Set ¶
Set the mapped components of the given entity to the given values.
Requires the entity to already have all the mapped components. This is not a component operation, so it can be performed on a locked world.
func (*Map3[A, B, C]) SetRelations ¶
SetRelations sets relation targets for the given entity.
type Map4 ¶
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.
func (*Map4[A, B, C, D]) Add ¶
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[A, B, C, D]) AddBatch ¶
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[A, B, C, D]) AddBatchFn ¶
func (m *Map4[A, B, C, D]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D), rel ...Relation)
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[A, B, C, D]) AddFn ¶
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[A, B, C, D]) Get ¶
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[A, B, C, D]) GetRelation ¶
GetRelation returns the relation target of an entity for the component at the given index.
func (*Map4[A, B, C, D]) 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[A, B, C, D]) GetUnchecked ¶
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[A, B, C, D]) HasAll ¶
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[A, B, C, D]) New ¶
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[A, B, C, D]) NewBatch ¶
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[A, B, C, D]) NewBatchFn ¶
func (m *Map4[A, B, C, D]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C, d *D), rel ...Relation)
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[A, B, C, D]) NewEntity ¶
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[A, B, C, D]) NewEntityFn ¶
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[A, B, C, D]) RemoveBatch ¶
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[A, B, C, D]) Set ¶
Set the mapped components of the given entity to the given values.
Requires the entity to already have all the mapped components. This is not a component operation, so it can be performed on a locked world.
func (*Map4[A, B, C, D]) SetRelations ¶
SetRelations sets relation targets for the given entity.
type Map5 ¶
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.
func (*Map5[A, B, C, D, E]) Add ¶
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[A, B, C, D, E]) AddBatch ¶
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[A, B, C, D, E]) AddBatchFn ¶
func (m *Map5[A, B, C, D, E]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E), rel ...Relation)
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[A, B, C, D, E]) AddFn ¶
func (m *Map5[A, B, C, D, E]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E), rel ...Relation)
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[A, B, C, D, E]) Get ¶
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[A, B, C, D, E]) GetRelation ¶
GetRelation returns the relation target of an entity for the component at the given index.
func (*Map5[A, B, C, D, E]) 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[A, B, C, D, E]) GetUnchecked ¶
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[A, B, C, D, E]) HasAll ¶
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[A, B, C, D, E]) New ¶
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[A, B, C, D, E]) NewBatch ¶
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[A, B, C, D, E]) NewBatchFn ¶
func (m *Map5[A, B, C, D, E]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E), rel ...Relation)
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[A, B, C, D, E]) NewEntity ¶
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[A, B, C, D, E]) NewEntityFn ¶
func (m *Map5[A, B, C, D, E]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E), rel ...Relation) Entity
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[A, B, C, D, E]) RemoveBatch ¶
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[A, B, C, D, E]) Set ¶
Set the mapped components of the given entity to the given values.
Requires the entity to already have all the mapped components. This is not a component operation, so it can be performed on a locked world.
func (*Map5[A, B, C, D, E]) SetRelations ¶
SetRelations sets relation targets for the given entity.
type Map6 ¶
type Map6[A any, B any, C any, D any, E any, F any] struct { // contains filtered or unexported fields }
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.
func (*Map6[A, B, C, D, E, F]) Add ¶
func (m *Map6[A, B, C, D, E, F]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
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[A, B, C, D, E, F]) AddBatch ¶
func (m *Map6[A, B, C, D, E, F]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
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[A, B, C, D, E, F]) AddBatchFn ¶
func (m *Map6[A, B, C, D, E, F]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F), rel ...Relation)
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[A, B, C, D, E, F]) AddFn ¶
func (m *Map6[A, B, C, D, E, F]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F), rel ...Relation)
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[A, B, C, D, E, F]) Get ¶
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[A, B, C, D, E, F]) GetRelation ¶
GetRelation returns the relation target of an entity for the component at the given index.
func (*Map6[A, B, C, D, E, F]) 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[A, B, C, D, E, F]) GetUnchecked ¶
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[A, B, C, D, E, F]) HasAll ¶
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[A, B, C, D, E, F]) New ¶
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[A, B, C, D, E, F]) NewBatch ¶
func (m *Map6[A, B, C, D, E, F]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation)
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[A, B, C, D, E, F]) NewBatchFn ¶
func (m *Map6[A, B, C, D, E, F]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F), rel ...Relation)
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[A, B, C, D, E, F]) NewEntity ¶
func (m *Map6[A, B, C, D, E, F]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, rel ...Relation) Entity
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[A, B, C, D, E, F]) NewEntityFn ¶
func (m *Map6[A, B, C, D, E, F]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E, f *F), rel ...Relation) Entity
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[A, B, C, D, E, F]) RemoveBatch ¶
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[A, B, C, D, E, F]) Set ¶
Set the mapped components of the given entity to the given values.
Requires the entity to already have all the mapped components. This is not a component operation, so it can be performed on a locked world.
func (*Map6[A, B, C, D, E, F]) SetRelations ¶
SetRelations sets relation targets for the given entity.
type Map7 ¶
type Map7[A any, B any, C any, D any, E any, F any, G any] struct { // contains filtered or unexported fields }
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.
func NewMap7 ¶
func NewMap7[A any, B any, C any, D any, E any, F any, G any](world *World) *Map7[A, B, C, D, E, F, G]
NewMap7 creates a new Map7.
func (*Map7[A, B, C, D, E, F, G]) Add ¶
func (m *Map7[A, B, C, D, E, F, G]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
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[A, B, C, D, E, F, G]) AddBatch ¶
func (m *Map7[A, B, C, D, E, F, G]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
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[A, B, C, D, E, F, G]) AddBatchFn ¶
func (m *Map7[A, B, C, D, E, F, G]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G), rel ...Relation)
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[A, B, C, D, E, F, G]) AddFn ¶
func (m *Map7[A, B, C, D, E, F, G]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G), rel ...Relation)
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[A, B, C, D, E, F, G]) Get ¶
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[A, B, C, D, E, F, G]) GetRelation ¶
GetRelation returns the relation target of an entity for the component at the given index.
func (*Map7[A, B, C, D, E, F, G]) 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[A, B, C, D, E, F, G]) GetUnchecked ¶
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[A, B, C, D, E, F, G]) HasAll ¶
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[A, B, C, D, E, F, G]) New ¶
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[A, B, C, D, E, F, G]) NewBatch ¶
func (m *Map7[A, B, C, D, E, F, G]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation)
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[A, B, C, D, E, F, G]) NewBatchFn ¶
func (m *Map7[A, B, C, D, E, F, G]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G), rel ...Relation)
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[A, B, C, D, E, F, G]) NewEntity ¶
func (m *Map7[A, B, C, D, E, F, G]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, g *G, rel ...Relation) Entity
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[A, B, C, D, E, F, G]) NewEntityFn ¶
func (m *Map7[A, B, C, D, E, F, G]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G), rel ...Relation) Entity
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[A, B, C, D, E, F, G]) RemoveBatch ¶
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[A, B, C, D, E, F, G]) Set ¶
Set the mapped components of the given entity to the given values.
Requires the entity to already have all the mapped components. This is not a component operation, so it can be performed on a locked world.
func (*Map7[A, B, C, D, E, F, G]) SetRelations ¶
SetRelations sets relation targets for the given entity.
type Map8 ¶
type Map8[A any, B any, C any, D any, E any, F any, G any, H any] struct { // contains filtered or unexported fields }
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.
func NewMap8 ¶
func NewMap8[A any, B any, C any, D any, E any, F any, G any, H any](world *World) *Map8[A, B, C, D, E, F, G, H]
NewMap8 creates a new Map8.
func (*Map8[A, B, C, D, E, F, G, H]) Add ¶
func (m *Map8[A, B, C, D, E, F, G, H]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
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[A, B, C, D, E, F, G, H]) AddBatch ¶
func (m *Map8[A, B, C, D, E, F, G, H]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
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[A, B, C, D, E, F, G, H]) AddBatchFn ¶
func (m *Map8[A, B, C, D, E, F, G, H]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H), rel ...Relation)
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[A, B, C, D, E, F, G, H]) AddFn ¶
func (m *Map8[A, B, C, D, E, F, G, H]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H), rel ...Relation)
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[A, B, C, D, E, F, G, H]) Get ¶
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[A, B, C, D, E, F, G, H]) GetRelation ¶
GetRelation returns the relation target of an entity for the component at the given index.
func (*Map8[A, B, C, D, E, F, G, H]) 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[A, B, C, D, E, F, G, H]) GetUnchecked ¶
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[A, B, C, D, E, F, G, H]) HasAll ¶
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[A, B, C, D, E, F, G, H]) New ¶
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[A, B, C, D, E, F, G, H]) NewBatch ¶
func (m *Map8[A, B, C, D, E, F, G, H]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation)
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[A, B, C, D, E, F, G, H]) NewBatchFn ¶
func (m *Map8[A, B, C, D, E, F, G, H]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H), rel ...Relation)
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[A, B, C, D, E, F, G, H]) NewEntity ¶
func (m *Map8[A, B, C, D, E, F, G, H]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, rel ...Relation) Entity
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[A, B, C, D, E, F, G, H]) NewEntityFn ¶
func (m *Map8[A, B, C, D, E, F, G, H]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H), rel ...Relation) Entity
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[A, B, C, D, E, F, G, H]) RemoveBatch ¶
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[A, B, C, D, E, F, G, H]) Set ¶
func (m *Map8[A, B, C, D, E, F, G, H]) Set(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H)
Set the mapped components of the given entity to the given values.
Requires the entity to already have all the mapped components. This is not a component operation, so it can be performed on a locked world.
func (*Map8[A, B, C, D, E, F, G, H]) SetRelations ¶
SetRelations sets relation targets for the given entity.
type Map9 ¶
type Map9[A any, B any, C any, D any, E any, F any, G any, H any, I any] struct { // contains filtered or unexported fields }
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.
func NewMap9 ¶
func NewMap9[A any, B any, C any, D any, E any, F any, G any, H any, I any](world *World) *Map9[A, B, C, D, E, F, G, H, I]
NewMap9 creates a new Map9.
func (*Map9[A, B, C, D, E, F, G, H, I]) Add ¶
func (m *Map9[A, B, C, D, E, F, G, H, I]) Add(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, rel ...Relation)
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[A, B, C, D, E, F, G, H, I]) AddBatch ¶
func (m *Map9[A, B, C, D, E, F, G, H, I]) AddBatch(batch *Batch, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, rel ...Relation)
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[A, B, C, D, E, F, G, H, I]) AddBatchFn ¶
func (m *Map9[A, B, C, D, E, F, G, H, I]) AddBatchFn(batch *Batch, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I), rel ...Relation)
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[A, B, C, D, E, F, G, H, I]) AddFn ¶
func (m *Map9[A, B, C, D, E, F, G, H, I]) AddFn(entity Entity, fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I), rel ...Relation)
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[A, B, C, D, E, F, G, H, I]) Get ¶
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[A, B, C, D, E, F, G, H, I]) GetRelation ¶
GetRelation returns the relation target of an entity for the component at the given index.
func (*Map9[A, B, C, D, E, F, G, H, I]) 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[A, B, C, D, E, F, G, H, I]) GetUnchecked ¶
func (m *Map9[A, B, C, D, E, F, G, H, I]) GetUnchecked(entity Entity) (*A, *B, *C, *D, *E, *F, *G, *H, *I)
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[A, B, C, D, E, F, G, H, I]) HasAll ¶
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[A, B, C, D, E, F, G, H, I]) New ¶
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[A, B, C, D, E, F, G, H, I]) NewBatch ¶
func (m *Map9[A, B, C, D, E, F, G, H, I]) NewBatch(count int, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, rel ...Relation)
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[A, B, C, D, E, F, G, H, I]) NewBatchFn ¶
func (m *Map9[A, B, C, D, E, F, G, H, I]) NewBatchFn(count int, fn func(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I), rel ...Relation)
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[A, B, C, D, E, F, G, H, I]) NewEntity ¶
func (m *Map9[A, B, C, D, E, F, G, H, I]) NewEntity(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I, rel ...Relation) Entity
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[A, B, C, D, E, F, G, H, I]) NewEntityFn ¶
func (m *Map9[A, B, C, D, E, F, G, H, I]) NewEntityFn(fn func(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I), rel ...Relation) Entity
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[A, B, C, D, E, F, G, H, I]) Remove ¶
Remove the mapped components from the given entity.
func (*Map9[A, B, C, D, E, F, G, H, I]) RemoveBatch ¶
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[A, B, C, D, E, F, G, H, I]) Set ¶
func (m *Map9[A, B, C, D, E, F, G, H, I]) Set(entity Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, i *I)
Set the mapped components of the given entity to the given values.
Requires the entity to already have all the mapped components. This is not a component operation, so it can be performed on a locked world.
func (*Map9[A, B, C, D, E, F, G, H, I]) SetRelations ¶
SetRelations sets relation targets for the given entity.
type Query0 ¶
type Query0 struct {
// contains filtered or unexported fields
}
Query0 is a query for 0 components. Use a Filter0 to create one.
Queries are one-time use iterators and must be re-created each time before iterating.
See Query2 for a usage example.
func (*Query0) Close ¶
func (q *Query0) Close()
Close closes the Query and unlocks the world.
Automatically called when iteration completes. Needs to be called only if breaking out of the query iteration or not iterating at all.
func (*Query0) Count ¶
Count counts the entities matching this query.
Has some overhead of iterating through archetypes. However, this is still much faster than manual counting via iteration.
Does not iterate or close the query.
See Query2.Count for an example.
func (*Query0) EntityAt ¶
EntityAt returns the entity at a given index.
The method is particularly useful for random sampling of entities from a query. However, performance depends on the number of archetypes in the world and in the query. In worlds with many archetypes, it is recommended to use a registered/cached filter.
Do not use this to iterate a query! Use Query0.Next instead.
Panics if the index is out of range, as indicated by Query0.Count.
See Query2.EntityAt for an example.
type Query1 ¶
type Query1[A any] struct { // contains filtered or unexported fields }
Query1 is a query for 1 components. Use a Filter1 to create one.
Queries are one-time use iterators and must be re-created each time before iterating.
See Query2 for a usage example.
func (*Query1[A]) Close ¶
func (q *Query1[A]) Close()
Close closes the Query and unlocks the world.
Automatically called when iteration completes. Needs to be called only if breaking out of the query iteration or not iterating at all.
func (*Query1[A]) Count ¶
Count counts the entities matching this query.
Has some overhead of iterating through archetypes. However, this is still much faster than manual counting via iteration.
Does not iterate or close the query.
See Query2.Count for an example.
func (*Query1[A]) EntityAt ¶
EntityAt returns the entity at a given index.
The method is particularly useful for random sampling of entities from a query. However, performance depends on the number of archetypes in the world and in the query. In worlds with many archetypes, it is recommended to use a registered/cached filter.
Do not use this to iterate a query! Use Query1.Next instead.
Panics if the index is out of range, as indicated by Query1.Count.
See Query2.EntityAt for an example.
func (*Query1[A]) Get ¶
func (q *Query1[A]) Get() *A
Get returns the queried components of the current entity.
⚠️ Do not store the obtained pointers outside of the current context (i.e. the query loop)!
func (*Query1[A]) GetRelation ¶
GetRelation returns the entity relation target of the component at the given index.
type Query2 ¶
Query2 is a query for 2 components. Use a Filter2 to create one.
Queries are one-time use iterators and must be re-created each time before iterating.
Example ¶
world := ecs.NewWorld()
// A simple filter.
filter := ecs.NewFilter2[Position, Velocity](&world)
// Create a fresh query before iterating.
query := filter.Query()
for query.Next() {
// Access components of the current entity.
pos, vel := query.Get()
// Access the current entity itself.
entity := query.Entity()
// ...
_, _, _ = pos, vel, entity
}
func (*Query2[A, B]) Close ¶
func (q *Query2[A, B]) Close()
Close closes the Query and unlocks the world.
Automatically called when iteration completes. Needs to be called only if breaking out of the query iteration or not iterating at all.
func (*Query2[A, B]) Count ¶
Count counts the entities matching this query.
Has some overhead of iterating through archetypes. However, this is still much faster than manual counting via iteration.
Does not iterate or close the query.
Example ¶
world := ecs.NewWorld() // Create a filter. filter := ecs.NewFilter2[Position, Velocity](&world) // Query the filter query := filter.Query() // Get the number of entities matching the query count := query.Count() // Close the query // This is required if the query is not iterated query.Close() _ = count
func (*Query2[A, B]) EntityAt ¶
EntityAt returns the entity at a given index.
The method is particularly useful for random sampling of entities from a query. However, performance depends on the number of archetypes in the world and in the query. In worlds with many archetypes, it is recommended to use a registered/cached filter.
Do not use this to iterate a query! Use Query2.Next instead.
Panics if the index is out of range, as indicated by Query2.Count.
Example ¶
world := ecs.NewWorld() // Create a filter. filter := ecs.NewFilter2[Position, Velocity](&world) // Query the filter query := filter.Query() // Get the number of entities matching the query count := query.Count() // Get random entities from the query e1 := query.EntityAt(rand.IntN(count)) e2 := query.EntityAt(rand.IntN(count)) e3 := query.EntityAt(rand.IntN(count)) // Close the query // This is required if the query is not iterated query.Close() _, _, _ = e1, e2, e3
func (*Query2[A, B]) Get ¶
func (q *Query2[A, B]) Get() (*A, *B)
Get returns the queried components of the current entity.
⚠️ Do not store the obtained pointers outside of the current context (i.e. the query loop)!
func (*Query2[A, B]) GetRelation ¶
GetRelation returns the entity relation target of the component at the given index.
type Query3 ¶
Query3 is a query for 3 components. Use a Filter3 to create one.
Queries are one-time use iterators and must be re-created each time before iterating.
See Query2 for a usage example.
func (*Query3[A, B, C]) Close ¶
func (q *Query3[A, B, C]) Close()
Close closes the Query and unlocks the world.
Automatically called when iteration completes. Needs to be called only if breaking out of the query iteration or not iterating at all.
func (*Query3[A, B, C]) Count ¶
Count counts the entities matching this query.
Has some overhead of iterating through archetypes. However, this is still much faster than manual counting via iteration.
Does not iterate or close the query.
See Query2.Count for an example.
func (*Query3[A, B, C]) EntityAt ¶
EntityAt returns the entity at a given index.
The method is particularly useful for random sampling of entities from a query. However, performance depends on the number of archetypes in the world and in the query. In worlds with many archetypes, it is recommended to use a registered/cached filter.
Do not use this to iterate a query! Use Query3.Next instead.
Panics if the index is out of range, as indicated by Query3.Count.
See Query2.EntityAt for an example.
func (*Query3[A, B, C]) Get ¶
func (q *Query3[A, B, C]) Get() (*A, *B, *C)
Get returns the queried components of the current entity.
⚠️ Do not store the obtained pointers outside of the current context (i.e. the query loop)!
func (*Query3[A, B, C]) GetRelation ¶
GetRelation returns the entity relation target of the component at the given index.
type Query4 ¶
Query4 is a query for 4 components. Use a Filter4 to create one.
Queries are one-time use iterators and must be re-created each time before iterating.
See Query2 for a usage example.
func (*Query4[A, B, C, D]) Close ¶
func (q *Query4[A, B, C, D]) Close()
Close closes the Query and unlocks the world.
Automatically called when iteration completes. Needs to be called only if breaking out of the query iteration or not iterating at all.
func (*Query4[A, B, C, D]) Count ¶
Count counts the entities matching this query.
Has some overhead of iterating through archetypes. However, this is still much faster than manual counting via iteration.
Does not iterate or close the query.
See Query2.Count for an example.
func (*Query4[A, B, C, D]) EntityAt ¶
EntityAt returns the entity at a given index.
The method is particularly useful for random sampling of entities from a query. However, performance depends on the number of archetypes in the world and in the query. In worlds with many archetypes, it is recommended to use a registered/cached filter.
Do not use this to iterate a query! Use Query4.Next instead.
Panics if the index is out of range, as indicated by Query4.Count.
See Query2.EntityAt for an example.
func (*Query4[A, B, C, D]) Get ¶
func (q *Query4[A, B, C, D]) Get() (*A, *B, *C, *D)
Get returns the queried components of the current entity.
⚠️ Do not store the obtained pointers outside of the current context (i.e. the query loop)!
func (*Query4[A, B, C, D]) GetRelation ¶
GetRelation returns the entity relation target of the component at the given index.
type Query5 ¶
Query5 is a query for 5 components. Use a Filter5 to create one.
Queries are one-time use iterators and must be re-created each time before iterating.
See Query2 for a usage example.
func (*Query5[A, B, C, D, E]) Close ¶
func (q *Query5[A, B, C, D, E]) Close()
Close closes the Query and unlocks the world.
Automatically called when iteration completes. Needs to be called only if breaking out of the query iteration or not iterating at all.
func (*Query5[A, B, C, D, E]) Count ¶
Count counts the entities matching this query.
Has some overhead of iterating through archetypes. However, this is still much faster than manual counting via iteration.
Does not iterate or close the query.
See Query2.Count for an example.
func (*Query5[A, B, C, D, E]) EntityAt ¶
EntityAt returns the entity at a given index.
The method is particularly useful for random sampling of entities from a query. However, performance depends on the number of archetypes in the world and in the query. In worlds with many archetypes, it is recommended to use a registered/cached filter.
Do not use this to iterate a query! Use Query5.Next instead.
Panics if the index is out of range, as indicated by Query5.Count.
See Query2.EntityAt for an example.
func (*Query5[A, B, C, D, E]) Get ¶
func (q *Query5[A, B, C, D, E]) Get() (*A, *B, *C, *D, *E)
Get returns the queried components of the current entity.
⚠️ Do not store the obtained pointers outside of the current context (i.e. the query loop)!
func (*Query5[A, B, C, D, E]) GetRelation ¶
GetRelation returns the entity relation target of the component at the given index.
type Query6 ¶
type Query6[A any, B any, C any, D any, E any, F any] struct { // contains filtered or unexported fields }
Query6 is a query for 6 components. Use a Filter6 to create one.
Queries are one-time use iterators and must be re-created each time before iterating.
See Query2 for a usage example.
func (*Query6[A, B, C, D, E, F]) Close ¶
func (q *Query6[A, B, C, D, E, F]) Close()
Close closes the Query and unlocks the world.
Automatically called when iteration completes. Needs to be called only if breaking out of the query iteration or not iterating at all.
func (*Query6[A, B, C, D, E, F]) Count ¶
Count counts the entities matching this query.
Has some overhead of iterating through archetypes. However, this is still much faster than manual counting via iteration.
Does not iterate or close the query.
See Query2.Count for an example.
func (*Query6[A, B, C, D, E, F]) EntityAt ¶
EntityAt returns the entity at a given index.
The method is particularly useful for random sampling of entities from a query. However, performance depends on the number of archetypes in the world and in the query. In worlds with many archetypes, it is recommended to use a registered/cached filter.
Do not use this to iterate a query! Use Query6.Next instead.
Panics if the index is out of range, as indicated by Query6.Count.
See Query2.EntityAt for an example.
func (*Query6[A, B, C, D, E, F]) Get ¶
func (q *Query6[A, B, C, D, E, F]) Get() (*A, *B, *C, *D, *E, *F)
Get returns the queried components of the current entity.
⚠️ Do not store the obtained pointers outside of the current context (i.e. the query loop)!
func (*Query6[A, B, C, D, E, F]) GetRelation ¶
GetRelation returns the entity relation target of the component at the given index.
type Query7 ¶
type Query7[A any, B any, C any, D any, E any, F any, G any] struct { // contains filtered or unexported fields }
Query7 is a query for 7 components. Use a Filter7 to create one.
Queries are one-time use iterators and must be re-created each time before iterating.
See Query2 for a usage example.
func (*Query7[A, B, C, D, E, F, G]) Close ¶
func (q *Query7[A, B, C, D, E, F, G]) Close()
Close closes the Query and unlocks the world.
Automatically called when iteration completes. Needs to be called only if breaking out of the query iteration or not iterating at all.
func (*Query7[A, B, C, D, E, F, G]) Count ¶
Count counts the entities matching this query.
Has some overhead of iterating through archetypes. However, this is still much faster than manual counting via iteration.
Does not iterate or close the query.
See Query2.Count for an example.
func (*Query7[A, B, C, D, E, F, G]) EntityAt ¶
EntityAt returns the entity at a given index.
The method is particularly useful for random sampling of entities from a query. However, performance depends on the number of archetypes in the world and in the query. In worlds with many archetypes, it is recommended to use a registered/cached filter.
Do not use this to iterate a query! Use Query7.Next instead.
Panics if the index is out of range, as indicated by Query7.Count.
See Query2.EntityAt for an example.
func (*Query7[A, B, C, D, E, F, G]) Get ¶
func (q *Query7[A, B, C, D, E, F, G]) Get() (*A, *B, *C, *D, *E, *F, *G)
Get returns the queried components of the current entity.
⚠️ Do not store the obtained pointers outside of the current context (i.e. the query loop)!
func (*Query7[A, B, C, D, E, F, G]) GetRelation ¶
GetRelation returns the entity relation target of the component at the given index.
type Query8 ¶
type Query8[A any, B any, C any, D any, E any, F any, G any, H any] struct { // contains filtered or unexported fields }
Query8 is a query for 8 components. Use a Filter8 to create one.
Queries are one-time use iterators and must be re-created each time before iterating.
See Query2 for a usage example.
func (*Query8[A, B, C, D, E, F, G, H]) Close ¶
func (q *Query8[A, B, C, D, E, F, G, H]) Close()
Close closes the Query and unlocks the world.
Automatically called when iteration completes. Needs to be called only if breaking out of the query iteration or not iterating at all.
func (*Query8[A, B, C, D, E, F, G, H]) Count ¶
Count counts the entities matching this query.
Has some overhead of iterating through archetypes. However, this is still much faster than manual counting via iteration.
Does not iterate or close the query.
See Query2.Count for an example.
func (*Query8[A, B, C, D, E, F, G, H]) EntityAt ¶
EntityAt returns the entity at a given index.
The method is particularly useful for random sampling of entities from a query. However, performance depends on the number of archetypes in the world and in the query. In worlds with many archetypes, it is recommended to use a registered/cached filter.
Do not use this to iterate a query! Use Query8.Next instead.
Panics if the index is out of range, as indicated by Query8.Count.
See Query2.EntityAt for an example.
func (*Query8[A, B, C, D, E, F, G, H]) Get ¶
func (q *Query8[A, B, C, D, E, F, G, H]) Get() (*A, *B, *C, *D, *E, *F, *G, *H)
Get returns the queried components of the current entity.
⚠️ Do not store the obtained pointers outside of the current context (i.e. the query loop)!
func (*Query8[A, B, C, D, E, F, G, H]) GetRelation ¶
GetRelation returns the entity relation target of the component at the given index.
type Relation ¶
type Relation struct {
// contains filtered or unexported fields
}
Relation is the common type for specifying relationship targets. It can be created with Rel, RelIdx and RelID.
- Rel is safe, but has some run-time overhead for component ID lookup.
- RelIdx is fast but more error-prone.
- RelID is used in the Unsafe API.
func Rel ¶
Rel creates a new Relation for a component type.
It can be used as a safer but slower alternative to RelIdx. Required a component ID lookup when used the first time. Un reuse, it is as fast as RelIdx.
Example ¶
world := ecs.NewWorld()
// Create relation targets / parents
parent1 := world.NewEntity()
parent2 := world.NewEntity()
// Create a component mapper.
mapper := ecs.NewMap2[Position, ChildOf](&world)
// Create an entity, setting a relation target.
entity := mapper.NewEntity(&Position{}, &ChildOf{}, ecs.Rel[ChildOf](parent1))
// Change the entity's relation target.
mapper.SetRelations(entity, ecs.Rel[ChildOf](parent2))
func RelID ¶
RelID creates a new Relation for a component ID.
It is used in Ark's unsafe, ID-based API.
func RelIdx ¶
RelIdx creates a new Relation for a component index.
It can be used as faster but less safe alternative to Rel.
Note that the index refers to the position of the component in the generics of e.g. a Map2 or Filter2. This should not be confused with component ID as obtained by ComponentID! For component IDs, use [RelationID].
Example ¶
world := ecs.NewWorld()
// Create relation targets / parents
parent1 := world.NewEntity()
parent2 := world.NewEntity()
// Create a component mapper.
mapper := ecs.NewMap2[Position, ChildOf](&world)
// Create an entity, setting a relation target.
entity := mapper.NewEntity(&Position{}, &ChildOf{}, ecs.RelIdx(1, parent1))
// Change the entity's relation target.
mapper.SetRelations(entity, ecs.RelIdx(1, parent2))
type RelationMarker ¶
type RelationMarker struct{}
RelationMarker is a marker for entity relation components. It must be embedded as first field of a component that represent an entity relationship (see the example).
Entity relations allow for fast queries using entity relationships. E.g. to iterate over all entities that are the child of a certain parent entity.
Example ¶
package main
import (
"fmt"
"github.com/mlange-42/ark/ecs"
)
// ChildOf demonstrates how to define a relation component.
// There may be more fields _after_ the embed.
type ChildOf struct {
ecs.RelationMarker
}
func main() {
world := ecs.NewWorld()
// Create a targets/parents entity for the relation.
parent1 := world.NewEntity()
parent2 := world.NewEntity()
// Create a mapper for one or more components.
mapper := ecs.NewMap1[ChildOf](&world)
// Create a child entity with a relation to a parent.
child1 := mapper.NewEntity(&ChildOf{}, ecs.RelIdx(0, parent1))
// Create another child entity with a relation to a parent.
// This version is slower than the above variant, but safer.
_ = mapper.NewEntity(&ChildOf{}, ecs.Rel[ChildOf](parent2))
// Set the relation target.
mapper.SetRelations(child1, ecs.RelIdx(0, parent2))
// Filter for the relation with a given target.
filter := ecs.NewFilter1[ChildOf](&world)
query := filter.Query(ecs.RelIdx(0, parent2))
for query.Next() {
fmt.Println(
query.Entity(),
query.GetRelation(0), // Get the relation target in a query
)
}
}
Output: {5 0} {3 0} {4 0} {3 0}
type ResID ¶
type ResID struct {
// contains filtered or unexported fields
}
ResID is the resource identifier. It is not relevant when using the default generic API.
func AddResource ¶
AddResource adds a resource to the world. Returns the ID for the added resource.
Panics if there is already such a resource.
Uses reflection. For more efficiency when used repeatedly, use Resource.
The number of resources per World is limited to 256 (64 with build tag ark_tiny).
See also GetResource.
Example ¶
world := ecs.NewWorld() gridResource := NewGrid(100, 100) ecs.AddResource(&world, &gridResource)
func ResourceID ¶
ResourceID returns the ResID for a resource type via generics. Registers the type if it is not already registered.
The number of resources per World is limited to 256 (64 with build tag ark_tiny).
func ResourceIDs ¶
ResourceIDs returns a list of all registered resource IDs.
func ResourceTypeID ¶
ResourceTypeID returns the ResID for a resource type. Registers the type if it is not already registered.
See ResourceID for a more commonly used generic variant.
type Resource ¶
type Resource[T any] struct { // contains filtered or unexported fields }
Resource provides access to a world resource.
Create one with NewResource.
Example ¶
// Create a world. world := ecs.NewWorld() // Create a resource. gridResource := NewGrid(100, 100) // Add it to the world. ecs.AddResource(&world, &gridResource) // Resource access in systems. // Create and store a resource accessor. gridAccess := ecs.NewResource[Grid](&world) // Use the resource. grid := gridAccess.Get() entity := grid.Get(13, 42) _ = entity
func NewResource ¶
NewResource creates a new Resource mapper for a resource type. This does not add a resource to the world, but only creates a mapper for resource access!
See also World.Resources.
func (*Resource[T]) Add ¶
func (g *Resource[T]) Add(res *T)
Add adds a resource to the world.
Panics if there is already a resource of the given type.
func (*Resource[T]) Get ¶
func (g *Resource[T]) Get() *T
Get gets the resource of the given type.
Returns nil if there is no such resource.
func (*Resource[T]) Remove ¶
func (g *Resource[T]) Remove()
Remove removes a resource from the world.
Panics if there is no resource of the given type.
See also ecs.Resources.Remove.
type Resources ¶
type Resources struct {
// contains filtered or unexported fields
}
Resources manage a world's resources. Access it using World.Resources.
Although this type provides an ID-based API, the recommended usage is via Resource.
func (*Resources) Add ¶
Add a resource to the world. The resource should always be a pointer.
Panics if there is already a resource of the given type.
See Resource.Add for the recommended type-safe way.
func (*Resources) Get ¶
Get returns a pointer to the resource of the given type.
Returns nil if there is no such resource.
See Resource.Get for the recommended type-safe way.
func (*Resources) Has ¶
Has returns whether the world has the given resource.
See Resource.Has for the recommended type-safe way.
func (*Resources) Remove ¶
Remove a resource from the world.
Panics if there is no resource of the given type.
See Resource.Remove for the recommended type-safe way.
type Unsafe ¶
type Unsafe struct {
// contains filtered or unexported fields
}
Unsafe provides access to Ark's unsafe ID-based API. Get an instance via World.Unsafe.
The unsafe API is significantly slower than the type-safe API, and should only be used when component types are not known at compile time.
func (Unsafe) DumpEntities ¶
func (u Unsafe) DumpEntities() EntityDump
DumpEntities dumps entity information into an EntityDump object. This dump can be used with Unsafe.LoadEntities to set the World's entity state.
For world serialization with components and resources, see module github.com/mlange-42/ark-serde.
func (Unsafe) Get ¶
Get returns a pointer to the given component of an Entity.
⚠️ Do not store the obtained pointer outside of the current context!
Panics if the entity does not have the given component. Panics when called for a removed (and potentially recycled) entity.
func (Unsafe) GetRelation ¶
GetRelation returns the relation target for the entity and the mapped component.
func (Unsafe) GetRelationUnchecked ¶
GetRelationUnchecked returns the relation target for the entity and the mapped component. In contrast to Unsafe.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 (Unsafe) GetUnchecked ¶
GetUnchecked returns a pointer to the given component of an Entity. In contrast to Unsafe.Get, it does not check whether the entity is alive.
⚠️ Do not store the obtained pointer outside of the current context!
Panics if the entity does not have the given component.
func (Unsafe) Has ¶
Has returns whether an Entity has the given component.
Panics when called for a removed (and potentially recycled) entity.
func (Unsafe) HasUnchecked ¶
HasUnchecked returns whether an Entity has the given component. In contrast to Unsafe.Has, it does not check whether the entity is alive.
Panics when called for a removed (and potentially recycled) entity.
func (Unsafe) LoadEntities ¶
func (u Unsafe) LoadEntities(data *EntityDump)
LoadEntities resets all entities to the state saved with Unsafe.DumpEntities.
Use this only on an empty world! Can be used after World.Reset.
The resulting world will have the same entities (in terms of ID, generation and alive state) as the original world. This is necessary for proper serialization of entity relations. However, the entities will not have any components.
Panics if the world has any dead or alive entities.
For world serialization with components and resources, see module github.com/mlange-42/ark-serde.
func (Unsafe) NewEntityRel ¶
NewEntityRel creates a new entity with the given components and relation targets.
func (Unsafe) SetRelations ¶
SetRelations sets relation targets for an entity.
type UnsafeFilter ¶
type UnsafeFilter struct {
// contains filtered or unexported fields
}
UnsafeFilter is a filter for components.
It is significantly slower than type-safe generic filters like Filter2, and should only be used when component types are not known at compile time.
func NewUnsafeFilter ¶
func NewUnsafeFilter(world *World, ids ...ID) UnsafeFilter
NewUnsafeFilter creates a new UnsafeFilter matching the given components.
func (UnsafeFilter) Exclusive ¶
func (f UnsafeFilter) Exclusive() UnsafeFilter
Exclusive makes the filter exclusive in the sense that the component composition is matched exactly, and no other components are allowed.
func (UnsafeFilter) Query ¶
func (f UnsafeFilter) Query(relations ...Relation) UnsafeQuery
Query returns a new query matching this filter and the given entity relation targets.
func (UnsafeFilter) Without ¶
func (f UnsafeFilter) Without(ids ...ID) UnsafeFilter
Without specifies components to exclude. Resets previous excludes.
type UnsafeQuery ¶
type UnsafeQuery struct {
// contains filtered or unexported fields
}
UnsafeQuery is an unsafe query. It is significantly slower than type-safe generic queries like Query2, and should only be used when component types are not known at compile time.
func (*UnsafeQuery) Close ¶
func (q *UnsafeQuery) Close()
Close closes the Query and unlocks the world.
Automatically called when iteration completes. Needs to be called only if breaking out of the query iteration or not iterating at all.
func (*UnsafeQuery) Count ¶
func (q *UnsafeQuery) Count() int
Count returns the number of entities matching this query.
func (*UnsafeQuery) Entity ¶
func (q *UnsafeQuery) Entity() Entity
Entity returns the current entity.
func (*UnsafeQuery) EntityAt ¶
func (q *UnsafeQuery) EntityAt(index int) Entity
EntityAt returns the entity at a given index.
The method is particularly useful for random sampling of entities from a query. However, performance depends on the number of archetypes in the world and in the query. In worlds with many archetypes, it is recommended to use a registered/cached filter.
Do not use this to iterate a query! Use [Query.Next] instead.
Panics if the index is out of range, as indicated by [Query.Count].
func (*UnsafeQuery) Get ¶
func (q *UnsafeQuery) Get(comp ID) unsafe.Pointer
Get returns the queried components of the current entity.
⚠️ Do not store the obtained pointer outside of the current context (i.e. the query loop)!
func (*UnsafeQuery) GetRelation ¶
func (q *UnsafeQuery) GetRelation(comp ID) Entity
GetRelation returns the entity relation target of the component at the given index.
func (*UnsafeQuery) Has ¶
func (q *UnsafeQuery) Has(comp ID) bool
Has returns whether the current entity has the given component.
func (*UnsafeQuery) IDs ¶
func (q *UnsafeQuery) IDs() IDs
IDs returns the IDs of all component of the current [Entity]n.
func (*UnsafeQuery) Next ¶
func (q *UnsafeQuery) Next() bool
Next advances the query's cursor to the next entity.
type World ¶
type World struct {
// contains filtered or unexported fields
}
World is the central type holding entity and component data, as well as resources.
func NewWorld ¶
NewWorld creates a new World.
Accepts zero, one or two arguments. The first argument is the initial capacity of the world, and of normal archetypes. The second argument is the initial capacity of relation archetypes. If only one argument is provided, it is used for both capacities. If no arguments are provided, the defaults are 1024 and 128, respectively.
func (*World) Alive ¶
Alive return whether the given entity is alive.
In Ark, entities are returned to a pool when they are removed from the world. These entities can be recycled, with the same ID (Entity.ID), but an incremented generation (Entity.Gen). This allows to determine whether an entity held by the user is still alive, despite it was potentially recycled.
func (*World) NewEntities ¶
NewEntities creates a batch of new entities without any components, running the given callback function on each. The callback function can be nil.
func (*World) RemoveEntities ¶
RemoveEntities removes all entities matching the given batch filter, running the given function on each. The function can be nil.
func (*World) RemoveEntity ¶
RemoveEntity removes the given entity from the world.
func (*World) Reset ¶
func (w *World) Reset()
Reset removes all entities and resources from the world, and clears the filter cache.
Does NOT free reserved memory, remove archetypes, or clear the registry. However, it removes archetypes with a relation component.
Can be used to run systematic simulations without the need to re-allocate memory for each run. Accelerates re-populating the world by a factor of 2-3.
func (*World) Resources ¶
Resources of the world. Resources are component-like data that is not associated to an entity, but unique to the world.
See also Resource, AddResource and GetResource.
func (*World) Stats ¶
Stats reports statistics for inspecting the World.
The underlying stats.World object is re-used and updated between calls. The returned pointer should thus not be stored for later analysis. Rather, the required data should be extracted immediately.
Source Files
¶
- archetype.go
- cache.go
- checks.go
- checks_nodebug.go
- column.go
- config.go
- constants.go
- doc.go
- entity.go
- exchange_gen.go
- filter.go
- filter_gen.go
- functions.go
- graph.go
- id_map.go
- lock.go
- map.go
- maps_func.go
- maps_gen.go
- mask256.go
- mask64.go
- mask_notiny.go
- pool.go
- query.go
- query_count.go
- query_gen.go
- query_nodebug.go
- query_nodebug_gen.go
- registry.go
- relation.go
- resource.go
- resources.go
- storage.go
- table.go
- types.go
- unsafe.go
- util.go
- world.go
- world_internal.go
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
generate
command
Package generate contains code generation for queries and maps with a different number of generic parameters.
|
Package generate contains code generation for queries and maps with a different number of generic parameters. |
|
Package stats provides the structs returned by ecs.World.Stats().
|
Package stats provides the structs returned by ecs.World.Stats(). |