ecs

package
v0.0.10-0...-c37c0d3 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2019 License: MIT Imports: 0 Imported by: 0

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 Entity

type Entity struct {
	Components []Component
	Id         string
}

Entity is simply a composition of one or more components with an id.

func (*Entity) Get

func (e *Entity) Get(name string) Component

Get a specific component by name.

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.

Jump to

Keyboard shortcuts

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