public static class AddressConstantsTurns a build's addresses into constants a game can spell wrong at compile time.
Remarks
The last thing doc 28's G0 owed. § Definitions makes an address the only identity — DefId.From("items/flamebrand"), a hash, no registry — and the cost of that is a magic string in every rule that names content. This is the other half: the content build knows every address it shipped, so it can write them down once and a typo becomes a compile error instead of a rule that silently never fires.
Editor-time rather than a Roslyn generator, and that is forced. A source generator sees the compilation and nothing else; the address list is a property of the *content* build, which runs beside the compiler rather than inside it. Vixen.Sdk's import target already runs BeforeTargets="CoreCompile" for exactly this — its comment says "generated C# … has to exist before CoreCompile reads the compile items. Nothing generates C# yet; the ordering is what makes that a scheduling detail later rather than a redesign." This is the first thing to use it.
⚠ The id is computed from the string, never emitted as a literal. Writing new DefId(0x9A3C1F04) would be a second implementation of the hash, in generated code nobody reads, that silently disagrees with DefId.From the day the hash changes — and the failure is every id in the game resolving to nothing. One FNV pass per constant at type-init is the price of that not being possible.
⚠ Every address gets a class of its own rather than a field on its parent. The obvious shape — a field named after the leaf — cannot express an address that is also a prefix of another, and maps/greenmarch beside maps/greenmarch/spawns is ordinary content. A class can hold both its own Address and its children, so the shape is uniform and the case never arises.
Fields and properties (3)
public const string FileNameWhat the file is called, wherever it is written.
public const string AddressMemberThe member holding an address's own text.
public const string IdMemberThe member holding an address's DefId.
Methods (2)
public static AddressConstantsResult Emit(IEnumerable<string> addresses, string namespace, string root = "Addresses", bool ids = false)Writes the constants for a build's addresses.
public static string Identifier(string? segment)Turns one address segment into a C# identifier, or empty when nothing can be.
Used by (3)
- AddressConstantsTestsVixen.Editor.Assets.Tests
- AddressRunnerVixen.Cli
- VixenCommandVixen.Cli