interface checks like this
This commit is contained in:
parent
3168c5eb54
commit
43eff6e326
10 changed files with 61 additions and 52 deletions
|
@ -8,8 +8,10 @@ import (
|
|||
var (
|
||||
animCache = make(map[assetKey]Anim)
|
||||
|
||||
_ Animer = &AnimRef{}
|
||||
_ Loader = &AnimRef{}
|
||||
_ interface {
|
||||
Animer
|
||||
Loader
|
||||
} = &AnimRef{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -8,13 +8,13 @@ import (
|
|||
)
|
||||
|
||||
// Ensure Billboard satisfies interfaces.
|
||||
var (
|
||||
_ Identifier = &Billboard{}
|
||||
_ Drawer = &Billboard{}
|
||||
_ DrawOrderer = &Billboard{}
|
||||
_ ParallaxScaler = &Billboard{}
|
||||
_ Scanner = &Billboard{}
|
||||
)
|
||||
var _ interface {
|
||||
Identifier
|
||||
Drawer
|
||||
DrawOrderer
|
||||
ParallaxScaler
|
||||
Scanner
|
||||
} = &Billboard{}
|
||||
|
||||
func init() {
|
||||
gob.Register(&Billboard{})
|
||||
|
|
|
@ -8,13 +8,13 @@ import (
|
|||
)
|
||||
|
||||
// Ensure Camera satisfies interfaces.
|
||||
var (
|
||||
_ Identifier = &Camera{}
|
||||
_ Drawer = &Camera{}
|
||||
_ Prepper = &Camera{}
|
||||
_ Scanner = &Camera{}
|
||||
_ Updater = &Camera{}
|
||||
)
|
||||
var _ interface {
|
||||
Identifier
|
||||
Drawer
|
||||
Prepper
|
||||
Scanner
|
||||
Updater
|
||||
} = &Camera{}
|
||||
|
||||
func init() {
|
||||
gob.Register(&Camera{})
|
||||
|
|
|
@ -9,11 +9,11 @@ import (
|
|||
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
||||
)
|
||||
|
||||
var (
|
||||
_ Drawer = PerfDisplay{}
|
||||
_ DrawOrderer = PerfDisplay{}
|
||||
_ Hider = &PerfDisplay{}
|
||||
)
|
||||
var _ interface {
|
||||
Drawer
|
||||
DrawOrderer
|
||||
Hider
|
||||
} = &PerfDisplay{}
|
||||
|
||||
func init() {
|
||||
gob.Register(&PerfDisplay{})
|
||||
|
|
|
@ -8,7 +8,12 @@ import (
|
|||
)
|
||||
|
||||
// Ensure Fill satisfies Drawer.
|
||||
var _ Drawer = &Fill{}
|
||||
var _ interface {
|
||||
Drawer
|
||||
DrawOrderer
|
||||
Hider
|
||||
Identifier
|
||||
} = &Fill{}
|
||||
|
||||
func init() {
|
||||
gob.Register(Fill{})
|
||||
|
|
|
@ -10,10 +10,10 @@ import (
|
|||
)
|
||||
|
||||
// Ensure SceneRef satisfies interfaces.
|
||||
var (
|
||||
_ Loader = &SceneRef{}
|
||||
_ Scener = &SceneRef{}
|
||||
)
|
||||
var _ interface {
|
||||
Loader
|
||||
Scener
|
||||
} = &SceneRef{}
|
||||
|
||||
func init() {
|
||||
gob.Register(SceneRef{})
|
||||
|
|
|
@ -6,10 +6,10 @@ import (
|
|||
"github.com/hajimehoshi/ebiten/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
_ Prepper = &Sheet{}
|
||||
_ Scanner = &Sheet{}
|
||||
)
|
||||
var _ interface {
|
||||
Prepper
|
||||
Scanner
|
||||
} = &Sheet{}
|
||||
|
||||
// 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
|
||||
|
|
|
@ -8,13 +8,13 @@ import (
|
|||
)
|
||||
|
||||
// Ensure Sprite satisfies interfaces.
|
||||
var (
|
||||
_ Identifier = &Sprite{}
|
||||
_ Drawer = &Sprite{}
|
||||
_ DrawOrderer = &Sprite{}
|
||||
_ Scanner = &Sprite{}
|
||||
_ Updater = &Sprite{}
|
||||
)
|
||||
var _ interface {
|
||||
Identifier
|
||||
Drawer
|
||||
DrawOrderer
|
||||
Scanner
|
||||
Updater
|
||||
} = &Sprite{}
|
||||
|
||||
func init() {
|
||||
gob.Register(&Sprite{})
|
||||
|
|
|
@ -8,14 +8,23 @@ import (
|
|||
)
|
||||
|
||||
// Ensure Tilemap satisfies interfaces.
|
||||
var _ interface {
|
||||
Identifier
|
||||
Collider
|
||||
Drawer
|
||||
DrawOrderer
|
||||
Hider
|
||||
Scanner
|
||||
Updater
|
||||
} = &Tilemap{}
|
||||
|
||||
// Ensure StaticTile and AnimatedTile satisfy Tile.
|
||||
var (
|
||||
_ Identifier = &Tilemap{}
|
||||
_ Collider = &Tilemap{}
|
||||
_ Drawer = &Tilemap{}
|
||||
_ DrawOrderer = &Tilemap{}
|
||||
_ Hider = &Tilemap{}
|
||||
_ Scanner = &Tilemap{}
|
||||
_ Updater = &Tilemap{}
|
||||
_ Tile = StaticTile(0)
|
||||
_ interface {
|
||||
Tile
|
||||
Scanner
|
||||
} = AnimatedTile{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -125,13 +134,6 @@ type Tile interface {
|
|||
CellIndex() int
|
||||
}
|
||||
|
||||
// Ensure StaticTile and AnimatedTile satisfy Tile.
|
||||
var (
|
||||
_ Tile = StaticTile(0)
|
||||
_ Tile = AnimatedTile{}
|
||||
_ Scanner = AnimatedTile{}
|
||||
)
|
||||
|
||||
// StaticTile returns a fixed tile index.
|
||||
type StaticTile int
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ var (
|
|||
// But Wall is still responsible for collisions.
|
||||
type Wall struct {
|
||||
ID
|
||||
Ersatz bool
|
||||
Ersatz bool // fake wall - disables collisions
|
||||
Offset image.Point // offset the whole wall
|
||||
Sheet Sheet
|
||||
UnitOffset image.Point // drawing offset
|
||||
|
|
Loading…
Reference in a new issue