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 { func (g *Game) Prepare(component interface{}) error {
// Postorder traversal, in case ancestors depend on descendants being // Postorder traversal, in case ancestors depend on descendants being
// ready to answer queries. // ready to answer queries.
if sc, ok := component.(Scanner); ok { return g.Query(component, PrepperType, nil, func(c interface{}) error {
if err := sc.Scan(g.Prepare); err != nil { return c.(Prepper).Prepare(g)
return err })
}
}
if p, ok := component.(Prepper); ok {
return p.Prepare(g)
}
return nil
} }
// LoadAndPrepare first calls Load on all Loaders. Once loading is complete, it // LoadAndPrepare first calls Load on all Loaders. Once loading is complete, it