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 { // Matches returns whether the provided entity is handled by this system. Matches(entity Entity) bool // Update is called once for each matching entity each time the game state is updated. Update(entity Entity) error // Draw is called once for each matching entity each time the game is drawn to the screen. Draw(entity Entity, 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") )