Documentation ¶
Overview ¶
Package generic contains Arche's generic API.
See the top level module github.com/mlange-42/arche for an overview.
Outline ¶
- Filter0, Filter1, etc. provide generic filters and query generation using Filter0.Query and friends.
- Query0, Query1, provide the usual ecs.Query functionality, as well as generic Query1.Get, Query1.Relation, etc.
- Map provides generic access to a single component using world access, like Map.Get and Map.Set.
- Map1, Map2, etc. provide generic access to multiple components using world access, like Map1.Get, Map1.Add, Map1.Remove, etc.
- Resource provides generic access to a resource from ecs.Resources.
Index ¶
- type Comp
- func T[A any]() Comp
- func T1[A any]() []Comp
- func T2[A any, B any]() []Comp
- func T3[A any, B any, C any]() []Comp
- func T4[A any, B any, C any, D any]() []Comp
- func T5[A any, B any, C any, D any, E any]() []Comp
- func T6[A any, B any, C any, D any, E any, F any]() []Comp
- func T7[A any, B any, C any, D any, E any, F any, G any]() []Comp
- func T8[A any, B any, C any, D any, E any, F any, G any, H any]() []Comp
- type Exchange
- type Filter0
- func (q *Filter0) Query(w *ecs.World, target ...ecs.Entity) Query0
- func (q *Filter0) Register(w *ecs.World)
- func (q *Filter0) Unregister(w *ecs.World)
- func (q *Filter0) With(mask ...Comp) *Filter0
- func (q *Filter0) WithRelation(comp Comp, target ...ecs.Entity) *Filter0
- func (q *Filter0) Without(mask ...Comp) *Filter0
- type Filter1
- func (q *Filter1[A]) Optional(mask ...Comp) *Filter1[A]
- func (q *Filter1[A]) Query(w *ecs.World, target ...ecs.Entity) Query1[A]
- func (q *Filter1[A]) Register(w *ecs.World)
- func (q *Filter1[A]) Unregister(w *ecs.World)
- func (q *Filter1[A]) With(mask ...Comp) *Filter1[A]
- func (q *Filter1[A]) WithRelation(comp Comp, target ...ecs.Entity) *Filter1[A]
- func (q *Filter1[A]) Without(mask ...Comp) *Filter1[A]
- type Filter2
- func (q *Filter2[A, B]) Optional(mask ...Comp) *Filter2[A, B]
- func (q *Filter2[A, B]) Query(w *ecs.World, target ...ecs.Entity) Query2[A, B]
- func (q *Filter2[A, B]) Register(w *ecs.World)
- func (q *Filter2[A, B]) Unregister(w *ecs.World)
- func (q *Filter2[A, B]) With(mask ...Comp) *Filter2[A, B]
- func (q *Filter2[A, B]) WithRelation(comp Comp, target ...ecs.Entity) *Filter2[A, B]
- func (q *Filter2[A, B]) Without(mask ...Comp) *Filter2[A, B]
- type Filter3
- func (q *Filter3[A, B, C]) Optional(mask ...Comp) *Filter3[A, B, C]
- func (q *Filter3[A, B, C]) Query(w *ecs.World, target ...ecs.Entity) Query3[A, B, C]
- func (q *Filter3[A, B, C]) Register(w *ecs.World)
- func (q *Filter3[A, B, C]) Unregister(w *ecs.World)
- func (q *Filter3[A, B, C]) With(mask ...Comp) *Filter3[A, B, C]
- func (q *Filter3[A, B, C]) WithRelation(comp Comp, target ...ecs.Entity) *Filter3[A, B, C]
- func (q *Filter3[A, B, C]) Without(mask ...Comp) *Filter3[A, B, C]
- type Filter4
- func (q *Filter4[A, B, C, D]) Optional(mask ...Comp) *Filter4[A, B, C, D]
- func (q *Filter4[A, B, C, D]) Query(w *ecs.World, target ...ecs.Entity) Query4[A, B, C, D]
- func (q *Filter4[A, B, C, D]) Register(w *ecs.World)
- func (q *Filter4[A, B, C, D]) Unregister(w *ecs.World)
- func (q *Filter4[A, B, C, D]) With(mask ...Comp) *Filter4[A, B, C, D]
- func (q *Filter4[A, B, C, D]) WithRelation(comp Comp, target ...ecs.Entity) *Filter4[A, B, C, D]
- func (q *Filter4[A, B, C, D]) Without(mask ...Comp) *Filter4[A, B, C, D]
- type Filter5
- func (q *Filter5[A, B, C, D, E]) Optional(mask ...Comp) *Filter5[A, B, C, D, E]
- func (q *Filter5[A, B, C, D, E]) Query(w *ecs.World, target ...ecs.Entity) Query5[A, B, C, D, E]
- func (q *Filter5[A, B, C, D, E]) Register(w *ecs.World)
- func (q *Filter5[A, B, C, D, E]) Unregister(w *ecs.World)
- func (q *Filter5[A, B, C, D, E]) With(mask ...Comp) *Filter5[A, B, C, D, E]
- func (q *Filter5[A, B, C, D, E]) WithRelation(comp Comp, target ...ecs.Entity) *Filter5[A, B, C, D, E]
- func (q *Filter5[A, B, C, D, E]) Without(mask ...Comp) *Filter5[A, B, C, D, E]
- type Filter6
- func (q *Filter6[A, B, C, D, E, F]) Optional(mask ...Comp) *Filter6[A, B, C, D, E, F]
- func (q *Filter6[A, B, C, D, E, F]) Query(w *ecs.World, target ...ecs.Entity) Query6[A, B, C, D, E, F]
- func (q *Filter6[A, B, C, D, E, F]) Register(w *ecs.World)
- func (q *Filter6[A, B, C, D, E, F]) Unregister(w *ecs.World)
- func (q *Filter6[A, B, C, D, E, F]) With(mask ...Comp) *Filter6[A, B, C, D, E, F]
- func (q *Filter6[A, B, C, D, E, F]) WithRelation(comp Comp, target ...ecs.Entity) *Filter6[A, B, C, D, E, F]
- func (q *Filter6[A, B, C, D, E, F]) Without(mask ...Comp) *Filter6[A, B, C, D, E, F]
- type Filter7
- func (q *Filter7[A, B, C, D, E, F, G]) Optional(mask ...Comp) *Filter7[A, B, C, D, E, F, G]
- func (q *Filter7[A, B, C, D, E, F, G]) Query(w *ecs.World, target ...ecs.Entity) Query7[A, B, C, D, E, F, G]
- func (q *Filter7[A, B, C, D, E, F, G]) Register(w *ecs.World)
- func (q *Filter7[A, B, C, D, E, F, G]) Unregister(w *ecs.World)
- func (q *Filter7[A, B, C, D, E, F, G]) With(mask ...Comp) *Filter7[A, B, C, D, E, F, G]
- func (q *Filter7[A, B, C, D, E, F, G]) WithRelation(comp Comp, target ...ecs.Entity) *Filter7[A, B, C, D, E, F, G]
- func (q *Filter7[A, B, C, D, E, F, G]) Without(mask ...Comp) *Filter7[A, B, C, D, E, F, G]
- type Filter8
- func (q *Filter8[A, B, C, D, E, F, G, H]) Optional(mask ...Comp) *Filter8[A, B, C, D, E, F, G, H]
- func (q *Filter8[A, B, C, D, E, F, G, H]) Query(w *ecs.World, target ...ecs.Entity) Query8[A, B, C, D, E, F, G, H]
- func (q *Filter8[A, B, C, D, E, F, G, H]) Register(w *ecs.World)
- func (q *Filter8[A, B, C, D, E, F, G, H]) Unregister(w *ecs.World)
- func (q *Filter8[A, B, C, D, E, F, G, H]) With(mask ...Comp) *Filter8[A, B, C, D, E, F, G, H]
- func (q *Filter8[A, B, C, D, E, F, G, H]) WithRelation(comp Comp, target ...ecs.Entity) *Filter8[A, B, C, D, E, F, G, H]
- func (q *Filter8[A, B, C, D, E, F, G, H]) Without(mask ...Comp) *Filter8[A, B, C, D, E, F, G, H]
- type Map
- func (g *Map[T]) Get(entity ecs.Entity) *T
- func (g *Map[T]) GetRelation(entity ecs.Entity) ecs.Entity
- func (g *Map[T]) GetRelationUnchecked(entity ecs.Entity) ecs.Entity
- func (g *Map[T]) GetUnchecked(entity ecs.Entity) *T
- func (g *Map[T]) Has(entity ecs.Entity) bool
- func (g *Map[T]) HasUnchecked(entity ecs.Entity) bool
- func (g *Map[T]) ID() ecs.ID
- func (g *Map[T]) Set(entity ecs.Entity, comp *T) *T
- func (g *Map[T]) SetRelation(entity, target ecs.Entity)
- type Map1
- func (m *Map1[A]) Add(entity ecs.Entity)
- func (m *Map1[A]) Assign(entity ecs.Entity, a *A)
- func (m *Map1[A]) Get(entity ecs.Entity) *A
- func (m *Map1[A]) GetUnchecked(entity ecs.Entity) *A
- func (m *Map1[A]) New(target ...ecs.Entity) ecs.Entity
- func (m *Map1[A]) NewBatch(count int, target ...ecs.Entity)
- func (m *Map1[A]) NewBatchQ(count int, target ...ecs.Entity) Query1[A]
- func (m *Map1[A]) NewWith(a *A, target ...ecs.Entity) ecs.Entity
- func (m *Map1[A]) Remove(entity ecs.Entity)
- func (m *Map1[A]) RemoveEntities(exclusive bool) int
- type Map2
- func (m *Map2[A, B]) Add(entity ecs.Entity)
- func (m *Map2[A, B]) Assign(entity ecs.Entity, a *A, b *B)
- func (m *Map2[A, B]) Get(entity ecs.Entity) (*A, *B)
- func (m *Map2[A, B]) GetUnchecked(entity ecs.Entity) (*A, *B)
- func (m *Map2[A, B]) New(target ...ecs.Entity) ecs.Entity
- func (m *Map2[A, B]) NewBatch(count int, target ...ecs.Entity)
- func (m *Map2[A, B]) NewBatchQ(count int, target ...ecs.Entity) Query2[A, B]
- func (m *Map2[A, B]) NewWith(a *A, b *B, target ...ecs.Entity) ecs.Entity
- func (m *Map2[A, B]) Remove(entity ecs.Entity)
- func (m *Map2[A, B]) RemoveEntities(exclusive bool) int
- type Map3
- func (m *Map3[A, B, C]) Add(entity ecs.Entity)
- func (m *Map3[A, B, C]) Assign(entity ecs.Entity, a *A, b *B, c *C)
- func (m *Map3[A, B, C]) Get(entity ecs.Entity) (*A, *B, *C)
- func (m *Map3[A, B, C]) GetUnchecked(entity ecs.Entity) (*A, *B, *C)
- func (m *Map3[A, B, C]) New(target ...ecs.Entity) ecs.Entity
- func (m *Map3[A, B, C]) NewBatch(count int, target ...ecs.Entity)
- func (m *Map3[A, B, C]) NewBatchQ(count int, target ...ecs.Entity) Query3[A, B, C]
- func (m *Map3[A, B, C]) NewWith(a *A, b *B, c *C, target ...ecs.Entity) ecs.Entity
- func (m *Map3[A, B, C]) Remove(entity ecs.Entity)
- func (m *Map3[A, B, C]) RemoveEntities(exclusive bool) int
- type Map4
- func (m *Map4[A, B, C, D]) Add(entity ecs.Entity)
- func (m *Map4[A, B, C, D]) Assign(entity ecs.Entity, a *A, b *B, c *C, d *D)
- func (m *Map4[A, B, C, D]) Get(entity ecs.Entity) (*A, *B, *C, *D)
- func (m *Map4[A, B, C, D]) GetUnchecked(entity ecs.Entity) (*A, *B, *C, *D)
- func (m *Map4[A, B, C, D]) New(target ...ecs.Entity) ecs.Entity
- func (m *Map4[A, B, C, D]) NewBatch(count int, target ...ecs.Entity)
- func (m *Map4[A, B, C, D]) NewBatchQ(count int, target ...ecs.Entity) Query4[A, B, C, D]
- func (m *Map4[A, B, C, D]) NewWith(a *A, b *B, c *C, d *D, target ...ecs.Entity) ecs.Entity
- func (m *Map4[A, B, C, D]) Remove(entity ecs.Entity)
- func (m *Map4[A, B, C, D]) RemoveEntities(exclusive bool) int
- type Map5
- func (m *Map5[A, B, C, D, E]) Add(entity ecs.Entity)
- func (m *Map5[A, B, C, D, E]) Assign(entity ecs.Entity, a *A, b *B, c *C, d *D, e *E)
- func (m *Map5[A, B, C, D, E]) Get(entity ecs.Entity) (*A, *B, *C, *D, *E)
- func (m *Map5[A, B, C, D, E]) GetUnchecked(entity ecs.Entity) (*A, *B, *C, *D, *E)
- func (m *Map5[A, B, C, D, E]) New(target ...ecs.Entity) ecs.Entity
- func (m *Map5[A, B, C, D, E]) NewBatch(count int, target ...ecs.Entity)
- func (m *Map5[A, B, C, D, E]) NewBatchQ(count int, target ...ecs.Entity) Query5[A, B, C, D, E]
- func (m *Map5[A, B, C, D, E]) NewWith(a *A, b *B, c *C, d *D, e *E, target ...ecs.Entity) ecs.Entity
- func (m *Map5[A, B, C, D, E]) Remove(entity ecs.Entity)
- func (m *Map5[A, B, C, D, E]) RemoveEntities(exclusive bool) int
- type Map6
- func (m *Map6[A, B, C, D, E, F]) Add(entity ecs.Entity)
- func (m *Map6[A, B, C, D, E, F]) Assign(entity ecs.Entity, a *A, b *B, c *C, d *D, e *E, f *F)
- func (m *Map6[A, B, C, D, E, F]) Get(entity ecs.Entity) (*A, *B, *C, *D, *E, *F)
- func (m *Map6[A, B, C, D, E, F]) GetUnchecked(entity ecs.Entity) (*A, *B, *C, *D, *E, *F)
- func (m *Map6[A, B, C, D, E, F]) New(target ...ecs.Entity) ecs.Entity
- func (m *Map6[A, B, C, D, E, F]) NewBatch(count int, target ...ecs.Entity)
- func (m *Map6[A, B, C, D, E, F]) NewBatchQ(count int, target ...ecs.Entity) Query6[A, B, C, D, E, F]
- func (m *Map6[A, B, C, D, E, F]) NewWith(a *A, b *B, c *C, d *D, e *E, f *F, target ...ecs.Entity) ecs.Entity
- func (m *Map6[A, B, C, D, E, F]) Remove(entity ecs.Entity)
- func (m *Map6[A, B, C, D, E, F]) RemoveEntities(exclusive bool) int
- type Map7
- func (m *Map7[A, B, C, D, E, F, G]) Add(entity ecs.Entity)
- func (m *Map7[A, B, C, D, E, F, G]) Assign(entity ecs.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]) Get(entity ecs.Entity) (*A, *B, *C, *D, *E, *F, *G)
- func (m *Map7[A, B, C, D, E, F, G]) GetUnchecked(entity ecs.Entity) (*A, *B, *C, *D, *E, *F, *G)
- func (m *Map7[A, B, C, D, E, F, G]) New(target ...ecs.Entity) ecs.Entity
- func (m *Map7[A, B, C, D, E, F, G]) NewBatch(count int, target ...ecs.Entity)
- func (m *Map7[A, B, C, D, E, F, G]) NewBatchQ(count int, target ...ecs.Entity) Query7[A, B, C, D, E, F, G]
- func (m *Map7[A, B, C, D, E, F, G]) NewWith(a *A, b *B, c *C, d *D, e *E, f *F, g *G, target ...ecs.Entity) ecs.Entity
- func (m *Map7[A, B, C, D, E, F, G]) Remove(entity ecs.Entity)
- func (m *Map7[A, B, C, D, E, F, G]) RemoveEntities(exclusive bool) int
- type Map8
- func (m *Map8[A, B, C, D, E, F, G, H]) Add(entity ecs.Entity)
- func (m *Map8[A, B, C, D, E, F, G, H]) Assign(entity ecs.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]) Get(entity ecs.Entity) (*A, *B, *C, *D, *E, *F, *G, *H)
- func (m *Map8[A, B, C, D, E, F, G, H]) GetUnchecked(entity ecs.Entity) (*A, *B, *C, *D, *E, *F, *G, *H)
- func (m *Map8[A, B, C, D, E, F, G, H]) New(target ...ecs.Entity) ecs.Entity
- func (m *Map8[A, B, C, D, E, F, G, H]) NewBatch(count int, target ...ecs.Entity)
- func (m *Map8[A, B, C, D, E, F, G, H]) NewBatchQ(count int, target ...ecs.Entity) Query8[A, B, C, D, E, F, G, H]
- func (m *Map8[A, B, C, D, E, F, G, H]) NewWith(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, target ...ecs.Entity) ecs.Entity
- func (m *Map8[A, B, C, D, E, F, G, H]) Remove(entity ecs.Entity)
- func (m *Map8[A, B, C, D, E, F, G, H]) RemoveEntities(exclusive bool) int
- type Query0
- type Query1
- type Query2
- type Query3
- type Query4
- type Query5
- type Query6
- type Query7
- type Query8
- type Resource
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comp ¶
Comp is an alias for component types.
type Exchange ¶
type Exchange struct {
// contains filtered or unexported fields
}
Exchange is a helper for adding, removing and exchanging components.
Set it up like this:
ex := NewExchange(&world). Adds(T3[A, B, C]()...). Removes(T2[D, E]()...)
For only adding or removing components, see also Map1, Map2 etc.
func NewExchange ¶
NewExchange creates a new Exchange object.
func (*Exchange) Add ¶
Add the components set via Exchange.Adds to the given entity.
See also ecs.World.Add.
func (*Exchange) Adds ¶
Adds sets components to add in calls to Exchange.Add and Exchange.Exchange.
Create the required mask items with T.
func (*Exchange) Exchange ¶
Exchange components on an entity.
Removes the components set via Exchange.Removes. Adds the components set via Exchange.Adds.
See also ecs.World.Exchange.
func (*Exchange) NewEntity ¶
NewEntity creates a new ecs.Entity with the components set via Exchange.Adds.
See also ecs.World.NewEntity.
func (*Exchange) Remove ¶
Remove the components set via Exchange.Removes from the given entity.
See also ecs.World.Remove.
func (*Exchange) Removes ¶
Removes sets components to remove in calls to Exchange.Remove and Exchange.Exchange.
Create the required mask items with T.
type Filter0 ¶
type Filter0 filter
Filter0 is a helper for building Query0 query iterators.
Example ¶
world := ecs.NewWorld() filter := NewFilter0() query := filter.Query(&world) complexFilter := NewFilter0(). With(T2[V, W]()...). Without(T3[X, Y, Z]()...).
func NewFilter0 ¶
func NewFilter0() *Filter0
NewFilter0 creates a generic Filter0 for zero components.
See also ecs.World.Query.
func (*Filter0) Query ¶
Query builds a Query0 query for iteration, with an optional relation target.
A relation target can't be used:
- if Filter0.WithRelation was not called
- if the target was already set via Filter0.WithRelation
- if the filter is registered for caching
Panics in these cases.
func (*Filter0) Register ¶ added in v0.6.0
Register the filter for caching.
See ecs.Cache for details on filter caching.
func (*Filter0) Unregister ¶ added in v0.6.0
Unregister the filter from caching.
See ecs.Cache for details on filter caching.
func (*Filter0) With ¶
With adds components that are required, but not accessible via [Query0.Get].
Create the required mask items with T.
func (*Filter0) WithRelation ¶ added in v0.8.0
WithRelation sets the filter's ecs.Relation component and optionally restricts the query to entities that have the given relation target.
Use without the optional argument to specify the relation target in Filter0.Query. If the optional argument is provided, the filter's relation target is set permanently.
Create the required component ID with T.
type Filter1 ¶
type Filter1[A any] filter
Filter1 is a helper for building Query1 query iterators.
Example ¶
world := ecs.NewWorld() filter := NewFilter1[A]() query := filter.Query(&world) complexFilter := NewFilter1[A](). Optional(T[A]()). With(T2[V, W]()...). Without(T3[X, Y, Z]()...).
func NewFilter1 ¶
NewFilter1 creates a generic Filter1 for one components.
See also ecs.World.Query.
func (*Filter1[A]) Optional ¶
Optional makes some of the query's components optional.
Create the required mask items with T.
Only affects component types that were specified in the query.
func (*Filter1[A]) Query ¶
Query builds a Query1 query for iteration, with an optional relation target.
A relation target can't be used:
- if Filter1.WithRelation was not called
- if the target was already set via Filter1.WithRelation
- if the filter is registered for caching
Panics in these cases.
func (*Filter1[A]) Register ¶ added in v0.6.0
Register the filter for caching.
See ecs.Cache for details on filter caching.
func (*Filter1[A]) Unregister ¶ added in v0.6.0
Unregister the filter from caching.
See ecs.Cache for details on filter caching.
func (*Filter1[A]) With ¶
With adds components that are required, but not accessible via Query1.Get.
Create the required mask items with T.
func (*Filter1[A]) WithRelation ¶ added in v0.8.0
WithRelation sets the filter's ecs.Relation component and optionally restricts the query to entities that have the given relation target.
Use without the optional argument to specify the relation target in Filter1.Query. If the optional argument is provided, the filter's relation target is set permanently.
Create the required component ID with T.
type Filter2 ¶
Filter2 is a helper for building Query2 query iterators.
Example ¶
world := ecs.NewWorld() filter := NewFilter2[A, B]() query := filter.Query(&world) complexFilter := NewFilter2[A, B](). Optional(T[A]()). With(T2[V, W]()...). Without(T3[X, Y, Z]()...).
func NewFilter2 ¶
NewFilter2 creates a generic Filter2 for two components.
See also ecs.World.Query.
func (*Filter2[A, B]) Optional ¶
Optional makes some of the query's components optional.
Create the required mask items with T.
Only affects component types that were specified in the query.
func (*Filter2[A, B]) Query ¶
Query builds a Query2 query for iteration, with an optional relation target.
A relation target can't be used:
- if Filter2.WithRelation was not called
- if the target was already set via Filter2.WithRelation
- if the filter is registered for caching
Panics in these cases.
func (*Filter2[A, B]) Register ¶ added in v0.6.0
Register the filter for caching.
See ecs.Cache for details on filter caching.
func (*Filter2[A, B]) Unregister ¶ added in v0.6.0
Unregister the filter from caching.
See ecs.Cache for details on filter caching.
func (*Filter2[A, B]) With ¶
With adds components that are required, but not accessible via Query2.Get.
Create the required mask items with T.
func (*Filter2[A, B]) WithRelation ¶ added in v0.8.0
WithRelation sets the filter's ecs.Relation component and optionally restricts the query to entities that have the given relation target.
Use without the optional argument to specify the relation target in Filter2.Query. If the optional argument is provided, the filter's relation target is set permanently.
Create the required component ID with T.
type Filter3 ¶
Filter3 is a helper for building Query3 query iterators.
Example ¶
world := ecs.NewWorld() filter := NewFilter3[A, B, C]() query := filter.Query(&world) complexFilter := NewFilter3[A, B, C](). Optional(T[A]()). With(T2[V, W]()...). Without(T3[X, Y, Z]()...).
func NewFilter3 ¶
NewFilter3 creates a generic Filter3 for three components.
See also ecs.World.Query.
func (*Filter3[A, B, C]) Optional ¶
Optional makes some of the query's components optional.
Create the required mask items with T.
Only affects component types that were specified in the query.
func (*Filter3[A, B, C]) Query ¶
Query builds a Query3 query for iteration, with an optional relation target.
A relation target can't be used:
- if Filter3.WithRelation was not called
- if the target was already set via Filter3.WithRelation
- if the filter is registered for caching
Panics in these cases.
func (*Filter3[A, B, C]) Register ¶ added in v0.6.0
Register the filter for caching.
See ecs.Cache for details on filter caching.
func (*Filter3[A, B, C]) Unregister ¶ added in v0.6.0
Unregister the filter from caching.
See ecs.Cache for details on filter caching.
func (*Filter3[A, B, C]) With ¶
With adds components that are required, but not accessible via Query3.Get.
Create the required mask items with T.
func (*Filter3[A, B, C]) WithRelation ¶ added in v0.8.0
WithRelation sets the filter's ecs.Relation component and optionally restricts the query to entities that have the given relation target.
Use without the optional argument to specify the relation target in Filter3.Query. If the optional argument is provided, the filter's relation target is set permanently.
Create the required component ID with T.
type Filter4 ¶
Filter4 is a helper for building Query4 query iterators.
Example ¶
world := ecs.NewWorld() filter := NewFilter4[A, B, C, D]() query := filter.Query(&world) complexFilter := NewFilter4[A, B, C, D](). Optional(T[A]()). With(T2[V, W]()...). Without(T3[X, Y, Z]()...).
func NewFilter4 ¶
NewFilter4 creates a generic Filter4 for four components.
See also ecs.World.Query.
func (*Filter4[A, B, C, D]) Optional ¶
Optional makes some of the query's components optional.
Create the required mask items with T.
Only affects component types that were specified in the query.
func (*Filter4[A, B, C, D]) Query ¶
Query builds a Query4 query for iteration, with an optional relation target.
A relation target can't be used:
- if Filter4.WithRelation was not called
- if the target was already set via Filter4.WithRelation
- if the filter is registered for caching
Panics in these cases.
func (*Filter4[A, B, C, D]) Register ¶ added in v0.6.0
Register the filter for caching.
See ecs.Cache for details on filter caching.
func (*Filter4[A, B, C, D]) Unregister ¶ added in v0.6.0
Unregister the filter from caching.
See ecs.Cache for details on filter caching.
func (*Filter4[A, B, C, D]) With ¶
With adds components that are required, but not accessible via Query4.Get.
Create the required mask items with T.
func (*Filter4[A, B, C, D]) WithRelation ¶ added in v0.8.0
WithRelation sets the filter's ecs.Relation component and optionally restricts the query to entities that have the given relation target.
Use without the optional argument to specify the relation target in Filter4.Query. If the optional argument is provided, the filter's relation target is set permanently.
Create the required component ID with T.
type Filter5 ¶
Filter5 is a helper for building Query5 query iterators.
Example ¶
world := ecs.NewWorld() filter := NewFilter5[A, B, C, D, E]() query := filter.Query(&world) complexFilter := NewFilter5[A, B, C, D, E](). Optional(T[A]()). With(T2[V, W]()...). Without(T3[X, Y, Z]()...).
func NewFilter5 ¶
NewFilter5 creates a generic Filter5 for five components.
See also ecs.World.Query.
func (*Filter5[A, B, C, D, E]) Optional ¶
Optional makes some of the query's components optional.
Create the required mask items with T.
Only affects component types that were specified in the query.
func (*Filter5[A, B, C, D, E]) Query ¶
Query builds a Query5 query for iteration, with an optional relation target.
A relation target can't be used:
- if Filter5.WithRelation was not called
- if the target was already set via Filter5.WithRelation
- if the filter is registered for caching
Panics in these cases.
func (*Filter5[A, B, C, D, E]) Register ¶ added in v0.6.0
Register the filter for caching.
See ecs.Cache for details on filter caching.
func (*Filter5[A, B, C, D, E]) Unregister ¶ added in v0.6.0
Unregister the filter from caching.
See ecs.Cache for details on filter caching.
func (*Filter5[A, B, C, D, E]) With ¶
With adds components that are required, but not accessible via Query5.Get.
Create the required mask items with T.
func (*Filter5[A, B, C, D, E]) WithRelation ¶ added in v0.8.0
func (q *Filter5[A, B, C, D, E]) WithRelation(comp Comp, target ...ecs.Entity) *Filter5[A, B, C, D, E]
WithRelation sets the filter's ecs.Relation component and optionally restricts the query to entities that have the given relation target.
Use without the optional argument to specify the relation target in Filter5.Query. If the optional argument is provided, the filter's relation target is set permanently.
Create the required component ID with T.
type Filter6 ¶
Filter6 is a helper for building Query6 query iterators.
Example ¶
world := ecs.NewWorld() filter := NewFilter6[A, B, C, D, E, F]() query := filter.Query(&world) complexFilter := NewFilter6[A, B, C, D, E, F](). Optional(T[A]()). With(T2[V, W]()...). Without(T3[X, Y, Z]()...).
func NewFilter6 ¶
NewFilter6 creates a generic Filter6 for six components.
See also ecs.World.Query.
func (*Filter6[A, B, C, D, E, F]) Optional ¶
Optional makes some of the query's components optional.
Create the required mask items with T.
Only affects component types that were specified in the query.
func (*Filter6[A, B, C, D, E, F]) Query ¶
func (q *Filter6[A, B, C, D, E, F]) Query(w *ecs.World, target ...ecs.Entity) Query6[A, B, C, D, E, F]
Query builds a Query6 query for iteration, with an optional relation target.
A relation target can't be used:
- if Filter6.WithRelation was not called
- if the target was already set via Filter6.WithRelation
- if the filter is registered for caching
Panics in these cases.
func (*Filter6[A, B, C, D, E, F]) Register ¶ added in v0.6.0
Register the filter for caching.
See ecs.Cache for details on filter caching.
func (*Filter6[A, B, C, D, E, F]) Unregister ¶ added in v0.6.0
Unregister the filter from caching.
See ecs.Cache for details on filter caching.
func (*Filter6[A, B, C, D, E, F]) With ¶
With adds components that are required, but not accessible via Query6.Get.
Create the required mask items with T.
func (*Filter6[A, B, C, D, E, F]) WithRelation ¶ added in v0.8.0
func (q *Filter6[A, B, C, D, E, F]) WithRelation(comp Comp, target ...ecs.Entity) *Filter6[A, B, C, D, E, F]
WithRelation sets the filter's ecs.Relation component and optionally restricts the query to entities that have the given relation target.
Use without the optional argument to specify the relation target in Filter6.Query. If the optional argument is provided, the filter's relation target is set permanently.
Create the required component ID with T.
type Filter7 ¶
Filter7 is a helper for building Query7 query iterators.
Example ¶
world := ecs.NewWorld() filter := NewFilter7[A, B, C, D, E, F, G]() query := filter.Query(&world) complexFilter := NewFilter7[A, B, C, D, E, F, G](). Optional(T[A]()). With(T2[V, W]()...). Without(T3[X, Y, Z]()...).
func NewFilter7 ¶
NewFilter7 creates a generic Filter7 for seven components.
See also ecs.World.Query.
func (*Filter7[A, B, C, D, E, F, G]) Optional ¶
Optional makes some of the query's components optional.
Create the required mask items with T.
Only affects component types that were specified in the query.
func (*Filter7[A, B, C, D, E, F, G]) Query ¶
func (q *Filter7[A, B, C, D, E, F, G]) Query(w *ecs.World, target ...ecs.Entity) Query7[A, B, C, D, E, F, G]
Query builds a Query7 query for iteration, with an optional relation target.
A relation target can't be used:
- if Filter7.WithRelation was not called
- if the target was already set via Filter7.WithRelation
- if the filter is registered for caching
Panics in these cases.
func (*Filter7[A, B, C, D, E, F, G]) Register ¶ added in v0.6.0
Register the filter for caching.
See ecs.Cache for details on filter caching.
func (*Filter7[A, B, C, D, E, F, G]) Unregister ¶ added in v0.6.0
Unregister the filter from caching.
See ecs.Cache for details on filter caching.
func (*Filter7[A, B, C, D, E, F, G]) With ¶
With adds components that are required, but not accessible via Query7.Get.
Create the required mask items with T.
func (*Filter7[A, B, C, D, E, F, G]) WithRelation ¶ added in v0.8.0
func (q *Filter7[A, B, C, D, E, F, G]) WithRelation(comp Comp, target ...ecs.Entity) *Filter7[A, B, C, D, E, F, G]
WithRelation sets the filter's ecs.Relation component and optionally restricts the query to entities that have the given relation target.
Use without the optional argument to specify the relation target in Filter7.Query. If the optional argument is provided, the filter's relation target is set permanently.
Create the required component ID with T.
type Filter8 ¶
Filter8 is a helper for building Query8 query iterators.
Example ¶
world := ecs.NewWorld() filter := NewFilter8[A, B, C, D, E, F, G, H]() query := filter.Query(&world) complexFilter := NewFilter8[A, B, C, D, E, F, G, H](). Optional(T[A]()). With(T2[V, W]()...). Without(T3[X, Y, Z]()...).
func NewFilter8 ¶
func NewFilter8[A any, B any, C any, D any, E any, F any, G any, H any]() *Filter8[A, B, C, D, E, F, G, H]
NewFilter8 creates a generic Filter8 for eight components.
See also ecs.World.Query.
func (*Filter8[A, B, C, D, E, F, G, H]) Optional ¶
Optional makes some of the query's components optional.
Create the required mask items with T.
Only affects component types that were specified in the query.
func (*Filter8[A, B, C, D, E, F, G, H]) Query ¶
func (q *Filter8[A, B, C, D, E, F, G, H]) Query(w *ecs.World, target ...ecs.Entity) Query8[A, B, C, D, E, F, G, H]
Query builds a Query8 query for iteration, with an optional relation target.
A relation target can't be used:
- if Filter8.WithRelation was not called
- if the target was already set via Filter8.WithRelation
- if the filter is registered for caching
Panics in these cases.
func (*Filter8[A, B, C, D, E, F, G, H]) Register ¶ added in v0.6.0
Register the filter for caching.
See ecs.Cache for details on filter caching.
func (*Filter8[A, B, C, D, E, F, G, H]) Unregister ¶ added in v0.6.0
Unregister the filter from caching.
See ecs.Cache for details on filter caching.
func (*Filter8[A, B, C, D, E, F, G, H]) With ¶
With adds components that are required, but not accessible via Query8.Get.
Create the required mask items with T.
func (*Filter8[A, B, C, D, E, F, G, H]) WithRelation ¶ added in v0.8.0
func (q *Filter8[A, B, C, D, E, F, G, H]) WithRelation(comp Comp, target ...ecs.Entity) *Filter8[A, B, C, D, E, F, G, H]
WithRelation sets the filter's ecs.Relation component and optionally restricts the query to entities that have the given relation target.
Use without the optional argument to specify the relation target in Filter8.Query. If the optional argument is provided, the filter's relation target is set permanently.
Create the required component ID with T.
type Map ¶
type Map[T any] struct { // contains filtered or unexported fields }
Map provides a type-safe way to access a component type by entity ID.
Create one with NewMap.
Example ¶
// Create a world. world := ecs.NewWorld() // Spawn some entities using the generic API. spawner := NewMap2[Position, Velocity](&world) entity := spawner.New() // Create a new Map. mapper := NewMap[Position](&world) // Get the map's component. pos := mapper.Get(entity) pos.X, pos.Y = 10, 5 // Get the map's component, optimized for cases when the entity is guaranteed to be still alive. pos = mapper.GetUnchecked(entity) pos.X, pos.Y = 10, 5
Output:
func NewMap ¶
NewMap creates a new Map for a component type.
Map provides a type-safe way to access a component type by entity ID.
See also ecs.World.Get, ecs.World.Has and ecs.World.Set.
func (*Map[T]) Get ¶
Get gets the component for the given entity.
See Map.HasUnchecked for an optimized version for static entities. See also ecs.World.Get.
func (*Map[T]) GetRelation ¶ added in v0.8.0
GetRelation returns the target entity for the given entity and the Map's relation component.
Panics:
- if the entity does not have a component of that type.
- if the component is not an ecs.Relation.
- if the entity has been removed/recycled.
See also ecs.World.GetRelation.
func (*Map[T]) GetRelationUnchecked ¶ added in v0.8.0
GetRelation returns the target entity for the given entity and the Map's relation component.
Returns the zero entity if the entity does not have the given component, or if the component is not an ecs.Relation.
GetRelationUnchecked is an optimized version of Map.GetRelation. Does not check if the entity is alive or that the component ID is applicable.
See also ecs.World.GetRelationUnchecked.
func (*Map[T]) GetUnchecked ¶ added in v0.7.0
GetUnchecked gets the component for the given entity.
GetUnchecked is an optimized version of Map.Get, for cases where entities are static or checked with ecs.World.Alive in user code.
See also ecs.World.GetUnchecked.
func (*Map[T]) Has ¶
Has returns whether the entity has the component.
See Map.HasUnchecked for an optimized version for static entities. See also ecs.World.Has.
func (*Map[T]) HasUnchecked ¶ added in v0.7.0
HasUnchecked returns whether the entity has the component.
HasUnchecked is an optimized version of Map.Has, for cases where entities are static or checked with ecs.World.Alive in user code.
See also ecs.World.HasUnchecked.
func (*Map[T]) Set ¶
Set overwrites the component for the given entity.
Panics if the entity does not have a component of that type.
See also ecs.World.Set.
func (*Map[T]) SetRelation ¶ added in v0.8.0
SetRelation sets the target entity for the given entity and the Map's relation component.
Panics if the entity does not have a component of that type. Panics if the component is not a relation.
See also ecs.World.SetRelation.
type Map1 ¶
type Map1[A any] struct { // contains filtered or unexported fields }
Map1 is a helper for mapping one components.
Example ¶
world := ecs.NewWorld() mapper := NewMap1[A](&world) entity := mapper.NewEntity() a := mapper.Get(entity)
func NewMap1 ¶
NewMap1 creates a new Map1 object.
The optional argument can be used to set an ecs.Relation component type.
func (*Map1[A]) Assign ¶
Assign the Map1's components to the given entity, using the supplied values.
See also ecs.World.Assign.
func (*Map1[A]) Get ¶
Get all the Map1's components for the given entity.
See Map1.GetUnchecked for an optimized version for static entities. See also ecs.World.Get.
func (*Map1[A]) GetUnchecked ¶ added in v0.7.0
GetUnchecked all the Map1's components for the given entity.
GetUnchecked is an optimized version of Map1.Get, for cases where entities are static or checked with ecs.World.Alive in user code.
See also ecs.World.GetUnchecked.
func (*Map1[A]) New ¶ added in v0.8.0
New creates a new ecs.Entity with the Map1's components.
The optional argument can be used to set the target ecs.Entity for the Map1's ecs.Relation.
See also ecs.World.NewEntity.
func (*Map1[A]) NewBatch ¶ added in v0.8.0
NewBatch creates entities with the Map1's components.
The optional argument can be used to set the target ecs.Entity for the Map1's ecs.Relation.
See also Map1.NewBatchQ and ecs.Batch.NewBatch.
func (*Map1[A]) NewBatchQ ¶ added in v0.8.0
NewBatchQ creates entities with the Map1's components. It returns a Query1 over the new entities.
The optional argument can be used to set the target ecs.Entity for the Map1's ecs.Relation.
Listener notification is delayed until the query is closed of fully iterated.
See also Map1.NewBatch and ecs.Builder.NewBatchQ.
func (*Map1[A]) NewWith ¶ added in v0.8.0
NewWith creates a new ecs.Entity with the Map1's components, using the supplied values.
The optional argument can be used to set the target ecs.Entity for the Map1's ecs.Relation.
See also ecs.NewBuilderWith.
func (*Map1[A]) Remove ¶
Remove the Map1's components from the given entity.
See also ecs.World.Remove.
func (*Map1[A]) RemoveEntities ¶ added in v0.6.0
RemoveEntities removes all entities from the world that match the Map1's components.
The argument determines whether to match the components exactly (i.e. no other components are allowed), or to use a simple filter that does not restrict further components.
Returns the number of removed entities.
See also ecs.World.NewEntityWith.
type Map2 ¶
Map2 is a helper for mapping two components.
Example ¶
world := ecs.NewWorld() mapper := NewMap2[A, B](&world) entity := mapper.NewEntity() a, b := mapper.Get(entity)
func NewMap2 ¶
NewMap2 creates a new Map2 object.
The optional argument can be used to set an ecs.Relation component type.
func (*Map2[A, B]) Assign ¶
Assign the Map2's components to the given entity, using the supplied values.
See also ecs.World.Assign.
func (*Map2[A, B]) Get ¶
Get all the Map2's components for the given entity.
See Map2.GetUnchecked for an optimized version for static entities. See also ecs.World.Get.
func (*Map2[A, B]) GetUnchecked ¶ added in v0.7.0
GetUnchecked all the Map2's components for the given entity.
GetUnchecked is an optimized version of Map2.Get, for cases where entities are static or checked with ecs.World.Alive in user code.
See also ecs.World.GetUnchecked.
func (*Map2[A, B]) New ¶ added in v0.8.0
New creates a new ecs.Entity with the Map2's components.
The optional argument can be used to set the target ecs.Entity for the Map2's ecs.Relation.
See also ecs.World.NewEntity.
func (*Map2[A, B]) NewBatch ¶ added in v0.8.0
NewBatch creates entities with the Map2's components.
The optional argument can be used to set the target ecs.Entity for the Map2's ecs.Relation.
See also Map2.NewBatchQ and ecs.Batch.NewBatch.
func (*Map2[A, B]) NewBatchQ ¶ added in v0.8.0
NewBatchQ creates entities with the Map2's components. It returns a Query2 over the new entities.
The optional argument can be used to set the target ecs.Entity for the Map2's ecs.Relation.
Listener notification is delayed until the query is closed of fully iterated.
See also Map2.NewBatch and ecs.Builder.NewBatchQ.
func (*Map2[A, B]) NewWith ¶ added in v0.8.0
NewWith creates a new ecs.Entity with the Map2's components, using the supplied values.
The optional argument can be used to set the target ecs.Entity for the Map2's ecs.Relation.
See also ecs.NewBuilderWith.
func (*Map2[A, B]) Remove ¶
Remove the Map2's components from the given entity.
See also ecs.World.Remove.
func (*Map2[A, B]) RemoveEntities ¶ added in v0.6.0
RemoveEntities removes all entities from the world that match the Map2's components.
The argument determines whether to match the components exactly (i.e. no other components are allowed), or to use a simple filter that does not restrict further components.
Returns the number of removed entities.
See also ecs.World.NewEntityWith.
type Map3 ¶
Map3 is a helper for mapping three components.
Example ¶
world := ecs.NewWorld() mapper := NewMap3[A, B, C](&world) entity := mapper.NewEntity() a, b, c := mapper.Get(entity)
func NewMap3 ¶
NewMap3 creates a new Map3 object.
The optional argument can be used to set an ecs.Relation component type.
func (*Map3[A, B, C]) Assign ¶
Assign the Map3's components to the given entity, using the supplied values.
See also ecs.World.Assign.
func (*Map3[A, B, C]) Get ¶
Get all the Map3's components for the given entity.
See Map3.GetUnchecked for an optimized version for static entities. See also ecs.World.Get.
func (*Map3[A, B, C]) GetUnchecked ¶ added in v0.7.0
GetUnchecked all the Map3's components for the given entity.
GetUnchecked is an optimized version of Map3.Get, for cases where entities are static or checked with ecs.World.Alive in user code.
See also ecs.World.GetUnchecked.
func (*Map3[A, B, C]) New ¶ added in v0.8.0
New creates a new ecs.Entity with the Map3's components.
The optional argument can be used to set the target ecs.Entity for the Map3's ecs.Relation.
See also ecs.World.NewEntity.
func (*Map3[A, B, C]) NewBatch ¶ added in v0.8.0
NewBatch creates entities with the Map3's components.
The optional argument can be used to set the target ecs.Entity for the Map3's ecs.Relation.
See also Map3.NewBatchQ and ecs.Batch.NewBatch.
func (*Map3[A, B, C]) NewBatchQ ¶ added in v0.8.0
NewBatchQ creates entities with the Map3's components. It returns a Query3 over the new entities.
The optional argument can be used to set the target ecs.Entity for the Map3's ecs.Relation.
Listener notification is delayed until the query is closed of fully iterated.
See also Map3.NewBatch and ecs.Builder.NewBatchQ.
func (*Map3[A, B, C]) NewWith ¶ added in v0.8.0
NewWith creates a new ecs.Entity with the Map3's components, using the supplied values.
The optional argument can be used to set the target ecs.Entity for the Map3's ecs.Relation.
See also ecs.NewBuilderWith.
func (*Map3[A, B, C]) Remove ¶
Remove the Map3's components from the given entity.
See also ecs.World.Remove.
func (*Map3[A, B, C]) RemoveEntities ¶ added in v0.6.0
RemoveEntities removes all entities from the world that match the Map3's components.
The argument determines whether to match the components exactly (i.e. no other components are allowed), or to use a simple filter that does not restrict further components.
Returns the number of removed entities.
See also ecs.World.NewEntityWith.
type Map4 ¶
Map4 is a helper for mapping four components.
Example ¶
world := ecs.NewWorld() mapper := NewMap4[A, B, C, D](&world) entity := mapper.NewEntity() a, b, c, d := mapper.Get(entity)
func NewMap4 ¶
NewMap4 creates a new Map4 object.
The optional argument can be used to set an ecs.Relation component type.
func (*Map4[A, B, C, D]) Add ¶
Add the Map4's components to the given entity.
See also ecs.World.Add.
func (*Map4[A, B, C, D]) Assign ¶
Assign the Map4's components to the given entity, using the supplied values.
See also ecs.World.Assign.
func (*Map4[A, B, C, D]) Get ¶
Get all the Map4's components for the given entity.
See Map4.GetUnchecked for an optimized version for static entities. See also ecs.World.Get.
func (*Map4[A, B, C, D]) GetUnchecked ¶ added in v0.7.0
GetUnchecked all the Map4's components for the given entity.
GetUnchecked is an optimized version of Map4.Get, for cases where entities are static or checked with ecs.World.Alive in user code.
See also ecs.World.GetUnchecked.
func (*Map4[A, B, C, D]) New ¶ added in v0.8.0
New creates a new ecs.Entity with the Map4's components.
The optional argument can be used to set the target ecs.Entity for the Map4's ecs.Relation.
See also ecs.World.NewEntity.
func (*Map4[A, B, C, D]) NewBatch ¶ added in v0.8.0
NewBatch creates entities with the Map4's components.
The optional argument can be used to set the target ecs.Entity for the Map4's ecs.Relation.
See also Map4.NewBatchQ and ecs.Batch.NewBatch.
func (*Map4[A, B, C, D]) NewBatchQ ¶ added in v0.8.0
NewBatchQ creates entities with the Map4's components. It returns a Query4 over the new entities.
The optional argument can be used to set the target ecs.Entity for the Map4's ecs.Relation.
Listener notification is delayed until the query is closed of fully iterated.
See also Map4.NewBatch and ecs.Builder.NewBatchQ.
func (*Map4[A, B, C, D]) NewWith ¶ added in v0.8.0
NewWith creates a new ecs.Entity with the Map4's components, using the supplied values.
The optional argument can be used to set the target ecs.Entity for the Map4's ecs.Relation.
See also ecs.NewBuilderWith.
func (*Map4[A, B, C, D]) Remove ¶
Remove the Map4's components from the given entity.
See also ecs.World.Remove.
func (*Map4[A, B, C, D]) RemoveEntities ¶ added in v0.6.0
RemoveEntities removes all entities from the world that match the Map4's components.
The argument determines whether to match the components exactly (i.e. no other components are allowed), or to use a simple filter that does not restrict further components.
Returns the number of removed entities.
See also ecs.World.NewEntityWith.
type Map5 ¶
Map5 is a helper for mapping five components.
Example ¶
world := ecs.NewWorld() mapper := NewMap5[A, B, C, D, E](&world) entity := mapper.NewEntity() a, b, c, d, e := mapper.Get(entity)
func NewMap5 ¶
NewMap5 creates a new Map5 object.
The optional argument can be used to set an ecs.Relation component type.
func (*Map5[A, B, C, D, E]) Add ¶
Add the Map5's components to the given entity.
See also ecs.World.Add.
func (*Map5[A, B, C, D, E]) Assign ¶
Assign the Map5's components to the given entity, using the supplied values.
See also ecs.World.Assign.
func (*Map5[A, B, C, D, E]) Get ¶
Get all the Map5's components for the given entity.
See Map5.GetUnchecked for an optimized version for static entities. See also ecs.World.Get.
func (*Map5[A, B, C, D, E]) GetUnchecked ¶ added in v0.7.0
GetUnchecked all the Map5's components for the given entity.
GetUnchecked is an optimized version of Map5.Get, for cases where entities are static or checked with ecs.World.Alive in user code.
See also ecs.World.GetUnchecked.
func (*Map5[A, B, C, D, E]) New ¶ added in v0.8.0
New creates a new ecs.Entity with the Map5's components.
The optional argument can be used to set the target ecs.Entity for the Map5's ecs.Relation.
See also ecs.World.NewEntity.
func (*Map5[A, B, C, D, E]) NewBatch ¶ added in v0.8.0
NewBatch creates entities with the Map5's components.
The optional argument can be used to set the target ecs.Entity for the Map5's ecs.Relation.
See also Map5.NewBatchQ and ecs.Batch.NewBatch.
func (*Map5[A, B, C, D, E]) NewBatchQ ¶ added in v0.8.0
NewBatchQ creates entities with the Map5's components. It returns a Query5 over the new entities.
The optional argument can be used to set the target ecs.Entity for the Map5's ecs.Relation.
Listener notification is delayed until the query is closed of fully iterated.
See also Map5.NewBatch and ecs.Builder.NewBatchQ.
func (*Map5[A, B, C, D, E]) NewWith ¶ added in v0.8.0
func (m *Map5[A, B, C, D, E]) NewWith(a *A, b *B, c *C, d *D, e *E, target ...ecs.Entity) ecs.Entity
NewWith creates a new ecs.Entity with the Map5's components, using the supplied values.
The optional argument can be used to set the target ecs.Entity for the Map5's ecs.Relation.
See also ecs.NewBuilderWith.
func (*Map5[A, B, C, D, E]) Remove ¶
Remove the Map5's components from the given entity.
See also ecs.World.Remove.
func (*Map5[A, B, C, D, E]) RemoveEntities ¶ added in v0.6.0
RemoveEntities removes all entities from the world that match the Map5's components.
The argument determines whether to match the components exactly (i.e. no other components are allowed), or to use a simple filter that does not restrict further components.
Returns the number of removed entities.
See also ecs.World.NewEntityWith.
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 helper for mapping six components.
Example ¶
world := ecs.NewWorld() mapper := NewMap6[A, B, C, D, E, F](&world) entity := mapper.NewEntity() a, b, c, d, e, f := mapper.Get(entity)
func NewMap6 ¶
func NewMap6[A any, B any, C any, D any, E any, F any](w *ecs.World, relation ...Comp) Map6[A, B, C, D, E, F]
NewMap6 creates a new Map6 object.
The optional argument can be used to set an ecs.Relation component type.
func (*Map6[A, B, C, D, E, F]) Add ¶
Add the Map6's components to the given entity.
See also ecs.World.Add.
func (*Map6[A, B, C, D, E, F]) Assign ¶
Assign the Map6's components to the given entity, using the supplied values.
See also ecs.World.Assign.
func (*Map6[A, B, C, D, E, F]) Get ¶
Get all the Map6's components for the given entity.
See Map6.GetUnchecked for an optimized version for static entities. See also ecs.World.Get.
func (*Map6[A, B, C, D, E, F]) GetUnchecked ¶ added in v0.7.0
GetUnchecked all the Map6's components for the given entity.
GetUnchecked is an optimized version of Map6.Get, for cases where entities are static or checked with ecs.World.Alive in user code.
See also ecs.World.GetUnchecked.
func (*Map6[A, B, C, D, E, F]) New ¶ added in v0.8.0
New creates a new ecs.Entity with the Map6's components.
The optional argument can be used to set the target ecs.Entity for the Map6's ecs.Relation.
See also ecs.World.NewEntity.
func (*Map6[A, B, C, D, E, F]) NewBatch ¶ added in v0.8.0
NewBatch creates entities with the Map6's components.
The optional argument can be used to set the target ecs.Entity for the Map6's ecs.Relation.
See also Map6.NewBatchQ and ecs.Batch.NewBatch.
func (*Map6[A, B, C, D, E, F]) NewBatchQ ¶ added in v0.8.0
func (m *Map6[A, B, C, D, E, F]) NewBatchQ(count int, target ...ecs.Entity) Query6[A, B, C, D, E, F]
NewBatchQ creates entities with the Map6's components. It returns a Query6 over the new entities.
The optional argument can be used to set the target ecs.Entity for the Map6's ecs.Relation.
Listener notification is delayed until the query is closed of fully iterated.
See also Map6.NewBatch and ecs.Builder.NewBatchQ.
func (*Map6[A, B, C, D, E, F]) NewWith ¶ added in v0.8.0
func (m *Map6[A, B, C, D, E, F]) NewWith(a *A, b *B, c *C, d *D, e *E, f *F, target ...ecs.Entity) ecs.Entity
NewWith creates a new ecs.Entity with the Map6's components, using the supplied values.
The optional argument can be used to set the target ecs.Entity for the Map6's ecs.Relation.
See also ecs.NewBuilderWith.
func (*Map6[A, B, C, D, E, F]) Remove ¶
Remove the Map6's components from the given entity.
See also ecs.World.Remove.
func (*Map6[A, B, C, D, E, F]) RemoveEntities ¶ added in v0.6.0
RemoveEntities removes all entities from the world that match the Map6's components.
The argument determines whether to match the components exactly (i.e. no other components are allowed), or to use a simple filter that does not restrict further components.
Returns the number of removed entities.
See also ecs.World.NewEntityWith.
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 helper for mapping seven components.
Example ¶
world := ecs.NewWorld() mapper := NewMap7[A, B, C, D, E, F, G](&world) entity := mapper.NewEntity() a, b, c, d, e, f, g := mapper.Get(entity)
func NewMap7 ¶
func NewMap7[A any, B any, C any, D any, E any, F any, G any](w *ecs.World, relation ...Comp) Map7[A, B, C, D, E, F, G]
NewMap7 creates a new Map7 object.
The optional argument can be used to set an ecs.Relation component type.
func (*Map7[A, B, C, D, E, F, G]) Add ¶
Add the Map7's components to the given entity.
See also ecs.World.Add.
func (*Map7[A, B, C, D, E, F, G]) Assign ¶
func (m *Map7[A, B, C, D, E, F, G]) Assign(entity ecs.Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G)
Assign the Map7's components to the given entity, using the supplied values.
See also ecs.World.Assign.
func (*Map7[A, B, C, D, E, F, G]) Get ¶
Get all the Map7's components for the given entity.
See Map7.GetUnchecked for an optimized version for static entities. See also ecs.World.Get.
func (*Map7[A, B, C, D, E, F, G]) GetUnchecked ¶ added in v0.7.0
GetUnchecked all the Map7's components for the given entity.
GetUnchecked is an optimized version of Map7.Get, for cases where entities are static or checked with ecs.World.Alive in user code.
See also ecs.World.GetUnchecked.
func (*Map7[A, B, C, D, E, F, G]) New ¶ added in v0.8.0
New creates a new ecs.Entity with the Map7's components.
The optional argument can be used to set the target ecs.Entity for the Map7's ecs.Relation.
See also ecs.World.NewEntity.
func (*Map7[A, B, C, D, E, F, G]) NewBatch ¶ added in v0.8.0
NewBatch creates entities with the Map7's components.
The optional argument can be used to set the target ecs.Entity for the Map7's ecs.Relation.
See also Map7.NewBatchQ and ecs.Batch.NewBatch.
func (*Map7[A, B, C, D, E, F, G]) NewBatchQ ¶ added in v0.8.0
func (m *Map7[A, B, C, D, E, F, G]) NewBatchQ(count int, target ...ecs.Entity) Query7[A, B, C, D, E, F, G]
NewBatchQ creates entities with the Map7's components. It returns a Query7 over the new entities.
The optional argument can be used to set the target ecs.Entity for the Map7's ecs.Relation.
Listener notification is delayed until the query is closed of fully iterated.
See also Map7.NewBatch and ecs.Builder.NewBatchQ.
func (*Map7[A, B, C, D, E, F, G]) NewWith ¶ added in v0.8.0
func (m *Map7[A, B, C, D, E, F, G]) NewWith(a *A, b *B, c *C, d *D, e *E, f *F, g *G, target ...ecs.Entity) ecs.Entity
NewWith creates a new ecs.Entity with the Map7's components, using the supplied values.
The optional argument can be used to set the target ecs.Entity for the Map7's ecs.Relation.
See also ecs.NewBuilderWith.
func (*Map7[A, B, C, D, E, F, G]) Remove ¶
Remove the Map7's components from the given entity.
See also ecs.World.Remove.
func (*Map7[A, B, C, D, E, F, G]) RemoveEntities ¶ added in v0.6.0
RemoveEntities removes all entities from the world that match the Map7's components.
The argument determines whether to match the components exactly (i.e. no other components are allowed), or to use a simple filter that does not restrict further components.
Returns the number of removed entities.
See also ecs.World.NewEntityWith.
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 helper for mapping eight components.
Example ¶
world := ecs.NewWorld() mapper := NewMap8[A, B, C, D, E, F, G, H](&world) entity := mapper.NewEntity() a, b, c, d, e, f, g, h := mapper.Get(entity)
func NewMap8 ¶
func NewMap8[A any, B any, C any, D any, E any, F any, G any, H any](w *ecs.World, relation ...Comp) Map8[A, B, C, D, E, F, G, H]
NewMap8 creates a new Map8 object.
The optional argument can be used to set an ecs.Relation component type.
func (*Map8[A, B, C, D, E, F, G, H]) Add ¶
Add the Map8's components to the given entity.
See also ecs.World.Add.
func (*Map8[A, B, C, D, E, F, G, H]) Assign ¶
func (m *Map8[A, B, C, D, E, F, G, H]) Assign(entity ecs.Entity, a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H)
Assign the Map8's components to the given entity, using the supplied values.
See also ecs.World.Assign.
func (*Map8[A, B, C, D, E, F, G, H]) Get ¶
Get all the Map8's components for the given entity.
See Map8.GetUnchecked for an optimized version for static entities. See also ecs.World.Get.
func (*Map8[A, B, C, D, E, F, G, H]) GetUnchecked ¶ added in v0.7.0
func (m *Map8[A, B, C, D, E, F, G, H]) GetUnchecked(entity ecs.Entity) (*A, *B, *C, *D, *E, *F, *G, *H)
GetUnchecked all the Map8's components for the given entity.
GetUnchecked is an optimized version of Map8.Get, for cases where entities are static or checked with ecs.World.Alive in user code.
See also ecs.World.GetUnchecked.
func (*Map8[A, B, C, D, E, F, G, H]) New ¶ added in v0.8.0
New creates a new ecs.Entity with the Map8's components.
The optional argument can be used to set the target ecs.Entity for the Map8's ecs.Relation.
See also ecs.World.NewEntity.
func (*Map8[A, B, C, D, E, F, G, H]) NewBatch ¶ added in v0.8.0
NewBatch creates entities with the Map8's components.
The optional argument can be used to set the target ecs.Entity for the Map8's ecs.Relation.
See also Map8.NewBatchQ and ecs.Batch.NewBatch.
func (*Map8[A, B, C, D, E, F, G, H]) NewBatchQ ¶ added in v0.8.0
func (m *Map8[A, B, C, D, E, F, G, H]) NewBatchQ(count int, target ...ecs.Entity) Query8[A, B, C, D, E, F, G, H]
NewBatchQ creates entities with the Map8's components. It returns a Query8 over the new entities.
The optional argument can be used to set the target ecs.Entity for the Map8's ecs.Relation.
Listener notification is delayed until the query is closed of fully iterated.
See also Map8.NewBatch and ecs.Builder.NewBatchQ.
func (*Map8[A, B, C, D, E, F, G, H]) NewWith ¶ added in v0.8.0
func (m *Map8[A, B, C, D, E, F, G, H]) NewWith(a *A, b *B, c *C, d *D, e *E, f *F, g *G, h *H, target ...ecs.Entity) ecs.Entity
NewWith creates a new ecs.Entity with the Map8's components, using the supplied values.
The optional argument can be used to set the target ecs.Entity for the Map8's ecs.Relation.
See also ecs.NewBuilderWith.
func (*Map8[A, B, C, D, E, F, G, H]) Remove ¶
Remove the Map8's components from the given entity.
See also ecs.World.Remove.
func (*Map8[A, B, C, D, E, F, G, H]) RemoveEntities ¶ added in v0.6.0
RemoveEntities removes all entities from the world that match the Map8's components.
The argument determines whether to match the components exactly (i.e. no other components are allowed), or to use a simple filter that does not restrict further components.
Returns the number of removed entities.
See also ecs.World.NewEntityWith.
type Query0 ¶
Query0 is a generic query iterator for zero components.
Create it with NewFilter0 and Filter0.Query.
Also has all methods of ecs.Query.
Example ¶
world := ecs.NewWorld() filter := NewFilter0() query := filter.Query(&world) for query.Next() { entity = query.Entity() }
func (*Query0) Relation ¶ added in v0.8.0
Relation returns the target entity for the query's relation.
Panics if the entity does not have the given component, or if the component is not an ecs.Relation. Panics if the underlying Filter0 was not prepared for relations using Filter0.WithRelation.
type Query1 ¶
Query1 is a generic query iterator for one components.
Create it with NewFilter1 and Filter1.Query.
Also has all methods of ecs.Query.
Example ¶
world := ecs.NewWorld() filter := NewFilter1[A]() query := filter.Query(&world) for query.Next() { entity = query.Entity() a := query.Get() }
func (*Query1[A]) Get ¶
func (q *Query1[A]) Get() *A
Get returns all queried components for the current query iterator position.
Use ecs.Query.Entity to get the current Entity.
func (*Query1[A]) Relation ¶ added in v0.8.0
Relation returns the target entity for the query's relation.
Panics if the entity does not have the given component, or if the component is not an ecs.Relation. Panics if the underlying Filter1 was not prepared for relations using Filter1.WithRelation.
type Query2 ¶
Query2 is a generic query iterator for two components.
Create it with NewFilter2 and Filter2.Query.
Also has all methods of ecs.Query.
Example ¶
world := ecs.NewWorld() filter := NewFilter2[A, B]() query := filter.Query(&world) for query.Next() { entity = query.Entity() a, b := query.Get() }
func (*Query2[A, B]) Get ¶
func (q *Query2[A, B]) Get() (*A, *B)
Get returns all queried components for the current query iterator position.
Use ecs.Query.Entity to get the current Entity.
func (*Query2[A, B]) Relation ¶ added in v0.8.0
Relation returns the target entity for the query's relation.
Panics if the entity does not have the given component, or if the component is not an ecs.Relation. Panics if the underlying Filter2 was not prepared for relations using Filter2.WithRelation.
type Query3 ¶
Query3 is a generic query iterator for three components.
Create it with NewFilter3 and Filter3.Query.
Also has all methods of ecs.Query.
Example ¶
world := ecs.NewWorld() filter := NewFilter3[A, B, C]() query := filter.Query(&world) for query.Next() { entity = query.Entity() a, b, c := query.Get() }
func (*Query3[A, B, C]) Get ¶
func (q *Query3[A, B, C]) Get() (*A, *B, *C)
Get returns all queried components for the current query iterator position.
Use ecs.Query.Entity to get the current Entity.
func (*Query3[A, B, C]) Relation ¶ added in v0.8.0
Relation returns the target entity for the query's relation.
Panics if the entity does not have the given component, or if the component is not an ecs.Relation. Panics if the underlying Filter3 was not prepared for relations using Filter3.WithRelation.
type Query4 ¶
type Query4[A any, B any, C any, D any] struct { ecs.Query // contains filtered or unexported fields }
Query4 is a generic query iterator for four components.
Create it with NewFilter4 and Filter4.Query.
Also has all methods of ecs.Query.
Example ¶
world := ecs.NewWorld() filter := NewFilter4[A, B, C, D]() query := filter.Query(&world) for query.Next() { entity = query.Entity() a, b, c, d := query.Get() }
func (*Query4[A, B, C, D]) Get ¶
func (q *Query4[A, B, C, D]) Get() (*A, *B, *C, *D)
Get returns all queried components for the current query iterator position.
Use ecs.Query.Entity to get the current Entity.
func (*Query4[A, B, C, D]) Relation ¶ added in v0.8.0
Relation returns the target entity for the query's relation.
Panics if the entity does not have the given component, or if the component is not an ecs.Relation. Panics if the underlying Filter4 was not prepared for relations using Filter4.WithRelation.
type Query5 ¶
type Query5[A any, B any, C any, D any, E any] struct { ecs.Query // contains filtered or unexported fields }
Query5 is a generic query iterator for five components.
Create it with NewFilter5 and Filter5.Query.
Also has all methods of ecs.Query.
Example ¶
world := ecs.NewWorld() filter := NewFilter5[A, B, C, D, E]() query := filter.Query(&world) for query.Next() { entity = query.Entity() a, b, c, d, e := query.Get() }
func (*Query5[A, B, C, D, E]) Get ¶
func (q *Query5[A, B, C, D, E]) Get() (*A, *B, *C, *D, *E)
Get returns all queried components for the current query iterator position.
Use ecs.Query.Entity to get the current Entity.
func (*Query5[A, B, C, D, E]) Relation ¶ added in v0.8.0
Relation returns the target entity for the query's relation.
Panics if the entity does not have the given component, or if the component is not an ecs.Relation. Panics if the underlying Filter5 was not prepared for relations using Filter5.WithRelation.
type Query6 ¶
type Query6[A any, B any, C any, D any, E any, F any] struct { ecs.Query // contains filtered or unexported fields }
Query6 is a generic query iterator for six components.
Create it with NewFilter6 and Filter6.Query.
Also has all methods of ecs.Query.
Example ¶
world := ecs.NewWorld() filter := NewFilter6[A, B, C, D, E, F]() query := filter.Query(&world) for query.Next() { entity = query.Entity() a, b, c, d, e, f := query.Get() }
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 all queried components for the current query iterator position.
Use ecs.Query.Entity to get the current Entity.
func (*Query6[A, B, C, D, E, F]) Relation ¶ added in v0.8.0
Relation returns the target entity for the query's relation.
Panics if the entity does not have the given component, or if the component is not an ecs.Relation. Panics if the underlying Filter6 was not prepared for relations using Filter6.WithRelation.
type Query7 ¶
type Query7[A any, B any, C any, D any, E any, F any, G any] struct { ecs.Query // contains filtered or unexported fields }
Query7 is a generic query iterator for seven components.
Create it with NewFilter7 and Filter7.Query.
Also has all methods of ecs.Query.
Example ¶
world := ecs.NewWorld() filter := NewFilter7[A, B, C, D, E, F, G]() query := filter.Query(&world) for query.Next() { entity = query.Entity() a, b, c, d, e, f, g := query.Get() }
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 all queried components for the current query iterator position.
Use ecs.Query.Entity to get the current Entity.
func (*Query7[A, B, C, D, E, F, G]) Relation ¶ added in v0.8.0
Relation returns the target entity for the query's relation.
Panics if the entity does not have the given component, or if the component is not an ecs.Relation. Panics if the underlying Filter7 was not prepared for relations using Filter7.WithRelation.
type Query8 ¶
type Query8[A any, B any, C any, D any, E any, F any, G any, H any] struct { ecs.Query // contains filtered or unexported fields }
Query8 is a generic query iterator for eight components.
Create it with NewFilter8 and Filter8.Query.
Also has all methods of ecs.Query.
Example ¶
world := ecs.NewWorld() filter := NewFilter8[A, B, C, D, E, F, G, H]() query := filter.Query(&world) for query.Next() { entity = query.Entity() a, b, c, d, e, f, g, h := query.Get() }
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 all queried components for the current query iterator position.
Use ecs.Query.Entity to get the current Entity.
func (*Query8[A, B, C, D, E, F, G, H]) Relation ¶ added in v0.8.0
Relation returns the target entity for the query's relation.
Panics if the entity does not have the given component, or if the component is not an ecs.Relation. Panics if the underlying Filter8 was not prepared for relations using Filter8.WithRelation.
type Resource ¶ added in v0.5.0
type Resource[T any] struct { // contains filtered or unexported fields }
Resource provides a type-safe way to access world resources.
Create one with NewResource.
Example ¶
world := ecs.NewWorld() myRes := Position{} resAccess := NewResource[Position](&world) resAccess.Add(&myRes) res := resAccess.Get() res.X, res.Y = 10, 5
Output:
func NewResource ¶ added in v0.5.0
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!
Resource provides a type-safe way to access a world resources.
See also ecs.World.Resources.
func (*Resource[T]) Add ¶ added in v0.5.0
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.
See also ecs.Resources.Add.
func (*Resource[T]) Get ¶ added in v0.5.0
func (g *Resource[T]) Get() *T
Get gets the resource of the given type.
Returns nil if there is no such resource.
See also ecs.Resources.Get.
func (*Resource[T]) Has ¶ added in v0.5.0
Has returns whether the world has the resource type.
See also ecs.Resources.Has.
func (*Resource[T]) ID ¶ added in v0.5.0
ID returns the resource ecs.ResID for this Resource mapper.
func (*Resource[T]) Remove ¶ added in v0.5.0
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.