Documentation
¶
Overview ¶
Package resolver connects Game Object data to the asset system. Its Resolver implements god.AssetResolver on top of an asset.Server, so god.Deserialize can turn the asset keys of a prefab or level ("chars/hero.aseprite.json#run") into the handles components hold, and god.SerializeComponents can turn them back.
Wiring:
res := resolver.New(srv) res.SetScope(levelScope) // loads of Deserialize are held by this scope resolver.Install(world, res) // god.SetAssetResolver
The resolver knows no asset kind itself. Every kind ("sprite", "clip", "sound", "voice", ...) is registered in package assetkind by the package that owns the asset type (render, anim, sound, prefab, particles, speech), so a kind exists in every program that links its owner; a game built on package game links all of them except the opt-in speech. The kinds and the fields that use them are listed in doc/guide/engine/kinds.md.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver implements god.AssetResolver for an asset.Server. Like the server it is single-goroutine.
func New ¶
New returns a Resolver that loads into srv's global scope until Resolver.SetScope is called. The loaders of the kinds in use (render.RegisterLoaders, anim.RegisterLoaders, sound.RegisterLoaders) must be registered on srv.
func (*Resolver) AssetKey ¶
AssetKey returns the key h was loaded from ("path" or "path#sub"). A stale handle (its asset was unloaded) is an error, so serialization never writes a key that no longer means anything.
func (*Resolver) ResolveAsset ¶
ResolveAsset loads path as an asset of the given kind into the current scope and returns its handle (gfx.SpriteHandle for "sprite", gfx.ClipHandle for "clip", and so on: what the kind's Load returns). It does not block: the asset may still be loading, and draws its placeholder until it is ready. A malformed path, a kind that is not registered in package assetkind or a kind whose loader is not registered on the server is an error, not a panic.