scv no more
This commit is contained in:
parent
d04cad7d73
commit
adf933f497
2 changed files with 9 additions and 11 deletions
|
@ -117,7 +117,7 @@ func (d *DrawDAG) Prepare(game *Game) error {
|
||||||
// Because Game.LoadAndPrepare calls Prepare in a post-order walk, all the
|
// Because Game.LoadAndPrepare calls Prepare in a post-order walk, all the
|
||||||
// descendants should be prepared, meaning BoundingBox (hence Register) is
|
// descendants should be prepared, meaning BoundingBox (hence Register) is
|
||||||
// likely to be a safe call.
|
// likely to be a safe call.
|
||||||
return d.Register(d, nil)
|
return d.Register(d.Child, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan visits d.Child.
|
// Scan visits d.Child.
|
||||||
|
@ -164,17 +164,17 @@ func (d *DrawDAG) Register(component, _ interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Register db, and then subcomponents recursively.
|
||||||
if db, ok := component.(DrawBoxer); ok {
|
if db, ok := component.(DrawBoxer); ok {
|
||||||
d.registerOne(db)
|
d.registerOne(db)
|
||||||
}
|
}
|
||||||
if _, ok := component.(DrawManager); ok && component != d {
|
if _, ok := component.(DrawManager); ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if sc, ok := component.(Scanner); ok {
|
if sc, ok := component.(Scanner); ok {
|
||||||
scv := func(x interface{}) error {
|
return sc.Scan(func(x interface{}) error {
|
||||||
return d.Register(x, nil)
|
return d.Register(x, nil)
|
||||||
}
|
})
|
||||||
return sc.Scan(scv)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -242,11 +242,10 @@ func (d *DrawDAG) Unregister(component interface{}) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if sc, ok := component.(Scanner); ok {
|
if sc, ok := component.(Scanner); ok {
|
||||||
scv := func(x interface{}) error {
|
sc.Scan(func(x interface{}) error {
|
||||||
d.Unregister(x)
|
d.Unregister(x)
|
||||||
return nil
|
return nil
|
||||||
}
|
})
|
||||||
sc.Scan(scv)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,10 @@ func (d *DrawDFS) draw(component interface{}, screen *ebiten.Image, opts ebiten.
|
||||||
}
|
}
|
||||||
// Has subcomponents? recurse
|
// Has subcomponents? recurse
|
||||||
if sc, ok := component.(Scanner); ok {
|
if sc, ok := component.(Scanner); ok {
|
||||||
scv := func(x interface{}) error {
|
sc.Scan(func(x interface{}) error {
|
||||||
d.draw(x, screen, opts)
|
d.draw(x, screen, opts)
|
||||||
return nil
|
return nil
|
||||||
}
|
})
|
||||||
sc.Scan(scv)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue