ecs

package
v0.0.0-...-ea360a7 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component interface {
}

Component specifies the interface that every component should follow.

type ComponentHandler

type ComponentHandler interface {
	Add(comp Component)
	Remove(comp Component)
	Get(comp Component) (Component, bool)
	Has(comp Component) bool
}

ComponentHandler specifies what objects can handle a list of components.

type Entity

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

Entity defines the entity in the entity component system.

func NewEntity

func NewEntity(x, y float64, w, h int32) *Entity

NewEntity creates a new entity with a unique identifier.

func (*Entity) Add

func (e *Entity) Add(comp Component) *Entity

Add a component to the entity.

func (Entity) Get

func (e Entity) Get(comp string) (Component, bool)

Get the component that you want, returns (component, ok)

func (Entity) H

func (e Entity) H() int32

H returns the height of the entity.

func (Entity) Has

func (e Entity) Has(comp string) bool

Has the entity a specific component?

func (Entity) ID

func (e Entity) ID() uint64

ID returns the unique id of the entity. (identifier interface)

func (*Entity) Rect

func (e *Entity) Rect() sdl.Rect

Rect returns a (SDL) rectangle that defines this entity.

func (*Entity) Remove

func (e *Entity) Remove(comp string)

Remove a component from the entity.

func (*Entity) SetH

func (e *Entity) SetH(n int32)

SetH sets the height of the entity.

func (*Entity) SetW

func (e *Entity) SetW(n int32)

SetW sets the width of the entity.

func (*Entity) SetX

func (e *Entity) SetX(n float64)

SetX sets the x value of the entity.

func (*Entity) SetY

func (e *Entity) SetY(n float64)

SetY sets the y value of the entity.

func (*Entity) SetZ

func (e *Entity) SetZ(n int32)

SetZ sets the z value of the entity.

func (Entity) W

func (e Entity) W() int32

W returns the width of the entity.

func (Entity) X

func (e Entity) X() float64

X returns the x value of the entity.

func (Entity) Y

func (e Entity) Y() float64

Y returns the y value of the entity.

func (Entity) Z

func (e Entity) Z() int32

Z returns the z value of the entity.

type EntityManager

type EntityManager interface {
	Add(entity Entity, systemIDs ...string)
	Delete(id uint64, systemIDs ...string)
	Get(id uint64) Entity
	HandleMessage(msg Message, data interface{}) interface{}
}

EntityManager defines the interface for an entitymanager.

type GameInterface

type GameInterface interface {
	Update(dt float64)
	Render(lag float64)
	IsRunning() bool
	SetRunning(state bool)
	ToggleFullscreen()
	HandleMessage(msg Message, data interface{}) interface{}
}

GameInterface defines the interface that every game should follow. Mostly used to decouple stuff so I can cyclic import :)

type Identifier

type Identifier interface {
	ID() uint64
}

Identifier specifies something that can be uniquely identified.

type Message

type Message int64

Message defines the type used for the Message enum

type Priority

type Priority interface {
	Priority() uint
}

Priority implies that some things are more important than others.

type System

type System interface {
	Init(mngr *SystemManager)
	Update(dt float64)
	HandleMessage(msg Message, data interface{}) interface{}
}

System specifies a system.

type SystemManager

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

SystemManager manages all the systems.

func NewSystemManager

func NewSystemManager(game GameInterface) *SystemManager

NewSystemManager makes a new system manager.

func (*SystemManager) AddSystem

func (mngr *SystemManager) AddSystem(s System, t SystemType)

AddSystem adds a system to the manager and sorts the list based on priority.

func (*SystemManager) AllSystems

func (mngr *SystemManager) AllSystems() []System

AllSystems returns ALL the systems that this manager manages.

func (*SystemManager) BeforeUpdate

func (mngr *SystemManager) BeforeUpdate(dt float64)

BeforeUpdate goes through the sorted list and updates all the systems.

func (SystemManager) GetEntityManager

func (mngr SystemManager) GetEntityManager() *EntityManager

GetEntityManager returns the entitymanager.

func (*SystemManager) Render

func (mngr *SystemManager) Render(lag float64)

Render goes through the sorted list and renders all the systems.

func (*SystemManager) SendMessage

func (mngr *SystemManager) SendMessage(
	msg Message, data interface{}) (interface{}, error)

SendMessage sends a message to all systems, entityManager and Game.

func (*SystemManager) SetEntityManager

func (mngr *SystemManager) SetEntityManager(em EntityManager)

SetEntityManager sets the entitymanager.

func (*SystemManager) Systems

func (mngr *SystemManager) Systems(t SystemType) []System

Systems returns the systems that this manager manages.

func (*SystemManager) Update

func (mngr *SystemManager) Update(dt float64)

Update goes through the sorted list and updates all the systems.

type SystemType

type SystemType int

SystemType defines the type used for the SystemType enum

const (
	STypeBeforeUpdate SystemType = iota
	STypeUpdate
	STypeRender
	STypeCount
)

The SystemType enum

Jump to

Keyboard shortcuts

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