comp

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package comp is how a template of entities names one component and where its value comes from: the same for every entity made from it (Const), read from each entity's own row (Load), the tags of one family (Tagged), the markers of one (Marks), or a default of the store's roster left out (Without). Nothing here is implemented by a user; a store's binding spawns through a Comp's Fill, into the place it laid out.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Omitted

func Omitted(c Comp) (reflect.Type, bool)

Omitted reports whether c is a Without marker, and of which type.

Types

type Comp

type Comp interface {
	// Type is the component type the Comp stands for.
	Type() reflect.Type
	// Row is the row type a Load reads, nil for a component that reads none.
	Row() reflect.Type
	// Fill writes the component's value for the entity row describes into dst, a value of
	// Type the store laid out.
	Fill(dst unsafe.Pointer, row any)
}

Comp is one component of a kind's Spec — made with Const, Load, Tagged or Without, never implemented by a game. Its methods are the spawning store's way in.

func Without

func Without[T any]() Comp

Without leaves the roster's default T out of a kind's Spec — a unit nothing pushes leaves out collision.Physics. It is a marker kind.Template.Spec takes out; it never reaches a spawn.

type Template

type Template[T any] struct {
	// contains filtered or unexported fields
}

Template yields one component value per spawned entity.

func Const

func Const[T any](v T) Template[T]

Const is a component whose value is the same for every entity of the kind.

func Load

func Load[P, T any](load func(row P) T) Template[T]

Load is a component whose value is read from each entity's own row.

func Marks

func Marks[F any]() Template[tag.Tags[F]]

Marks is a Spec component giving every entity of the kind the markers of family F for good, all off: states a plugin switches on and off by a bit.

func Tagged

func Tagged[F any](tags ...tag.Tag[F]) Template[tag.Tags[F]]

Tagged is a Spec component giving every entity of the kind these tags of one family; a Spec names each family once. The tags come from world.Kinds.DefineTag.

func (Template[T]) Fill added in v0.2.0

func (t Template[T]) Fill(dst unsafe.Pointer, row any)

Fill writes the value for row into dst; nothing for a T of no size.

func (Template[T]) Resolve

func (t Template[T]) Resolve(row any) T

Resolve is the value for the entity row describes.

func (Template[T]) Row added in v0.2.0

func (t Template[T]) Row() reflect.Type

Row is the row type a Load reads, nil for a Const.

func (Template[T]) Type added in v0.2.0

func (t Template[T]) Type() reflect.Type

Type is T.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL