Prepare uses Query

This commit is contained in:
Josh Deprez 2021-09-29 14:19:48 +10:00
parent 052c79c904
commit 472af504e8

View file

@ -221,15 +221,9 @@ func (g *Game) Load(component interface{}, assets fs.FS) error {
func (g *Game) Prepare(component interface{}) error {
// Postorder traversal, in case ancestors depend on descendants being
// ready to answer queries.
if sc, ok := component.(Scanner); ok {
if err := sc.Scan(g.Prepare); err != nil {
return err
}
}
if p, ok := component.(Prepper); ok {
return p.Prepare(g)
}
return nil
return g.Query(component, PrepperType, nil, func(c interface{}) error {
return c.(Prepper).Prepare(g)
})
}
// LoadAndPrepare first calls Load on all Loaders. Once loading is complete, it