Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component[T any] struct { // contains filtered or unexported fields }
Component is a unique identifer for a component type.
func Query ¶
Query returns the component by generic type in the world. The type must have already been registered with Register.
func Register ¶
Register allocates a table with capacity for (size) components in the world. Subsequent calls to Register will panic if it was already called once, or there are too many component types registered.
type ComponentKind ¶
type ComponentKind interface {
// contains filtered or unexported methods
}
ComponentKind represents a specific kind of component in a world.
type Entity ¶
type Entity struct {
// contains filtered or unexported fields
}
Entity is a unique identifer for a game object, which zero or more components are associated with in a world.
type Event ¶
type Event[T any] struct { // contains filtered or unexported fields }
Event is a notification channel of T.
func (*Event[T]) Close ¶
func (e *Event[T]) Close()
Close closes the event channel. No event methods should be called after this.
type Renderer ¶
type Renderer interface {
Render(w *World, i *ebiten.Image)
}
Renderer is an opaque state that renders entities to the screen.
type Scene ¶
type Scene interface {
Setup() *World
}
Scene creates and initializes a world by spawning entities, registering components, and systems.
type Table ¶
type Table[T any] struct { // contains filtered or unexported fields }
Table is a map of entities to indices into a dense slice of components of type T. It allows fast insertion and removal, but the order of components are not guaranteed.
func (*Table[T]) Delete ¶
Delete removes the component by entity, swapping the index of the last element in place.
type View ¶
type View struct {
// contains filtered or unexported fields
}
View is a cached query that can be used by systems to search for entities with specific components.
func NewView ¶
func NewView(w *World, components ...ComponentKind) *View
NewView creates a new view with the signatures of the components.
type World ¶
type World struct {
// contains filtered or unexported fields
}
World is the container of all data related to entities, components and systems.
func (*World) Draw ¶
func (w *World) Draw(screen *ebiten.Image)
Draw renders all renderers to the screen in the order they were registered. This implements the ebiten.Game interface.
func (*World) Register ¶
Register adds the systems to the world. A System may optionally implement Renderer, whose Render method is called when drawing to the screen.