entity

package module
v0.0.0-...-509d0e5 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2018 License: MIT Imports: 2 Imported by: 16

README

entity

Coverage Status GoDoc

Entity is a simple, idiomatic library for using an entity-component-system in Go. This lirbary draws inspiration from EngoEngine/ecs but with a more streamlined implementation.

Introduction to Entity Component Systems

An Entity-Component-System (abbreviated ECS) is a common development pattern in game development that takes advantage of common features of games, such as repeated behaviors that are exhibited in multiple 'entities.' Within an ECS, an entity is typically no more than a mere identifier.

TODO: finish.

Getting Started

To use entity, first run go get github.com/20zinnm/entity.

See my game, spac, for example usage.

TODO: examples in README.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RemoveBuffer = 64
)

Functions

This section is empty.

Types

type ID

type ID = uint64

ID represents an identifier for a unique entity in a manager. It is aliased to uint64 to provide compile-time optimization and to reduce the number of type casts necessary when, for example, serializing it.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager ties together entities and systems.

func NewManager

func NewManager() *Manager

func (*Manager) AddSystem

func (m *Manager) AddSystem(system System)

AddSystem adds a system to the manager to be executed on subsequent calls to update. Systems are executed in the order in which they are added.

func (*Manager) Destroy

func (m *Manager) Destroy()

func (*Manager) NewEntity

func (m *Manager) NewEntity() ID

NewEntity creates a new entity. Entity identifiers begin at 1.

func (*Manager) Remove

func (m *Manager) Remove(entity ID)

Remove marks an ID for removal from all systems.

func (*Manager) RemoveSystem

func (m *Manager) RemoveSystem(system System)

RemoveSystem removes a system from the manager. It will not execute during the next call to update.

func (*Manager) Systems

func (m *Manager) Systems() (systems []System)

Systems returns all added systems in the order in which they are executed.

func (*Manager) Update

func (m *Manager) Update(delta float64)

Update executes system updates.

type System

type System interface {
	Update(delta float64)
	Remove(entity ID)
}

System represents a process that executes every tick and deals with game state. Systems are responsible for keeping track of entity data and ensuring that Remove and Update can be called concurrently. This is usually accomplished through the use of a mutex.

Jump to

Keyboard shortcuts

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