ecs

package
v0.0.0-...-bcaffd1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntitiesAddEvent

type EntitiesAddEvent []Entity

EntitiesAddEvent is triggered when entities are added

type EntitiesDestroyEvent

type EntitiesDestroyEvent []Entity

EntitiesDestroyEvent is triggered when entities are destroyed

type Entity

type Entity interface{}

Entity should be a struct of any kind

type Entry

type Entry struct {
	Type      reflect.Type
	Last      interface{}
	CallStart time.Time
	CallEnd   time.Time
	Handlers  []*Handler
}

Entry holds the list of handlers for a specific function signature

type Handler

type Handler struct {
	Desc      string
	CallStart time.Time
	CallEnd   time.Time
	Fn        interface{}
}

Handler holds the func callback and some extra fields for profiling

func (*Handler) Describe

func (h *Handler) Describe(v string) *Handler

Describe the handler for debug purposes

type Manager

type Manager struct {
	Messaging
}

Manager the root thing

func New

func New(fns ...SystemFunc) *Manager

New create a new ECS Manager

func (*Manager) Destroy

func (m *Manager) Destroy(e ...Entity)

Destroy an entity

func (*Manager) Entity

func (m *Manager) Entity(e ...Entity)

Entity adds an entity

func (*Manager) Start

func (m *Manager) Start()

Start thing

type Messaging

type Messaging struct {
	Entries map[reflect.Type]*Entry
}

Messaging thing

func (*Messaging) Handle

func (m *Messaging) Handle(fn interface{}) *Handler

Handle registers an handler for the fn input type and returns the registered handler the fn interface must be a function with 1 parameter and no returns (i.e: func(type))

func (*Messaging) Query

func (m *Messaging) Query(fn interface{})

Query will callback if the signature type has a message the fn interface must be a function with 1 parameter and no returns (i.e: func(type))

func (*Messaging) ReflAuto

func (m *Messaging) ReflAuto(s interface{})

ReflAuto registers func handelrs by checking Methods on a struct If method has Handler prefix it will register as an handler If method has Watch prefix it will register as a watcher

func (*Messaging) Trigger

func (m *Messaging) Trigger(v interface{})

Trigger will retrieve handlers for the specific signature type and call each one

XXX: Might be bad to hold a reference to last value while triggering since it can be a huge value, consider creating a new kind of Trigger method for this purpose like `Persist(v interface)`

func (*Messaging) Watch

func (m *Messaging) Watch(fn interface{}) *Handler

Watch registers an handle that triggers upon registration if there is a last message, it will return the registered handler the fn interface must be a function with 1 parameter and no returns (i.e: func(type))

type StartEvent

type StartEvent struct{}

StartEvent fired when things starts

type SystemFunc

type SystemFunc func(*Manager)

SystemFunc type of function to initialize a system

Jump to

Keyboard shortcuts

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