API reference
Class AssetStore
Namespace: MicroEngine.Content
Assembly: MicroEngine.Content.dll
Guide: Assets
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.
public sealed class AssetStore : IAssetStore, IDisposableInheritance
Implements
Remarks
Used from the game’s thread; loaders may be given work done elsewhere through Add``1.
Constructors
AssetStore(IContentSource, AssetLoaderRegistry?)
A store reading from source.
public AssetStore(IContentSource source, AssetLoaderRegistry? loaders = null)Parameters
source IContentSource
loaders AssetLoaderRegistry?
Exceptions
source is null.
AssetStore(Func<IContentSource>, AssetLoaderRegistry?)
A store whose source is opened by openSource on the first read, so a game without content files
never needs one.
public AssetStore(Func<IContentSource> openSource, AssetLoaderRegistry? loaders = null)Parameters
openSource Func<IContentSource>
loaders AssetLoaderRegistry?
Exceptions
openSource is null.
Properties
Count
How many assets are loaded (each once, however many scopes hold it). Allocates nothing.
public int Count { get; }Property Value
IsSourceOpen
Whether Source has been opened.
public bool IsSourceOpen { get; }Property Value
Loaders
The loaders, one per kind of asset.
public AssetLoaderRegistry Loaders { get; }Property Value
Log
Where reports of slow loads during play go; standard error when null.
public ILog? Log { get; set; }Property Value
ILog?
Root
The scope that lives as long as the store; create child scopes from it for levels and scenes.
public AssetScope Root { get; }Property Value
Source
Where content files are read from, opened on first use.
public IContentSource Source { get; }Property Value
Exceptions
The source cannot be opened (a missing folder or archive); its kind is “content source”.
Methods
Dispose()
Releases every scope’s assets, disposing them. The source is not disposed: whoever made it owns it.
public void Dispose()Get<T>(Asset<T>)
The asset of asset.
public T Get<T>(Asset<T> asset) where T : classParameters
asset Asset<T>
Returns
T
Type Parameters
T
Exceptions
The handle is None, stale (every scope released it) or of another store.
IsLoaded<T>(Asset<T>)
Whether asset still refers to a loaded asset.
public bool IsLoaded<T>(Asset<T> asset) where T : classParameters
asset Asset<T>
Returns
Type Parameters
T
TryGet<T>(Asset<T>, out T?)
The asset of asset, if it is still loaded and of type T.
public bool TryGet<T>(Asset<T> asset, out T? value) where T : classParameters
asset Asset<T>
value T?
Returns
Type Parameters
T