API reference
Namespace MicroEngine.Content
Content: the asset store under Game.Assets (typed handles, scopes that share and release, the loader registry, the reserved import step) and content sources beyond folders (zip archives, files a host lists).
Guide: Assets
Classes
What a loader is asked to load, and the content it reads it from.
AssetLoader<T>
A loader written as a function (see IAssetLoader`1).
The loaders of a store, one per kind. The engine registers its own (images, atlases, fonts, sounds, music); a game or module adds kinds of its own, or replaces one by registering another loader with the same kind before the first load of that kind.
Content paths: relative to the source, ‘/’-separated.
An owner of assets: what a game, a level or a scene holds. Every scope that asks for an asset holds it, whichever scope loaded it first, so sibling scopes share one object; disposing a scope (or Release) releases its holds, and an asset is disposed when no scope holds it any more. Child scopes are released with their parent.
One entry per asset key for the whole game, shared by the scopes that hold it: a scope that asks for an asset another
scope already loaded gets the same object and holds it too; the object is disposed (when it is
IDisposable) once the last scope holding it releases it, and its handles become stale. Games never count
references: lifetimes follow scopes.
Reading from any content source, and opening one from a path.
Content files a host lists and opens itself, where the files are not a folder .NET can read: an Android app’s packaged assets (opened through the platform’s asset manager), files a browser page fetched. The listing is fixed when the source is made; names follow the folder rules (exact letter case everywhere, ‘/’ separators).
Content files inside a zip archive: a game’s content shipped as one file. Names follow the folder rules (exact letter case everywhere, ‘/’ separators, no way out of the archive). Each file is decompressed into memory when it is opened, so streams are independent and the source can be read from several threads.
Structs
Asset<T>
A typed reference to an asset in an AssetStore: a slot and the generation of the asset that held it.
Once the asset is released by every scope that held it (and disposed), the handle is stale: reading it fails instead
of reaching whatever reuses the slot. default is None.
What identifies a stored asset: the loader’s kind, the content path and the settings it was loaded with. Two requests with equal keys share one object. A struct of references and values, so a lookup allocates nothing.
One asset a scope holds, as Loaded lists it.
Interfaces
Reserved: a build-time step that turns a source file into the file a loader reads (a texture compressed for the GPU, a model converted from glTF, a font baked into a distance field), driven by settings kept next to the source file. The engine does not call importers yet; the interface fixes where that step will plug in so loaders never need to change when it arrives. Content stays usable without any importer: loaders read source files directly.
IAssetLoader<T>
A loader of assets of type T (see IAssetLoader).
Makes one kind of asset from content files: decodes an image into a texture, a WAV into an audio clip… A loader is registered once per store under its Kind (AssetLoaderRegistry); the store calls it the first time a key of that kind is asked for and shares the result.
A game’s assets: where content comes from, the loaders that read it, and the scopes that hold what was loaded.