Documentation ¶
Index ¶
- type Children
- type Component
- type Entity
- type Expiry
- type ExpirySystem
- type ParentSystem
- type Tags
- type World
- func (mgr *World) AddComponent(e Entity, c Component)
- func (mgr *World) AnyTagged(tag string) Entity
- func (mgr *World) Clear()
- func (mgr *World) Component(e Entity, t string) Component
- func (mgr *World) Dependency(parent, child Entity)
- func (mgr *World) DestroyEntity(e Entity)
- func (mgr *World) Exists(e Entity) bool
- func (mgr *World) Get(types []string) []Entity
- func (mgr *World) HasTag(e Entity, tag string) bool
- func (mgr *World) Len() int
- func (mgr *World) ListComponents(e Entity) []string
- func (mgr *World) NewEntity() Entity
- func (mgr *World) RemoveComponent(e Entity, c Component)
- func (mgr *World) RemoveTag(e Entity, tag string)
- func (mgr *World) RemoveType(e Entity, t string)
- func (mgr *World) Single(types []string) (Entity, bool)
- func (mgr *World) Tag(e Entity, tag string)
- func (mgr *World) Tagged(tag string) []Entity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Children ¶
type Children struct {
Value []Entity
}
Children allows hierarchical relationships between entities. Some Entities have Children.
type Component ¶
type Component interface {
Type() string
}
Component is a thing that stores data and can be interacted with by a System.
type Expiry ¶
Expiry is a Component that destroys the Entity after the configured duration has elapsed.
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.
type Tags ¶
type Tags []string
Tags is a Component that represents arbitrary strings that are related to an Entity.
type World ¶
type World struct {
// contains filtered or unexported fields
}
World is an instance of an Entity Component System.
func (*World) AddComponent ¶
AddComponent to Entity.
func (*World) AnyTagged ¶
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) Dependency ¶
Dependency adds a cascading destroy rule for a pair of Entities. When parent is destroyed, then child is also destroyed.
func (*World) DestroyEntity ¶
DestroyEntity removes an Entity and all its Components.
func (*World) ListComponents ¶
ListComponents returns the Component types that are present on the Entity.
func (*World) RemoveComponent ¶
RemoveComponent from an Entity.
func (*World) RemoveType ¶
RemoveType removes the Component of Type t from Entity e.
func (*World) Single ¶
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.