Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Architecture

Three .NET 10 projects, each with its own part in this book. This page covers what crosses project boundaries: the folder split of each project and where new code goes.

CreationEngineFormats  <-  BookAtlas.Exporter  --JSON-->  BookAtlas.Generator
(file formats)             (CLI: export, debug)           (static site)

BookAtlas.Generator references neither of the other two: it reads only the book export JSON format.

A namespace is the project name followed by the folder path, one segment per folder: the type in BookAtlas.Exporter/Pipelines/Maps/Layers/PlacedObjects/ObjectsLayer.cs is BookAtlas.Exporter.Pipelines.Maps.Layers.PlacedObjects.ObjectsLayer. Test projects follow the same rule.

CreationEngineFormats

The file formats, with no dependency on a CLI, a load order or vanilla Skyrim data. Parsers throw InvalidDataException on malformed input and never log.

FolderContent
Binary/SpanReader (little-endian reads) and SpanCursor (sequential, bounds-checked reads)
Plugin/Plugin format: record and group headers, PluginFile, PluginWalker, FormIds
Plugin/Query/Plugin queries: what a command reads from a plugin, in one walk
Plugin/Records/One model per record type
Plugin/Reader/One reader per record type, SubrecordCursor, Tags, VmadReader
ArchiveFile/BSA archives and string tables
Text/GameTextDecoder: primary then secondary encoding, for string tables and inline text
Nif/NIF and Havok: header, scene graph, BSTriShape geometry, collision shapes, textures
Lod/LOD settings: the terrain LOD grid of a worldspace
Swf/SWF container, DefineFont3, TrueType writer
Dds/DDS textures: header, mip levels, decoding to RGBA with Pfim

BookAtlas.Exporter

The CLI reads game data in four layers. A layer calls only the layers below it.

Commands/     parse the options, build a GameSource, run a pipeline (or format a dataset for a dump)
   |
Pipelines/    one feature: ask for its datasets, chain its steps, write its output
   |
Datasets/     one model merged over the load order: its clauses, its merge, its report
   |
Game/         access to the game: the source, the session, archives, the plugin pass, assets, vanilla facts

Imaging/  IO/  Diagnostics/   used by every layer
LayerDoesCallsWhy the boundary
Commands/Options, help, examples, --cleanPipelines, Datasets (dumps), GameA command stays an adapter to the command line
Pipelines/The steps of one output, then its filesDatasets, GameA new output is a new pipeline: it never opens a plugin or an archive
Datasets/Clauses on the plugin query, the load-order merge, what the merge droppedGame, other datasetsTwo pipelines in one session share what is already read and merged
Game/Where the data is, the session, archives, the plugin pass, assetsCreationEngineFormatsThe only code that touches game files

Inside a layer, folders follow the domain: Datasets/Books/, Pipelines/Maps/, Pipelines/Interiors/. Pipelines/Debug/ holds the debug:* commands that chain more than one step. A dump that only reads a dataset and prints it has no pipeline: the command formats it.

A session

A command builds a GameSource: one plugin file, one archive file, or a load order found in a Data directory. It opens a GameSession on it for its whole run.

  1. The pipeline asks for every dataset it needs in one LoadAsync.
  2. The session builds one PluginQuery per plugin and lets each dataset attach its clauses to it. Each plugin is walked once, all plugins in parallel, see Plugin queries.
  3. Each dataset merges its per-plugin parts in load order. The parts are released after the merge, unless the model keeps them on purpose.
  4. GetAsync returns the model. The first call also logs what the merge dropped, once per session, see Logging.
  5. When a large model is no longer needed, the pipeline releases it, so the next steps run without it.
  6. Disposing the session closes the archives.

The archives open on first use, once per session. A pipeline that needs them reads session.Archives before LoadAsync, so the listings are read, and the loose files of Data indexed, while the plugins are walked.

Datasets

KindContractCachedExamples
PluginAttach declares clauses on a plugin’s query, Merge folds the partsYes, by valueBookRecords, LocationRecords, WorldspaceMaps(reads)
DerivedBuildAsync combines other datasets of the sessionYes, by valueBookPlacements, WorldspaceCells, WorldspaceTerrain
LookupFormIds known after a first merge, then a targeted read of the top groupsNo, served onceBaseObjects(wanted), NamedRecords(wanted)

A dataset is a record. Its parameters are its cache key: two equal requests share one model, and WorldspaceMaps with and without heights are two models. Merge and BuildAsync are pure: they put what they dropped in the model, and the dataset’s Report logs it. The merge rules are in Load order and merging.

Where new code goes

You’re adding…Goes in
A binary format detail (a record type, a subrecord, an archive field)CreationEngineFormats
A new outputA pipeline in Pipelines/<Feature>/, a thin command in Commands/, registered in ExporterCli.cs
Data a pipeline needs from the pluginsA dataset in Datasets/<Domain>/, its clauses in the domain’s query class
A model built from existing datasetsA derived dataset
Records found by FormId after a mergeA lookup in Datasets/Lookups/
Reading a file from the archivesGame/Assets/
A fact specific to vanilla Special EditionGame/Vanilla/
Decoding a game textureCreationEngineFormats/Dds/, see DDS textures
An image operation or PNG encodingImaging/, PNG in Imaging/Png/
A way to interpolate between the samples of a gridImaging/Interpolation/Kernels/, see Interpolation
A debug dumpCommands/Debug/, with a pipeline in Pipelines/Debug/ if it chains several steps

Game/Vanilla/ holds the facts of vanilla Special Edition (archive list, string encodings, fontconfig files), Game/LoadOrders/ the se, ae and custom load orders. GameSource is where another data source would plug in. No abstraction is built for it yet.

No dependency injection container

The dependencies are data (datasets), not services to wire. There is one lifetime, the session, and few pipelines, all known. A container would add a package, start-up time and an indirection that hides the flow. Constructors take the session and the options. A container becomes useful only if pipelines turn into extensions registered at run time.

The production commands are export:books and export:worldspace-maps:*. The debug:* commands are inspection tools.

BookAtlas.Generator

The static site generator. See its overview for why it’s a separate project.

FolderContent
Commands/generate:site, generate:pdf
Import/JSON import models and readers (books, maps), independent of the exporter’s types; language discovery; the map catalog
Diagnostics/A copy of the exporter’s logger
IO/A copy of the exporter’s OutputDirectoryCleaner, behind --clean
Templates/, Assets/Embedded Scriban templates, the pages’ scripts, the site stylesheet and the PDF one
Rendering/Book naming, titles and their sort order, the concurrent book loop
Rendering/Markup/Book markup to safe HTML
Rendering/SiteAssets/Texture and font resolution, stylesheet
Rendering/Templating/The Scriban wrapper and template functions
Rendering/Pages/Page shell, index pages and the map pages; BookPage/ for one book’s page
Rendering/Maps/The map page’s menu, data and libraries, links from book pages; copying the tiles into the site
Rendering/Pdf/Headless Firefox, the WebDriver BiDi client, printing books to PDF

LanguageSiteGenerator.cs writes one language’s subsite, LanguagePdfGenerator.cs one language’s PDFs.

Tests

Each project has a test project with the same folder layout: CreationEngineFormats.Tests, BookAtlas.Exporter.Tests, BookAtlas.Generator.Tests. Fixtures are built in code (Support/: plugin, subrecord, BSA and NIF byte builders); no test reads game files.