Vixen
caa30e12
csharp
public static class DefinitionContent

Reads a build's definitions out of Assets and bakes them into a catalog.

Read the guide page for this →

Remarks

Doc 28 § Definitions' third consequence, and the half that was owed from G0. The importer writes one self-describing artefact per .vxdef and DefinitionSerialization reads one back; what was missing is the step that finds them all. A game's definitions are found by label, because that is the mechanism the content build already has for "everything of this kind" and inventing a second one would be a second thing to keep in step.

⚠ A definition is copied out of its bundle rather than held by a handle, and doc 28's sketch is wrong about this. § Definitions says a definition is "resolved through Vixen.Assets, ref-counted". Ref-counting the definitions themselves would be the wrong shape twice over: it puts a load call on the damage path, and it admits a state in which a sword sitting in somebody's bag names a definition that has been unloaded — and a DefId that sometimes resolves is worse than one that never does. The catalog is loaded whole, at boot, and held for the life of the build; a live content update replaces it wholesale through Reload.

What is ref-counted is what a definition points at — the sword's mesh, its icon, its sound. Those are AssetReferences inside the definition and they are loaded by whoever draws them, on the ordinary handle path, long after this has run.

⚠ BuildHash and ContentCatalog.BuildHash are different numbers and neither substitutes for the other. The content catalog's covers every byte a build shipped and is what doc 27's placement filters on; this one covers the addresses and the tag table, which is what two peers have to agree on before a tag index means the same thing at both ends.

Fields and properties (1)

  • public const string Label

    The label a content build puts on the group its definitions live in.

Methods (3)

  • public static ValueTask<DefinitionLoad> LoadAsync(AssetManager assets, CancellationToken cancellation = default(CancellationToken))

    Loads everything under Label.

  • public static ValueTask<DefinitionLoad> LoadAsync(AssetManager assets, IEnumerable<string> labels, CancellationToken cancellation = default(CancellationToken))

    Loads everything under some labels.

  • public static ValueTask<DefinitionLoad> LoadFromAsync(AssetManager assets, IEnumerable<string> addresses, CancellationToken cancellation = default(CancellationToken))

    Loads a named set of addresses.

Used by (1)

  • DefinitionContentTestsVixen.Gameplay.Content.Tests