Entity Component System framework for Ebiten
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.3 KiB

package gohan
import (
"errors"
"github.com/hajimehoshi/ebiten/v2"
)
// System represents a system that runs continuously. While the system must
// implement the Update and Draw methods, a special error value may be returned
// indicating that the system does not utilize one of the methods. System
// methods which return one of these special error values will not be called again.
//
// See ErrSystemWithoutUpdate and ErrSystemWithoutDraw.
type System interface {
// Name returns the name of the system.
//Name() string
// Components returns a list of Components (specified by ID) required for
// an Entity to be handled by the System.
Components() []ComponentID
// Update is called once for each matching entity each time the game state is updated.
Update(ctx *Context) error
// Draw is called once for each matching entity each time the game is drawn to the screen.
Draw(ctx *Context, screen *ebiten.Image) error
}
// Special error values.
var (
// ErrSystemWithoutUpdate is the error returned when a System does not implement Update.
ErrSystemWithoutUpdate = errors.New("system does not implement update")
// ErrSystemWithoutDraw is the error returned when a System does not implement Draw.
ErrSystemWithoutDraw = errors.New("system does not implement draw")
)