interface checks like this

This commit is contained in:
Josh Deprez 2021-08-27 11:49:11 +10:00
parent 3168c5eb54
commit 43eff6e326
10 changed files with 61 additions and 52 deletions

View file

@ -8,8 +8,10 @@ import (
var ( var (
animCache = make(map[assetKey]Anim) animCache = make(map[assetKey]Anim)
_ Animer = &AnimRef{} _ interface {
_ Loader = &AnimRef{} Animer
Loader
} = &AnimRef{}
) )
func init() { func init() {

View file

@ -8,13 +8,13 @@ import (
) )
// Ensure Billboard satisfies interfaces. // Ensure Billboard satisfies interfaces.
var ( var _ interface {
_ Identifier = &Billboard{} Identifier
_ Drawer = &Billboard{} Drawer
_ DrawOrderer = &Billboard{} DrawOrderer
_ ParallaxScaler = &Billboard{} ParallaxScaler
_ Scanner = &Billboard{} Scanner
) } = &Billboard{}
func init() { func init() {
gob.Register(&Billboard{}) gob.Register(&Billboard{})

View file

@ -8,13 +8,13 @@ import (
) )
// Ensure Camera satisfies interfaces. // Ensure Camera satisfies interfaces.
var ( var _ interface {
_ Identifier = &Camera{} Identifier
_ Drawer = &Camera{} Drawer
_ Prepper = &Camera{} Prepper
_ Scanner = &Camera{} Scanner
_ Updater = &Camera{} Updater
) } = &Camera{}
func init() { func init() {
gob.Register(&Camera{}) gob.Register(&Camera{})

View file

@ -9,11 +9,11 @@ import (
"github.com/hajimehoshi/ebiten/v2/ebitenutil" "github.com/hajimehoshi/ebiten/v2/ebitenutil"
) )
var ( var _ interface {
_ Drawer = PerfDisplay{} Drawer
_ DrawOrderer = PerfDisplay{} DrawOrderer
_ Hider = &PerfDisplay{} Hider
) } = &PerfDisplay{}
func init() { func init() {
gob.Register(&PerfDisplay{}) gob.Register(&PerfDisplay{})

View file

@ -8,7 +8,12 @@ import (
) )
// Ensure Fill satisfies Drawer. // Ensure Fill satisfies Drawer.
var _ Drawer = &Fill{} var _ interface {
Drawer
DrawOrderer
Hider
Identifier
} = &Fill{}
func init() { func init() {
gob.Register(Fill{}) gob.Register(Fill{})

View file

@ -10,10 +10,10 @@ import (
) )
// Ensure SceneRef satisfies interfaces. // Ensure SceneRef satisfies interfaces.
var ( var _ interface {
_ Loader = &SceneRef{} Loader
_ Scener = &SceneRef{} Scener
) } = &SceneRef{}
func init() { func init() {
gob.Register(SceneRef{}) gob.Register(SceneRef{})

View file

@ -6,10 +6,10 @@ import (
"github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2"
) )
var ( var _ interface {
_ Prepper = &Sheet{} Prepper
_ Scanner = &Sheet{} Scanner
) } = &Sheet{}
// Sheet handles images that consist of a grid of equally sized regions // Sheet handles images that consist of a grid of equally sized regions
// (cells) and can produce subimages for the cell at an index. This is useful // (cells) and can produce subimages for the cell at an index. This is useful

View file

@ -8,13 +8,13 @@ import (
) )
// Ensure Sprite satisfies interfaces. // Ensure Sprite satisfies interfaces.
var ( var _ interface {
_ Identifier = &Sprite{} Identifier
_ Drawer = &Sprite{} Drawer
_ DrawOrderer = &Sprite{} DrawOrderer
_ Scanner = &Sprite{} Scanner
_ Updater = &Sprite{} Updater
) } = &Sprite{}
func init() { func init() {
gob.Register(&Sprite{}) gob.Register(&Sprite{})

View file

@ -8,14 +8,23 @@ import (
) )
// Ensure Tilemap satisfies interfaces. // Ensure Tilemap satisfies interfaces.
var _ interface {
Identifier
Collider
Drawer
DrawOrderer
Hider
Scanner
Updater
} = &Tilemap{}
// Ensure StaticTile and AnimatedTile satisfy Tile.
var ( var (
_ Identifier = &Tilemap{} _ Tile = StaticTile(0)
_ Collider = &Tilemap{} _ interface {
_ Drawer = &Tilemap{} Tile
_ DrawOrderer = &Tilemap{} Scanner
_ Hider = &Tilemap{} } = AnimatedTile{}
_ Scanner = &Tilemap{}
_ Updater = &Tilemap{}
) )
func init() { func init() {
@ -125,13 +134,6 @@ type Tile interface {
CellIndex() int CellIndex() int
} }
// Ensure StaticTile and AnimatedTile satisfy Tile.
var (
_ Tile = StaticTile(0)
_ Tile = AnimatedTile{}
_ Scanner = AnimatedTile{}
)
// StaticTile returns a fixed tile index. // StaticTile returns a fixed tile index.
type StaticTile int type StaticTile int

View file

@ -29,7 +29,7 @@ var (
// But Wall is still responsible for collisions. // But Wall is still responsible for collisions.
type Wall struct { type Wall struct {
ID ID
Ersatz bool Ersatz bool // fake wall - disables collisions
Offset image.Point // offset the whole wall Offset image.Point // offset the whole wall
Sheet Sheet Sheet Sheet
UnitOffset image.Point // drawing offset UnitOffset image.Point // drawing offset