unregister uses g.children; add TODO in DrawDFS

This commit is contained in:
Josh Deprez 2021-09-29 20:46:49 +10:00
parent c23b149a84
commit db5a10a14b
2 changed files with 3 additions and 5 deletions

View file

@ -56,6 +56,7 @@ func (d *DrawDFS) drawRecursive(component interface{}, screen *ebiten.Image, opt
return
}
// Has subcomponents? recurse
// TODO: use g.Children or g.Query - but need to go in Scan order...
if sc, ok := component.(Scanner); ok {
sc.Scan(func(x interface{}) error {
d.drawRecursive(x, screen, opts)

View file

@ -348,11 +348,8 @@ func (g *Game) Unregister(component interface{}) {
}
func (g *Game) unregisterRecursive(component interface{}) {
if sc, ok := component.(Scanner); ok {
sc.Scan(func(x interface{}) error {
for x := range g.children[component] {
g.unregisterRecursive(x)
return nil
})
}
g.unregisterOne(component)
}