bacommon.assetref package¶
Language-independent references to assets within asset-packages.
A reference is a minimal pointer – an apverid plus an asset’s logical
name – carrying no asset data. The server (bamaster) holds only references;
the client resolves the package and loads the real asset for display. Each
kind gets a distinct type (TextureRef, MeshRef) so a
consumer schema can enforce where each kind may go.
Type-safe, ergonomic access to a package’s references comes from a generated
wrapper module (see generate_asset_ref_wrapper_module()), whose
per-kind roots (textures, meshes) are driven at runtime by
AssetRefDir – mirroring the client-side asset-package wrappers.
- class bacommon.assetref.AssetRefDir(apverid: str, node: AssetRefTree, prefix: str)[source]¶
Bases:
objectDynamic accessor for one subdirectory of an asset-package’s refs.
Attribute access resolves against the wrapper’s nested kind-code tree: a subdirectory yields another
AssetRefDir; a leaf yields the reference for its kind. All real type information lives in the wrapper’sif TYPE_CHECKING:shadow, so callers never type-check through this class.
- type bacommon.assetref.AssetRefTree = dict[str, str | AssetRefTree]¶
- class bacommon.assetref.MeshRef(apverid: str, name: str)[source]¶
Bases:
objectA language-independent reference to a mesh in an asset-package.
nameis the mesh’s logical path within the package (e.g.meshes/box). The engine resolves the qualified form<apverid>:<name>.
- class bacommon.assetref.TextureRef(apverid: str, name: str)[source]¶
Bases:
objectA language-independent reference to a texture in an asset-package.
nameis the texture’s logical path within the package (e.g.textures/zoe_icon). The engine resolves the qualified form<apverid>:<name>.
- bacommon.assetref.generate_asset_ref_wrapper_module(apverid: str, assets: list[tuple[str, str]]) str[source]¶
Return the
.pysource for a package’s type-safe ref wrapper.assetsis the package’s asset listing as(logical_path, kind_code)pairs (e.g.('textures/zoe_icon', 't')). The output is valid but not auto-formatted (the_TREEliteral in particular); a caller writing it to the tree should run the formatter before committing.