Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEngine ¶
func NewEngine(entityManager *EntityManager, systemManager *SystemManager) *engine
NewEngine creates a new Engine and returns its address.
Types ¶
type Component ¶
type Component interface {
Name() (name string)
}
Component contains only the data (no behaviour at all). The Name() method must be implemented, because the EntityManager uses it to filter the entities by component names.
type EntityManager ¶
type EntityManager struct {
// contains filtered or unexported fields
}
EntityManager handles the access to each entity.
func NewEntityManager ¶
func NewEntityManager() *EntityManager
NewEntityManager creates a new EntityManager and returns its address.
func (*EntityManager) Add ¶
func (m *EntityManager) Add(entities ...*Entity)
Add entries to the manager.
func (*EntityManager) Entities ¶
func (m *EntityManager) Entities() (entities []*Entity)
Entities returns all the entities.
func (*EntityManager) FilterBy ¶
func (m *EntityManager) FilterBy(components ...string) (entities []*Entity)
FilterBy returns the mapped entities, which components name matched.
func (*EntityManager) Get ¶
func (m *EntityManager) Get(id string) (entity *Entity)
Get a specific entity by id.
func (*EntityManager) Remove ¶
func (m *EntityManager) Remove(entity *Entity)
Remove a specific entity.
type System ¶
type System interface { Setup() Process(entityManager *EntityManager) Teardown() }
System implements the behaviour of an entity by modifying the state, which is stored in each component of the entity.
type SystemManager ¶
type SystemManager struct {
// contains filtered or unexported fields
}
SystemManager handles the access to each system.
func NewSystemManager ¶
func NewSystemManager() *SystemManager
NewSystemManager creates a new SystemManager and returns its address.
func (*SystemManager) Add ¶
func (m *SystemManager) Add(systems ...System)
Add systems to the SystemManager.
func (*SystemManager) Systems ¶
func (m *SystemManager) Systems() []System
Systems returns the system, which are internally stored.