Documentation ¶
Index ¶
- func Destroy(o interface{})
- func NewEntity() *entity
- type Component
- type Destructible
- type Entity
- type Manager
- type Query
- type System
- type World
- func (w *World) AddEntity(entity Entity)
- func (w *World) AddSystem(system System)
- func (w *World) Entities(componentTypes uint32) []Entity
- func (w *World) EntitiesByID(ids ...uint64) []Entity
- func (w *World) EntityByID(id uint64) Entity
- func (w *World) ForAllEntities(componentTypes uint32, f func(e Entity) bool)
- func (w *World) RemoveEntity(target Entity) Entity
- func (w *World) RemoveEntityByID(id uint64) Entity
- func (w *World) RemoveSystem(systemType uint32) System
- func (w *World) System(systemType uint32) System
- func (w *World) Update(stage int, delta time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Component ¶
type Component interface {
ComponentType() uint32
}
Component represents the abstract version of data. each component will associate with a meaningful data. because of underneath structure, we can have upto 32 components in total per game. hope that enough...
type Destructible ¶
type Destructible interface {
Destroy()
}
Destructible defines a component or entity that needs cleanup.
type Entity ¶
type Entity interface { ID() uint64 Component(typ uint32) Component Components() []Component AddComponent(component Component) RemoveComponent(componentType uint32) Component HasComponentTypes(componentTypes uint32) bool }
Entity is a shell around multiple components. components can be added or removed from entity either at runtime or compile time.
type Manager ¶
type Manager interface { AddSystem(system System) RemoveSystem(systemType uint32) System Update(stage int, delta time.Duration) }
Manager is a simple abstraction of minimum requirement of method which needed for any game.
type Query ¶
type Query interface { Entities(componentTypes uint32) []Entity ForAllEntities(componentTypes uint32, f func(e Entity) bool) EntityByID(id uint64) Entity EntitiesByID(ids ...uint64) []Entity AddEntity(Entity) RemoveEntity(Entity) Entity RemoveEntityByID(id uint64) Entity System(systemType uint32) System }
Query is a bridge between System and Entity. query can be used to fetch array of entities based on the data that they have or accessing an already exist system.
type System ¶
type System interface { SystemType() uint32 Active(stage int) bool Update(delta time.Duration, query Query) }
System contains all the methods which will needed for hopfully all the scenarioes. There is an Update method that is being called by World and was given a Query object for manipulating entities.
type World ¶
type World struct {
// contains filtered or unexported fields
}