v0.0.0-...-47a16e8 Latest Latest

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

Go to latest
Published: Mar 30, 2023 License: GPL-3.0 Imports: 2 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Children

type Children struct {
	Value []Entity

Children allows hierarchical relationships between entities. Some Entities have Children.

func (*Children) Type

func (*Children) Type() string

Type of this Component.

type Component

type Component interface {
	Type() string

Component is a thing that stores data and can be interacted with by a System.

type Entity

type Entity int64

Entity identifies entities

func Must

func Must(e Entity, ok bool) Entity

Must returns the Entity when ok is true, otherwise it will panic.

type Expiry

type Expiry struct {
	Remaining time.Duration

Expiry is a Component that destroys the Entity after the configured duration has elapsed.

func (*Expiry) Type

func (*Expiry) Type() string

Type of this component.

type ExpirySystem

type ExpirySystem struct {
	// contains filtered or unexported fields

ExpirySystem destroys Entities that have expired.

func NewExpirySystem

func NewExpirySystem(mgr *World) *ExpirySystem

NewExpirySystem constructs a new expiry system.

func (*ExpirySystem) Update

func (es *ExpirySystem) Update(elapsed time.Duration)

Update the ExpirySystem.

type ParentSystem

type ParentSystem struct {
	// contains filtered or unexported fields

ParentSystem manages Parent Components.

func NewParentSystem

func NewParentSystem(mgr *World) *ParentSystem

NewParentSystem constructs a new ParentSystem.

func (*ParentSystem) Update

func (s *ParentSystem) Update()

Update the ParentSystem.

type Tags

type Tags []string

Tags is a Component that represents arbitrary strings that are related to an Entity.

func (*Tags) Type

func (*Tags) Type() string

Type of this Component.

type World

type World struct {
	// contains filtered or unexported fields

World is an instance of an Entity Component System.

func NewWorld

func NewWorld() *World

NewWorld creates an Entity Component System World.

func (*World) AddComponent

func (mgr *World) AddComponent(e Entity, c Component)

AddComponent to Entity.

func (*World) AnyTagged

func (mgr *World) AnyTagged(tag string) Entity

AnyTagged returns any Entity tagged with tag. It returns 0 when there are no Entities tagged with tag.

func (*World) Clear

func (mgr *World) Clear()

Clear all Entities and their Components from the World, resetting it to an empty state.

func (*World) Component

func (mgr *World) Component(e Entity, t string) Component

Component retrieves the Component of Type t for Entity.

func (*World) Dependency

func (mgr *World) Dependency(parent, child Entity)

Dependency adds a cascading destroy rule for a pair of Entities. When parent is destroyed, then child is also destroyed.

func (*World) DestroyEntity

func (mgr *World) DestroyEntity(e Entity)

DestroyEntity removes an Entity and all its Components.

func (*World) Exists

func (mgr *World) Exists(e Entity) bool

Exists returns whether an entity exists in this World.

func (*World) Get

func (mgr *World) Get(types []string) []Entity

Get returns the list of entities that have all of the provided types.

func (*World) HasTag

func (mgr *World) HasTag(e Entity, tag string) bool

HasTag returns whether an Entity has the passed tag.

func (*World) Len

func (mgr *World) Len() int

Len returns the number of Entites currently in the world.

func (*World) ListComponents

func (mgr *World) ListComponents(e Entity) []string

ListComponents returns the Component types that are present on the Entity.

func (*World) NewEntity

func (mgr *World) NewEntity() Entity

NewEntity creates an Entity

func (*World) RemoveComponent

func (mgr *World) RemoveComponent(e Entity, c Component)

RemoveComponent from an Entity.

func (*World) RemoveTag

func (mgr *World) RemoveTag(e Entity, tag string)

RemoveTag from the Entity.

func (*World) RemoveType

func (mgr *World) RemoveType(e Entity, t string)

RemoveType removes the Component of Type t from Entity e.

func (*World) Single

func (mgr *World) Single(types []string) (Entity, bool)

Single Entity that has all Components specified by types. Returns the Entity and a boolean indicating whether there was exactly one Entity that satisfies all types. When the second return value is false, the Entity returned is not valid.

func (*World) Tag

func (mgr *World) Tag(e Entity, tag string)

Tag an Entity with an arbitrary string.

func (*World) Tagged

func (mgr *World) Tagged(tag string) []Entity

Tagged returns all Entities tagged with tag.

Jump to

Keyboard shortcuts

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