Documentation
¶
Overview ¶
Package ecs provides typed component storage, queries, structural commands, schedules, resources and messages. It is independent of scene, rendering, input and UI runtimes; applications supply their own component types.
World.ComponentRevision tracks storage changes, including archetype migrations, and is suitable for caches retaining component references. Caches retaining copied values can use World.ComponentValueRevision to ignore unchanged migrations. World.EntityVersion tracks live entities independently of component membership.
Component access, resources, revision tracking and message writes are generic World methods. Commands provides deferred structural operations; Bundle.Put builds dynamic component groups. EntitySlot methods access the slot's bound world and validate the entity generation on every lookup.
SystemContext provides Local values and Added/Changed filters. World owns FrameValue, FrameScratch, FrameScratchMap, ScopeValue and MessageScratch; these caches retain their distinct reset, scope and message lifetimes.
World.Query and Query2 through Query7 construct typed query views. World also provides NewSpawner1 through NewSpawner12 and NewPatch1 through NewPatch8 for reusable creation and mutation plans bound to that world.
Index ¶
- func CommitComponent[T comparable](access ComponentAccess[T], value T) bool
- type Bundle
- type Commands
- func (commands *Commands) Despawn(entity Entity)
- func (commands *Commands) Insert[T any](entity Entity, value T)
- func (commands *Commands) Remove[T any](entity Entity)
- func (commands *Commands) RemovePrepared(entity Entity, removal PreparedRemoval)
- func (c *Commands) Reserve(capacity int)
- func (commands *Commands) Spawn(bundle Bundle) Entity
- func (commands *Commands) SpawnPrepared(bundle PreparedBundle) Entity
- type ComponentAccess
- type ComponentBinding
- type ComponentType
- type Components2
- type Components3
- type Components4
- type Components5
- type Components6
- type Components7
- type Condition
- type Entity
- type EntityRow
- type EntitySlot
- type MessageReader
- type Patch1
- type Patch2
- type Patch3
- type Patch4
- type Patch5
- type Patch6
- type Patch7
- type Patch8
- type PreparedBundle
- type PreparedRemoval
- type QueryOption
- type QueryScope
- type QueryView1
- type QueryView2
- type QueryView3
- type QueryView4
- type QueryView5
- type QueryView6
- type QueryView7
- type Schedule
- type Scratch
- type Spawner1
- type Spawner2
- type Spawner3
- type Spawner4
- type Spawner5
- type Spawner6
- type Spawner7
- type Spawner8
- type Spawner9
- type Spawner10
- type Spawner11
- type Spawner12
- type System
- type SystemConfig
- type SystemContext
- func (context *SystemContext) Added[T any]() QueryOption
- func (context *SystemContext) Changed[T any]() QueryOption
- func (c *SystemContext) LastRun() Tick
- func (context *SystemContext) Local[Tag, T any]() *T
- func (context *SystemContext) ResourceAdded[T any]() bool
- func (context *SystemContext) ResourceChanged[T any]() bool
- func (c *SystemContext) ThisRun() Tick
- type Tick
- type World
- func (world *World) AdvanceMessages()
- func (w *World) BindComponent[T any]() ComponentBinding[T]
- func (w *World) ChangeTick() Tick
- func (w *World) ChangesSince(since Tick) SystemContext
- func (w *World) Commands() *Commands
- func (world *World) ComponentDetachRevision[T any]() uint64
- func (world *World) ComponentRevision[T any]() (version, structure uint64)
- func (world *World) ComponentStructureVersion[T any]() uint64
- func (world *World) ComponentValueRevision[T any]() (version, membership uint64)
- func (world *World) ComponentVersion[T any]() uint64
- func (w *World) Despawn(entity Entity) bool
- func (w *World) Entities() iter.Seq[Entity]
- func (w *World) EntityByPickingID(id uint32) (Entity, bool)
- func (w *World) EntityBySlot(slot EntitySlot) (Entity, bool)
- func (w *World) EntityChangesSince(version uint64, dst []Entity) ([]Entity, bool)
- func (w *World) EntityCount() int
- func (w *World) EntitySlots() int
- func (w *World) EntityVersion() uint64
- func (w *World) FlushCommands() error
- func (world *World) FrameScratch[Tag, T any]() *Scratch[T]
- func (world *World) FrameScratchMap[Tag any, K comparable, V any]() map[K]V
- func (world *World) FrameValue[Tag, T any]() *T
- func (world *World) Get[T any](entity Entity) (value T, ok bool)
- func (world *World) GetMut[T any](entity Entity) *T
- func (world *World) GetRef[T any](entity Entity) *T
- func (world *World) GetResource[T any]() (T, bool)
- func (world *World) GetResourceMut[T any]() (*T, bool)
- func (world *World) Has[T any](entity Entity) bool
- func (w *World) InQueryScope(entity Entity) bool
- func (world *World) Insert[T any](entity Entity, value T) error
- func (world *World) Insert2[A, B any](entity Entity, a A, b B) error
- func (world *World) Insert3[A, B, C any](entity Entity, a A, b B, c C) error
- func (world *World) Insert4[A, B, C, D any](entity Entity, a A, b B, c C, d D) error
- func (world *World) Insert5[A, B, C, D, E any](entity Entity, a A, b B, c C, d D, e E) error
- func (world *World) Insert6[A, B, C, D, E, F any](entity Entity, a A, b B, c C, d D, e E, f F) error
- func (world *World) Insert7[A, B, C, D, E, F, G any](entity Entity, a A, b B, c C, d D, e E, f F, g G) error
- func (world *World) Insert8[A, B, C, D, E, F, G, H any](entity Entity, a A, b B, c C, d D, e E, f F, g G, h H) error
- func (world *World) InsertResource[T any](resource T)
- func (w *World) IsAlive(entity Entity) bool
- func (w *World) Maintain()
- func (world *World) MessageScratch[Tag, T any]() *Scratch[T]
- func (world *World) MustMut[T any](entity Entity) *T
- func (w *World) MutationVersion() uint64
- func (world *World) NewPatch1[A any](removed ...ComponentType) Patch1[A]
- func (world *World) NewPatch2[A, B any](removed ...ComponentType) Patch2[A, B]
- func (world *World) NewPatch3[A, B, C any](removed ...ComponentType) Patch3[A, B, C]
- func (world *World) NewPatch4[A, B, C, D any](removed ...ComponentType) Patch4[A, B, C, D]
- func (world *World) NewPatch5[A, B, C, D, E any](removed ...ComponentType) Patch5[A, B, C, D, E]
- func (world *World) NewPatch6[A, B, C, D, E, F any](removed ...ComponentType) Patch6[A, B, C, D, E, F]
- func (world *World) NewPatch7[A, B, C, D, E, F, G any](removed ...ComponentType) Patch7[A, B, C, D, E, F, G]
- func (world *World) NewPatch8[A, B, C, D, E, F, G, H any](removed ...ComponentType) Patch8[A, B, C, D, E, F, G, H]
- func (world *World) NewSpawner1[A any]() Spawner1[A]
- func (world *World) NewSpawner2[A, B any]() Spawner2[A, B]
- func (world *World) NewSpawner3[A, B, C any]() Spawner3[A, B, C]
- func (world *World) NewSpawner4[A, B, C, D any]() Spawner4[A, B, C, D]
- func (world *World) NewSpawner5[A, B, C, D, E any]() Spawner5[A, B, C, D, E]
- func (world *World) NewSpawner6[A, B, C, D, E, F any]() Spawner6[A, B, C, D, E, F]
- func (world *World) NewSpawner7[A, B, C, D, E, F, G any]() Spawner7[A, B, C, D, E, F, G]
- func (world *World) NewSpawner8[A, B, C, D, E, F, G, H any]() Spawner8[A, B, C, D, E, F, G, H]
- func (world *World) NewSpawner9[A, B, C, D, E, F, G, H, I any]() Spawner9[A, B, C, D, E, F, G, H, I]
- func (world *World) NewSpawner10[A, B, C, D, E, F, G, H, I, J any]() Spawner10[A, B, C, D, E, F, G, H, I, J]
- func (world *World) NewSpawner11[A, B, C, D, E, F, G, H, I, J, K any]() Spawner11[A, B, C, D, E, F, G, H, I, J, K]
- func (world *World) NewSpawner12[A, B, C, D, E, F, G, H, I, J, K, L any]() Spawner12[A, B, C, D, E, F, G, H, I, J, K, L]
- func (world *World) OnComponentRemove[T any](cleanup func(*World, Entity, *T))
- func (w *World) PrepareBundle(bundle Bundle) PreparedBundle
- func (world *World) PrepareRemoval(types ...ComponentType) PreparedRemoval
- func (world *World) Query[A any](options ...QueryOption) QueryView1[A]
- func (world *World) Query2[A, B any](options ...QueryOption) QueryView2[A, B]
- func (world *World) Query3[A, B, C any](options ...QueryOption) QueryView3[A, B, C]
- func (world *World) Query4[A, B, C, D any](options ...QueryOption) QueryView4[A, B, C, D]
- func (world *World) Query5[A, B, C, D, E any](options ...QueryOption) QueryView5[A, B, C, D, E]
- func (world *World) Query6[A, B, C, D, E, F any](options ...QueryOption) QueryView6[A, B, C, D, E, F]
- func (world *World) Query7[A, B, C, D, E, F, G any](options ...QueryOption) QueryView7[A, B, C, D, E, F, G]
- func (w *World) QueryScope() *QueryScope
- func (w *World) QueryScopeKey() (*QueryScope, uint64)
- func (world *World) Remove[T any](entity Entity) (T, bool)
- func (world *World) RemoveResource[T any]() (T, bool)
- func (w *World) ReserveEntities(capacity int)
- func (world *World) ResourceChangeTick[T any]() Tick
- func (w *World) Row(entity Entity) EntityRow
- func (world *World) ScopeValue[Tag, T any]() *T
- func (world *World) SetIfChanged[T comparable](entity Entity, value T) bool
- func (w *World) SetQueryScope(scope *QueryScope) *QueryScope
- func (w *World) Slot(entity Entity) EntitySlot
- func (w *World) Spawn(bundle Bundle) Entity
- func (w *World) SpawnPrepared(bundle PreparedBundle) Entity
- func (w *World) StructureVersion() uint64
- func (world *World) WriteMessage[T any](message T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommitComponent ¶
func CommitComponent[T comparable](access ComponentAccess[T], value T) bool
CommitComponent writes only when the value differs. Query accesses use their query tick; bindings obtain a mutation tick only when a value actually changes.
Types ¶
type Bundle ¶
type Bundle struct {
// contains filtered or unexported fields
}
type Commands ¶
type Commands struct {
// contains filtered or unexported fields
}
func (*Commands) RemovePrepared ¶
func (commands *Commands) RemovePrepared(entity Entity, removal PreparedRemoval)
RemovePrepared queues one batch migration for use during iteration.
func (*Commands) Reserve ¶
Reserve grows command queue storage without changing its contents. It avoids queue backing-array growth when a system knows its command burst.
func (*Commands) SpawnPrepared ¶
func (commands *Commands) SpawnPrepared(bundle PreparedBundle) Entity
SpawnPrepared reserves an entity and queues a previously prepared bundle without rebuilding its component entry list.
type ComponentAccess ¶
type ComponentAccess[T any] struct { // contains filtered or unexported fields }
ComponentAccess provides explicit per-component change tracking. Query accesses expire after iteration; binding accesses expire after structural mutation.
func (ComponentAccess[T]) Get ¶
func (a ComponentAccess[T]) Get() T
func (ComponentAccess[T]) Mut ¶
func (a ComponentAccess[T]) Mut() *T
func (ComponentAccess[T]) Ref ¶
func (a ComponentAccess[T]) Ref() *T
Ref returns a read-only component reference without marking it changed.
type ComponentBinding ¶
type ComponentBinding[T any] struct { // contains filtered or unexported fields }
ComponentBinding resolves a component type once for repeated access in one world. It retains no column pointers and survives entity migrations.
func (ComponentBinding[T]) Access ¶
func (b ComponentBinding[T]) Access(row EntityRow) ComponentAccess[T]
Access returns a missing access (Ref is nil) for an invalid row or absent component. Reads preserve ticks. Mut and CommitComponent mark actual write access.
func (ComponentBinding[T]) Get ¶
func (b ComponentBinding[T]) Get(row EntityRow) (value T, ok bool)
type ComponentType ¶
type ComponentType struct {
// contains filtered or unexported fields
}
ComponentType identifies a component without constructing or boxing a value. Resolve descriptors once with PrepareRemoval or NewPatchN, outside the execution loop.
func Type ¶
func Type[T any]() ComponentType
type Components2 ¶
type Components2[A, B any] struct { A ComponentAccess[A] B ComponentAccess[B] }
Components2 contains explicitly tracked component access for one entity.
type Components3 ¶
type Components3[A, B, C any] struct { A ComponentAccess[A] B ComponentAccess[B] C ComponentAccess[C] }
Components3 contains explicitly tracked component access for one entity.
type Components4 ¶
type Components4[A, B, C, D any] struct { A ComponentAccess[A] B ComponentAccess[B] C ComponentAccess[C] D ComponentAccess[D] }
Components4 contains explicitly tracked component access for one entity.
type Components5 ¶
type Components5[A, B, C, D, E any] struct { A ComponentAccess[A] B ComponentAccess[B] C ComponentAccess[C] D ComponentAccess[D] E ComponentAccess[E] }
Components5 contains explicitly tracked component access for one entity.
type Components6 ¶
type Components6[A, B, C, D, E, F any] struct { A ComponentAccess[A] B ComponentAccess[B] C ComponentAccess[C] D ComponentAccess[D] E ComponentAccess[E] F ComponentAccess[F] }
Components6 contains explicitly tracked component access for one entity.
type Components7 ¶
type Components7[A, B, C, D, E, F, G any] struct { A ComponentAccess[A] B ComponentAccess[B] C ComponentAccess[C] D ComponentAccess[D] E ComponentAccess[E] F ComponentAccess[F] G ComponentAccess[G] }
Components7 contains explicitly tracked component access for one entity.
type Condition ¶
type Condition func(*SystemContext) bool
type Entity ¶
type Entity uint64
type EntityRow ¶
type EntityRow struct {
// contains filtered or unexported fields
}
EntityRow borrows one entity's location until the next structural mutation. Use a fresh Row after spawning, despawning, adding/removing components or World.Maintain, which may compact component storage.
type EntitySlot ¶
type EntitySlot struct {
// contains filtered or unexported fields
}
EntitySlot is a cached entity lookup bound to one World.
A slot keeps the entity generation, so resolving it after the entity has been despawned or its index has been reused fails instead of returning a different entity. Create slots during setup and reuse them in hot paths.
func (EntitySlot) Entity ¶
func (s EntitySlot) Entity() Entity
Entity returns the raw entity handle stored in the slot. Use EntityBySlot when the slot may have outlived a scene mutation and needs validation.
func (EntitySlot) Get ¶
func (s EntitySlot) Get[T any]() (T, bool)
Get reads a component from the bound world. Empty and stale slots return false.
func (EntitySlot) GetMut ¶
func (s EntitySlot) GetMut[T any]() *T
GetMut returns a mutable component reference, or nil for an empty or stale slot. The pointer must not outlive structural mutations.
func (EntitySlot) GetRef ¶
func (s EntitySlot) GetRef[T any]() *T
GetRef returns a component reference without marking it changed, or nil for an empty or stale slot. The pointer must not outlive structural mutations.
func (EntitySlot) Has ¶
func (s EntitySlot) Has[T any]() bool
Has reports whether the bound entity has the component. Empty and stale slots return false.
func (EntitySlot) MustMut ¶
func (s EntitySlot) MustMut[T any]() *T
MustMut requires a component on the bound entity. The pointer must not outlive structural mutations.
func (EntitySlot) Valid ¶
func (s EntitySlot) Valid() bool
Valid reports whether the slot contains a world-bound entity handle. It does not prove that the entity is still alive; resolve it through World.
type MessageReader ¶
type MessageReader[T any] struct { // contains filtered or unexported fields }
MessageReader tracks consumption of one message type within one world. Its zero value starts at the oldest retained message. Consumers use separate readers; copying a reader copies its current position.
func (*MessageReader[T]) All ¶
func (r *MessageReader[T]) All(world *World) iter.Seq[*T]
All visits unread messages without copying them. The reader consumes each message before yielding it, so break, return, and panic retain the remaining messages. Pointers are borrowed only for the current iteration body; do not advance message buffers during iteration. Use a separate reader per consumer.
func (*MessageReader[T]) Discard ¶
func (r *MessageReader[T]) Discard(world *World)
Discard skips all currently retained messages for this reader in constant time. Other readers and messages written later are unaffected.
func (*MessageReader[T]) Read ¶
func (r *MessageReader[T]) Read(world *World) []T
Read copies unread messages to a new slice and consumes them. Use All for direct iteration or ReadInto when a retained copy needs reusable storage.
func (*MessageReader[T]) ReadInto ¶
func (r *MessageReader[T]) ReadInto(world *World, dst []T) []T
ReadInto writes unread messages into a caller-owned buffer and advances the reader. Reusing the returned slice avoids the allocation performed by Read.
type Patch1 ¶
type Patch1[A any] struct { // contains filtered or unexported fields }
Patch1 upserts typed values and removes other components in one migration. Prepare once per world; copies share transitions. Inserted types take precedence over removals.
func (Patch1[A]) Apply ¶
Apply preserves Added for replacements and both ticks for retained values. Cleanup hooks run before any writes; warmed transitions and capacities allocate nothing.
type Patch2 ¶
type Patch2[A, B any] struct { // contains filtered or unexported fields }
Patch2 upserts typed values and removes other components in one migration. Prepare once per world; copies share transitions. Inserted types take precedence over removals.
func (Patch2[A, B]) Apply ¶
Apply preserves Added for replacements and both ticks for retained values. Cleanup hooks run before any writes; warmed transitions and capacities allocate nothing.
type Patch3 ¶
type Patch3[A, B, C any] struct { // contains filtered or unexported fields }
Patch3 upserts typed values and removes other components in one migration. Prepare once per world; copies share transitions. Inserted types take precedence over removals.
func (Patch3[A, B, C]) Apply ¶
Apply preserves Added for replacements and both ticks for retained values. Cleanup hooks run before any writes; warmed transitions and capacities allocate nothing.
type Patch4 ¶
type Patch4[A, B, C, D any] struct { // contains filtered or unexported fields }
Patch4 upserts typed values and removes other components in one migration. Prepare once per world; copies share transitions. Inserted types take precedence over removals.
func (Patch4[A, B, C, D]) Apply ¶
Apply preserves Added for replacements and both ticks for retained values. Cleanup hooks run before any writes; warmed transitions and capacities allocate nothing.
type Patch5 ¶
type Patch5[A, B, C, D, E any] struct { // contains filtered or unexported fields }
Patch5 upserts typed values and removes other components in one migration. Prepare once per world; copies share transitions. Inserted types take precedence over removals.
func (Patch5[A, B, C, D, E]) Apply ¶
Apply preserves Added for replacements and both ticks for retained values. Cleanup hooks run before any writes; warmed transitions and capacities allocate nothing.
type Patch6 ¶
type Patch6[A, B, C, D, E, F any] struct { // contains filtered or unexported fields }
Patch6 upserts typed values and removes other components in one migration. Prepare once per world; copies share transitions. Inserted types take precedence over removals.
func (Patch6[A, B, C, D, E, F]) Apply ¶
Apply preserves Added for replacements and both ticks for retained values. Cleanup hooks run before any writes; warmed transitions and capacities allocate nothing.
type Patch7 ¶
type Patch7[A, B, C, D, E, F, G any] struct { // contains filtered or unexported fields }
Patch7 upserts typed values and removes other components in one migration. Prepare once per world; copies share transitions. Inserted types take precedence over removals.
func (Patch7[A, B, C, D, E, F, G]) Apply ¶
Apply preserves Added for replacements and both ticks for retained values. Cleanup hooks run before any writes; warmed transitions and capacities allocate nothing.
type Patch8 ¶
type Patch8[A, B, C, D, E, F, G, H any] struct { // contains filtered or unexported fields }
Patch8 upserts typed values and removes other components in one migration. Prepare once per world; copies share transitions. Inserted types take precedence over removals.
func (Patch8[A, B, C, D, E, F, G, H]) Apply ¶
func (p Patch8[A, B, C, D, E, F, G, H]) Apply(entity Entity, a A, b B, c C, d D, e E, f F, g G, h H) error
Apply preserves Added for replacements and both ticks for retained values. Cleanup hooks run before any writes; warmed transitions and capacities allocate nothing.
type PreparedBundle ¶
type PreparedBundle struct {
// contains filtered or unexported fields
}
PreparedBundle caches the world-specific component IDs and sorted entries of a Bundle. It is immutable after creation and can be reused for repeated spawns without rebuilding the bundle description.
type PreparedRemoval ¶
type PreparedRemoval struct {
// contains filtered or unexported fields
}
PreparedRemoval removes a component set in one archetype migration. Copies share the same world-bound transition cache. Missing types are ignored.
func (PreparedRemoval) Apply ¶
func (r PreparedRemoval) Apply(entity Entity) bool
Apply returns whether any components were removed. It is allocation-free once the source transition and destination capacity have been prepared. Cleanup hooks see the complete source row and run before storage is moved. Hook panics do not move the row; external side effects are not rolled back.
func (PreparedRemoval) Reserve ¶
func (r PreparedRemoval) Reserve(capacity int)
Reserve prepares populated or preallocated source archetypes and reserves each destination for capacity entities. Unused shapes still need warming.
type QueryOption ¶
type QueryOption interface {
// contains filtered or unexported methods
}
func Unscoped ¶
func Unscoped() QueryOption
Unscoped visits matching tables independently of the current execution scope. It is intended for world-owned indexes that also include suspended scenes.
func With ¶
func With[T any]() QueryOption
func Without ¶
func Without[T any]() QueryOption
type QueryScope ¶
type QueryScope struct {
// contains filtered or unexported fields
}
QueryScope confines ordinary queries to a borrowed entity set. Direct component access remains available for loading and lifetime management. Ordinary queries use table order; explicit Query.In lists preserve order. Membership is compiled at structural boundaries; warm iteration does not allocate. World.Maintain retires caches unused for 30 frames. Borrowed membership survives.
func (*QueryScope) ReleaseCache ¶
func (s *QueryScope) ReleaseCache()
ReleaseCache retires compiled membership and system values, preserving the borrowed entity set. Existing cache pointers must no longer be used.
func (*QueryScope) Reset ¶
func (s *QueryScope) Reset(entities []Entity)
type QueryView1 ¶
type QueryView1[A any] struct { // contains filtered or unexported fields }
QueryView1 retains a query plan and its filter snapshot. Range over All to iterate.
func (QueryView1[A]) All ¶
func (v QueryView1[A]) All(yield func(Entity, ComponentAccess[A]) bool)
func (QueryView1[A]) In ¶
func (v QueryView1[A]) In(entities []Entity) QueryView1[A]
In limits traversal to the supplied entities, preserving their order. The list is borrowed and must not change during iteration. Nil visits none.
type QueryView2 ¶
type QueryView2[A, B any] struct { // contains filtered or unexported fields }
QueryView2 retains a query plan and its filter snapshot. Range over All to iterate.
func (QueryView2[A, B]) All ¶
func (v QueryView2[A, B]) All(yield func(Entity, Components2[A, B]) bool)
func (QueryView2[A, B]) In ¶
func (v QueryView2[A, B]) In(entities []Entity) QueryView2[A, B]
In limits traversal to the supplied entities, preserving their order. The list is borrowed and must not change during iteration. Nil visits none.
type QueryView3 ¶
type QueryView3[A, B, C any] struct { // contains filtered or unexported fields }
QueryView3 retains a query plan and its filter snapshot. Range over All to iterate.
func (QueryView3[A, B, C]) All ¶
func (v QueryView3[A, B, C]) All(yield func(Entity, Components3[A, B, C]) bool)
func (QueryView3[A, B, C]) In ¶
func (v QueryView3[A, B, C]) In(entities []Entity) QueryView3[A, B, C]
In limits traversal to the supplied entities, preserving their order. The list is borrowed and must not change during iteration. Nil visits none.
type QueryView4 ¶
type QueryView4[A, B, C, D any] struct { // contains filtered or unexported fields }
QueryView4 retains a query plan and its filter snapshot. Range over All to iterate.
func (QueryView4[A, B, C, D]) All ¶
func (v QueryView4[A, B, C, D]) All(yield func(Entity, Components4[A, B, C, D]) bool)
func (QueryView4[A, B, C, D]) In ¶
func (v QueryView4[A, B, C, D]) In(entities []Entity) QueryView4[A, B, C, D]
In limits traversal to the supplied entities, preserving their order. The list is borrowed and must not change during iteration. Nil visits none.
type QueryView5 ¶
type QueryView5[A, B, C, D, E any] struct { // contains filtered or unexported fields }
QueryView5 retains a query plan and its filter snapshot. Range over All to iterate.
func (QueryView5[A, B, C, D, E]) All ¶
func (v QueryView5[A, B, C, D, E]) All(yield func(Entity, Components5[A, B, C, D, E]) bool)
func (QueryView5[A, B, C, D, E]) In ¶
func (v QueryView5[A, B, C, D, E]) In(entities []Entity) QueryView5[A, B, C, D, E]
In limits traversal to the supplied entities, preserving their order. The list is borrowed and must not change during iteration. Nil visits none.
type QueryView6 ¶
type QueryView6[A, B, C, D, E, F any] struct { // contains filtered or unexported fields }
QueryView6 retains a query plan and its filter snapshot. Range over All to iterate.
func (QueryView6[A, B, C, D, E, F]) All ¶
func (v QueryView6[A, B, C, D, E, F]) All(yield func(Entity, Components6[A, B, C, D, E, F]) bool)
func (QueryView6[A, B, C, D, E, F]) In ¶
func (v QueryView6[A, B, C, D, E, F]) In(entities []Entity) QueryView6[A, B, C, D, E, F]
In limits traversal to the supplied entities, preserving their order. The list is borrowed and must not change during iteration. Nil visits none.
type QueryView7 ¶
type QueryView7[A, B, C, D, E, F, G any] struct { // contains filtered or unexported fields }
QueryView7 retains a query plan and its filter snapshot. Range over All to iterate.
func (QueryView7[A, B, C, D, E, F, G]) All ¶
func (v QueryView7[A, B, C, D, E, F, G]) All(yield func(Entity, Components7[A, B, C, D, E, F, G]) bool)
func (QueryView7[A, B, C, D, E, F, G]) In ¶
func (v QueryView7[A, B, C, D, E, F, G]) In(entities []Entity) QueryView7[A, B, C, D, E, F, G]
In limits traversal to the supplied entities, preserving their order. The list is borrowed and must not change during iteration. Nil visits none.
type Schedule ¶
type Schedule struct {
// contains filtered or unexported fields
}
func NewSchedule ¶
func (*Schedule) Add ¶
func (s *Schedule) Add(config SystemConfig) error
type Scratch ¶
type Scratch[T any] struct { Values []T // contains filtered or unexported fields }
func (*Scratch[T]) ReleaseUnused ¶
func (s *Scratch[T]) ReleaseUnused()
ReleaseUnused clears references in the portion used by the previous frame that was not overwritten in the current frame.
type Spawner1 ¶
type Spawner1[A any] struct { // contains filtered or unexported fields }
Spawner1 binds component columns once for repeated allocation-free creation.
type Spawner2 ¶
type Spawner2[A, B any] struct { // contains filtered or unexported fields }
Spawner2 binds component columns once for repeated allocation-free creation.
type Spawner3 ¶
type Spawner3[A, B, C any] struct { // contains filtered or unexported fields }
Spawner3 binds component columns once for repeated allocation-free creation.
type Spawner4 ¶
type Spawner4[A, B, C, D any] struct { // contains filtered or unexported fields }
Spawner4 binds component columns once for repeated allocation-free creation.
type Spawner5 ¶
type Spawner5[A, B, C, D, E any] struct { // contains filtered or unexported fields }
Spawner5 binds component columns once for repeated allocation-free creation.
type Spawner6 ¶
type Spawner6[A, B, C, D, E, F any] struct { // contains filtered or unexported fields }
Spawner6 binds component columns once for repeated allocation-free creation.
type Spawner7 ¶
type Spawner7[A, B, C, D, E, F, G any] struct { // contains filtered or unexported fields }
Spawner7 binds component columns once for repeated allocation-free creation.
type Spawner8 ¶
type Spawner8[A, B, C, D, E, F, G, H any] struct { // contains filtered or unexported fields }
Spawner8 binds component columns once for repeated allocation-free creation.
type Spawner9 ¶ added in v0.1.8
type Spawner9[A, B, C, D, E, F, G, H, I any] struct { // contains filtered or unexported fields }
Spawner9 binds component columns once for repeated allocation-free creation.
type Spawner10 ¶ added in v0.1.8
type Spawner10[A, B, C, D, E, F, G, H, I, J any] struct { // contains filtered or unexported fields }
Spawner10 binds component columns once for repeated allocation-free creation.
type Spawner11 ¶ added in v0.1.8
type Spawner11[A, B, C, D, E, F, G, H, I, J, K any] struct { // contains filtered or unexported fields }
Spawner11 binds component columns once for repeated allocation-free creation.
type Spawner12 ¶ added in v0.1.8
type Spawner12[A, B, C, D, E, F, G, H, I, J, K, L any] struct { // contains filtered or unexported fields }
Spawner12 binds component columns once for repeated allocation-free creation.
type System ¶
type System func(*SystemContext) error
type SystemConfig ¶
type SystemConfig struct {
System System
Name string
Before []string
After []string
RunIf []Condition
}
func (SystemConfig) Run ¶
func (c SystemConfig) Run(world *World) error
type SystemContext ¶
type SystemContext struct {
World *World
Commands *Commands
// contains filtered or unexported fields
}
func (*SystemContext) Added ¶
func (context *SystemContext) Added[T any]() QueryOption
func (*SystemContext) Changed ¶
func (context *SystemContext) Changed[T any]() QueryOption
func (*SystemContext) LastRun ¶
func (c *SystemContext) LastRun() Tick
func (*SystemContext) Local ¶
func (context *SystemContext) Local[Tag, T any]() *T
func (*SystemContext) ResourceAdded ¶
func (context *SystemContext) ResourceAdded[T any]() bool
func (*SystemContext) ResourceChanged ¶
func (context *SystemContext) ResourceChanged[T any]() bool
func (*SystemContext) ThisRun ¶
func (c *SystemContext) ThisRun() Tick
type World ¶
type World struct {
// contains filtered or unexported fields
}
func (*World) AdvanceMessages ¶
func (world *World) AdvanceMessages()
func (*World) BindComponent ¶
func (w *World) BindComponent[T any]() ComponentBinding[T]
func (*World) ChangeTick ¶
ChangeTick returns the current change-tracking clock without advancing it.
func (*World) ChangesSince ¶
func (w *World) ChangesSince(since Tick) SystemContext
ChangesSince snapshots a read window ending at the current change tick. It does not execute a system or advance the clock.
func (*World) ComponentDetachRevision ¶ added in v0.1.8
ComponentDetachRevision changes when a component is removed from a live entity. Despawns can be handled separately through EntityChangesSince.
func (*World) ComponentRevision ¶
ComponentRevision reads the content and structural versions in one lookup. Missing types return zero without registering storage or advancing ticks.
func (*World) ComponentStructureVersion ¶
ComponentStructureVersion changes when rows are inserted or removed.
func (*World) ComponentValueRevision ¶
ComponentValueRevision reports writes and membership changes, excluding migrations that only relocate unchanged values between archetypes. The second result changes only when values are inserted or removed.
func (*World) ComponentVersion ¶
ComponentVersion changes for writes, insertion, removal and row migration.
func (*World) Entities ¶
Entities traverses every live entity independently of the current scope. It is intended for rebuilding scopes, not normal system updates.
func (*World) EntityByPickingID ¶
EntityByPickingID resolves the current live entity occupying a GPU picking slot. A stale or background ID returns false.
func (*World) EntityBySlot ¶
func (w *World) EntityBySlot(slot EntitySlot) (Entity, bool)
EntityBySlot resolves a cached entity lookup without string or map allocation. Slots from another world and stale generations are rejected.
func (*World) EntityChangesSince ¶ added in v0.1.8
EntityChangesSince returns the handles affected by recent membership changes. A handle may appear more than once. Read its current state with IsAlive. The first call enables recording for subsequent changes. A false result means callers must refresh from the live entity list.
func (*World) EntityCount ¶
func (*World) EntitySlots ¶
EntitySlots reports the metadata slots used by live, free and reserved entities. Indexed external caches can grow to this size and check handles.
func (*World) EntityVersion ¶
EntityVersion changes only when a live entity is spawned or despawned. Adding or removing components does not change entity membership.
func (*World) FlushCommands ¶
func (*World) FrameScratch ¶
FrameScratch borrows reusable storage until the next call with the same types or World.Maintain. Maintenance clears idle references and trims peaks.
func (*World) FrameScratchMap ¶
func (world *World) FrameScratchMap[Tag any, K comparable, V any]() map[K]V
FrameScratchMap returns a per-frame map that is cleared on every call. Maps are borrowed until the next call or World.Maintain. Maintenance releases idle references and sustained historical peaks without allocating every frame.
func (*World) FrameValue ¶
func (*World) GetRef ¶
GetRef returns a component reference without marking it changed. Callers must not mutate it or retain it across structural mutations.
func (*World) GetResource ¶
func (*World) GetResourceMut ¶
func (*World) InQueryScope ¶
InQueryScope reports whether a live entity belongs to the current query scope. It lets hierarchy traversals honor scopes without scanning them.
func (*World) Insert6 ¶
func (world *World) Insert6[A, B, C, D, E, F any](entity Entity, a A, b B, c C, d D, e E, f F) error
Insert6 upserts values together, reusing a world-local patch plan.
func (*World) Insert7 ¶
func (world *World) Insert7[A, B, C, D, E, F, G any](entity Entity, a A, b B, c C, d D, e E, f F, g G) error
Insert7 upserts values together, reusing a world-local patch plan.
func (*World) Insert8 ¶
func (world *World) Insert8[A, B, C, D, E, F, G, H any](entity Entity, a A, b B, c C, d D, e E, f F, g G, h H) error
Insert8 upserts values together, reusing a world-local patch plan.
func (*World) InsertResource ¶
func (*World) Maintain ¶
func (w *World) Maintain()
Maintain releases caches after sustained underuse. Call once at the end of a frame, after all borrowed component accesses and drawing snapshots are done. Table and column identities survive; borrowed rows expire if storage moves.
func (*World) MessageScratch ¶
MessageScratch provides two-buffer storage for data borrowed by messages. Append to Values; AdvanceMessages retains it for the next message frame and recycles the older buffer. Tags isolate arenas even when T is identical. Do not overwrite borrowed values before two calls to AdvanceMessages.
func (*World) MustMut ¶
MustMut returns an existing component with write access. A missing component or stale entity is a structural error. Do not retain the pointer across structural mutations.
func (*World) MutationVersion ¶
func (*World) NewPatch2 ¶
func (world *World) NewPatch2[A, B any](removed ...ComponentType) Patch2[A, B]
func (*World) NewPatch3 ¶
func (world *World) NewPatch3[A, B, C any](removed ...ComponentType) Patch3[A, B, C]
func (*World) NewPatch4 ¶
func (world *World) NewPatch4[A, B, C, D any](removed ...ComponentType) Patch4[A, B, C, D]
func (*World) NewPatch5 ¶
func (world *World) NewPatch5[A, B, C, D, E any](removed ...ComponentType) Patch5[A, B, C, D, E]
func (*World) NewPatch6 ¶
func (world *World) NewPatch6[A, B, C, D, E, F any](removed ...ComponentType) Patch6[A, B, C, D, E, F]
func (*World) NewPatch7 ¶
func (world *World) NewPatch7[A, B, C, D, E, F, G any](removed ...ComponentType) Patch7[A, B, C, D, E, F, G]
func (*World) NewPatch8 ¶
func (world *World) NewPatch8[A, B, C, D, E, F, G, H any](removed ...ComponentType) Patch8[A, B, C, D, E, F, G, H]
func (*World) NewSpawner1 ¶
func (*World) NewSpawner2 ¶
func (*World) NewSpawner3 ¶
func (*World) NewSpawner4 ¶
func (*World) NewSpawner5 ¶
func (*World) NewSpawner6 ¶
func (*World) NewSpawner7 ¶
func (*World) NewSpawner8 ¶
func (*World) NewSpawner9 ¶ added in v0.1.8
func (*World) NewSpawner10 ¶ added in v0.1.8
func (*World) NewSpawner11 ¶ added in v0.1.8
func (*World) NewSpawner12 ¶ added in v0.1.8
func (*World) OnComponentRemove ¶
OnComponentRemove installs a cleanup hook for removal and despawn. Hooks must not change entity structure; archetype migration does not invoke them.
func (*World) PrepareBundle ¶
func (w *World) PrepareBundle(bundle Bundle) PreparedBundle
PrepareBundle resolves and sorts a bundle for this world. Reuse the result with SpawnPrepared when the same component shape is spawned repeatedly.
func (*World) PrepareRemoval ¶
func (world *World) PrepareRemoval(types ...ComponentType) PreparedRemoval
PrepareRemoval registers the supplied types and binds a reusable removal set. Duplicate descriptors are harmless; an empty set never changes an entity.
func (*World) Query ¶
func (world *World) Query[A any](options ...QueryOption) QueryView1[A]
Query iterates matching entities. Get and Ref do not mark changes; Mut does. Access values and component pointers must not outlive the iteration.
func (*World) Query2 ¶
func (world *World) Query2[A, B any](options ...QueryOption) QueryView2[A, B]
Query2 iterates matching entities. Get and Ref do not mark changes; Mut does. Access values and component pointers must not outlive the iteration.
func (*World) Query3 ¶
func (world *World) Query3[A, B, C any](options ...QueryOption) QueryView3[A, B, C]
Query3 iterates matching entities. Get and Ref do not mark changes; Mut does. Access values and component pointers must not outlive the iteration.
func (*World) Query4 ¶
func (world *World) Query4[A, B, C, D any](options ...QueryOption) QueryView4[A, B, C, D]
Query4 iterates matching entities. Get and Ref do not mark changes; Mut does. Access values and component pointers must not outlive the iteration.
func (*World) Query5 ¶
func (world *World) Query5[A, B, C, D, E any](options ...QueryOption) QueryView5[A, B, C, D, E]
Query5 iterates matching entities. Get and Ref do not mark changes; Mut does. Access values and component pointers must not outlive the iteration.
func (*World) Query6 ¶
func (world *World) Query6[A, B, C, D, E, F any](options ...QueryOption) QueryView6[A, B, C, D, E, F]
Query6 iterates matching entities. Get and Ref do not mark changes; Mut does. Access values and component pointers must not outlive the iteration.
func (*World) Query7 ¶
func (world *World) Query7[A, B, C, D, E, F, G any](options ...QueryOption) QueryView7[A, B, C, D, E, F, G]
Query7 iterates matching entities. Get and Ref do not mark changes; Mut does. Access values and component pointers must not outlive the iteration.
func (*World) QueryScope ¶
func (w *World) QueryScope() *QueryScope
func (*World) QueryScopeKey ¶
func (w *World) QueryScopeKey() (*QueryScope, uint64)
QueryScopeKey identifies both the selected scope and its structural revision.
func (*World) RemoveResource ¶
func (*World) ReserveEntities ¶
ReserveEntities grows entity metadata storage without changing the live entity count. Use it before a known spawn burst to keep the burst allocation free; archetype columns can be reserved through SpawnerN.Reserve.
func (*World) ResourceChangeTick ¶
ResourceChangeTick returns the last write tick, or zero for a missing resource.
func (*World) ScopeValue ¶
ScopeValue keeps long-lived system caches separate for execution and rendering scopes. Switching scopes does not rebuild the other scope's cache. Fetch values again when using a scope after ReleaseCache, an empty Reset or 30 frames without using it; previously borrowed cache pointers have expired.
func (*World) SetIfChanged ¶
func (world *World) SetIfChanged[T comparable](entity Entity, value T) bool
SetIfChanged updates an existing component only when its value differs. It returns false for equal values, missing components and stale entities. It does not insert components and may be used during query iteration.
func (*World) SetQueryScope ¶
func (w *World) SetQueryScope(scope *QueryScope) *QueryScope
SetQueryScope returns the previous scope. Nil restores unrestricted queries. A scope cannot change while a query iterator is live.
func (*World) Slot ¶
func (w *World) Slot(entity Entity) EntitySlot
Slot creates a cached lookup for an alive entity in this world. The slot does not keep the entity alive; EntityBySlot reports false after despawn or slot reuse. An invalid entity produces the zero slot.
func (*World) SpawnPrepared ¶
func (w *World) SpawnPrepared(bundle PreparedBundle) Entity
SpawnPrepared spawns a previously prepared bundle without rebuilding its component entry list. The prepared bundle must belong to this world.
func (*World) StructureVersion ¶
StructureVersion changes when entities are spawned, despawned or moved.