no more draworderer

This commit is contained in:
Josh Deprez 2021-08-28 17:50:54 +10:00
parent 0e64c4a994
commit 6f3c6c88c0
10 changed files with 8 additions and 19 deletions

View file

@ -11,7 +11,6 @@ import (
var _ interface {
Identifier
Drawer
DrawOrderer
ParallaxScaler
Scanner
} = &Billboard{}

View file

@ -35,7 +35,7 @@ type Camera struct {
game *Game
}
// Draw applies transformations to opts, then calls c.Scene.Draw with it.
// Draw applies transformations to opts, then draws the contents of c.Scene.
func (c *Camera) Draw(screen *ebiten.Image, opts ebiten.DrawImageOptions) {
if c.Scene.IsHidden() {
return
@ -104,6 +104,9 @@ func (c *Camera) Draw(screen *ebiten.Image, opts ebiten.DrawImageOptions) {
}
}
// DrawOrder passes the call to c.Scene.
func (c *Camera) DrawOrder() float64 { return c.Scene.DrawOrder() }
// Update passes the call to c.Scene.
func (c *Camera) Update() error { return c.Scene.Update() }

View file

@ -12,7 +12,6 @@ import (
var _ interface {
Drawer
DrawOrderer
Hider
} = &PerfDisplay{}

View file

@ -10,7 +10,6 @@ import (
// Ensure Fill satisfies Drawer.
var _ interface {
Drawer
DrawOrderer
Hider
Identifier
} = &Fill{}

View file

@ -17,7 +17,6 @@ var (
ColliderType = reflect.TypeOf((*Collider)(nil)).Elem()
DisablerType = reflect.TypeOf((*Disabler)(nil)).Elem()
DrawerType = reflect.TypeOf((*Drawer)(nil)).Elem()
DrawOrdererType = reflect.TypeOf((*DrawOrderer)(nil)).Elem()
DrawUpdaterType = reflect.TypeOf((*DrawUpdater)(nil)).Elem()
HiderType = reflect.TypeOf((*Hider)(nil)).Elem()
IdentifierType = reflect.TypeOf((*Identifier)(nil)).Elem()
@ -36,7 +35,6 @@ var (
ColliderType,
DisablerType,
DrawerType,
DrawOrdererType,
DrawUpdaterType,
HiderType,
IdentifierType,
@ -80,10 +78,6 @@ type Disabler interface {
// (so that hiding the parent can hide the children, etc).
type Drawer interface {
Draw(screen *ebiten.Image, opts ebiten.DrawImageOptions)
}
// DrawOrderer components can provide a number for determining draw order.
type DrawOrderer interface {
DrawOrder() float64
}
@ -148,7 +142,6 @@ type Scener interface {
Bounder
Disabler
Drawer
DrawOrderer
Hider
Identifier
Prepper

View file

@ -49,8 +49,8 @@ func (s *Scene) Prepare(game *Game) error {
// (among layers without a Z, or those with equal Z).
func (s *Scene) sortByDrawOrder() {
sort.SliceStable(s.Components, func(i, j int) bool {
a, aok := s.Components[i].(DrawOrderer)
b, bok := s.Components[j].(DrawOrderer)
a, aok := s.Components[i].(Drawer)
b, bok := s.Components[j].(Drawer)
if aok && bok {
return a.DrawOrder() < b.DrawOrder()
}
@ -81,7 +81,7 @@ func (s *Scene) Update() error {
// Check if the updates put the components out of order; if so, sort
cz := -math.MaxFloat64 // fun fact: this is min float64
for _, c := range s.Components {
z, ok := c.(DrawOrderer)
z, ok := c.(Drawer)
if !ok {
continue
}

View file

@ -11,7 +11,6 @@ import (
var _ interface {
Identifier
Drawer
DrawOrderer
Scanner
Updater
} = &Sprite{}

View file

@ -12,7 +12,6 @@ var _ interface {
Identifier
Collider
Drawer
DrawOrderer
Hider
Scanner
Updater

View file

@ -15,7 +15,6 @@ var (
_ interface {
Drawer
DrawOrderer
Disabler
Hider
Prepper

View file

@ -13,7 +13,6 @@ import (
var _ interface {
engine.Identifier
engine.Drawer // provided by Sprite
engine.DrawOrderer // provided by Sprite
engine.Disabler
engine.Hider // provided by Sprite
engine.Prepper