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