comp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 5 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; the store spawns through a Comp's Spawner.

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.

func RowOf

func RowOf(c Comp) reflect.Type

RowOf is the row type a Load reads, nil for a component that reads none.

func TypeOf

func TypeOf(c Comp) reflect.Type

TypeOf is the component type c stands for.

Types

type Comp

type Comp interface {
	Spawner() Spawner
	LoadToken() goke.CompToken
	// contains filtered or unexported methods
}

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 world'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 Spawner

type Spawner interface {
	Columns() []goke.Addable
	Write(cursor *goke.Cursor, i int, row any, id uid.UID64)
}

Spawner writes one component onto the entities a world spawns — what a world asks a Comp for.

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]) LoadToken

func (t Template[T]) LoadToken() goke.CompToken

LoadToken names T to a save file being loaded.

func (Template[T]) Resolve

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

Resolve is the value for the entity row describes.

func (Template[T]) Spawner

func (t Template[T]) Spawner() Spawner

Spawner is this component's column and the writing of it.

Jump to

Keyboard shortcuts

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