HumankindAssetFramework

Building the plugin

For adopters who just want to use the Factory, no build is needed — grab a released HumankindAssetFramework.dll. Build only if you’re changing the plugin.

Plugin (HumankindAssetFramework.dll)

Needs the .NET SDK. The project file is HumankindAssetFramework.csproj. Put a References\ folder next to the .csproj containing:

No game installed? pwsh tools/fetch-refs.ps1 collects every reference DLL from public sources (nuget.org, the BepInEx release, BepInEx’s unstripped-Unity mirror) — this is what CI uses; it never overwrites DLLs you already copied from the game. GitHub Actions builds + runs the full test suite on every push (.github/workflows/ci.yml), along with every source-only guard — docs links, binding-catalog surface, hot path, parse shape, editor source, and registry schema parity. Both halves now live in this repo, so parity needs no sibling checkout. See Testing.md for which guards run in which lane, and why the hook is not enough on its own.

Then:

dotnet build -c Release

and copy both bin\Release\HumankindAssetFramework.dll and bin\Release\Haf.Schema.dll → <Humankind>\BepInEx\plugins\ — or just run bash tools/deploy-plugin.sh, which copies both. Haf.Schema.dll (netstandard2.0) is the shared model schema that ModelDef (editor) and ModelEntry (plugin) both inherit — the build produces it automatically via a ProjectReference, but the plugin won’t load without it (BepInEx reports the missing dependency), so the two ship together. The editor package consumes the same tracked DLL from editor/Plugins/Haf.Schema.dll.

Refresh the tracked editor DLL when Haf.Schema changes. The editor compiles against the DLL under editor/, not the source project, so a schema change is invisible on the editor side until that in-repo artifact is refreshed — and the failure looks like a compile error naming a type that plainly does exist ('PackValidator' does not contain a definition for 'ValidatePack'), which reads as your mistake rather than a stale binary. Hit exactly this on 2026-08-23 adding the wrapper rules. If tools/editor_compile_check.sh reports a member that you can see in Haf.Schema/, copy the DLL before believing it:

cp Haf.Schema/bin/Release/netstandard2.0/Haf.Schema.dll editor/Plugins/Haf.Schema.dll

Blender (optional dependency)

The push remembers the last parity PASS (2026-10-31). A parity run that passes writes tools/parity-stamp.txt, a digest of every file the parity drills compile, run or read; the push’s parity stamp step compares it and SKIPs, naming the files, when a Blender script, a ported editor/*.cs or a drill fixture changed since. Commit the stamp the parity run writes beside such a change. See Testing.

The push gate runs no Blender and no Blender-parity drill (2026-10-30). The nine drills that hold the C# ports to Blender’s own output are the gate’s parity mode (HAF_GATE=parity: bash tools/blender_parity.sh, or the Bake Tests row Do the C# ports still match Blender?, which runs exactly that from Unity) and need Blender there; a push runs the build, the tests, the source guards and the Unity-backed drills only. A record of Blender’s output (HAF_ORACLE=record with tools/refresh_blender_oracle.sh, then replay) remains an option of the parity mode for an offline rerun; nothing requires it. See Testing. Blender is still needed for the editor’s own uses below and for the Bake Tests rows that run it.

Blender is needed for .blend import, animated-model import, and for Strip parts / Reduce-to-tris on what the Factory cannot prepare itself — auto-detected under Program Files, or point the Factory Settings override / EditorPrefs 'ENC.blenderPath' at blender.exe. Since 2026-10-08 a static .glb/.gltf with a reduce target is stripped and reduced in process (BlenderPrep, the same file Blender’s prep_model.py would write as far as the converter reads it); Blender still does an OBJ source, a strip without a reduce, and any model the in-process prep names in the console (“model prep: using Blender because …” — an animated file, a JPEG whose alpha is read, an object under a bone, …). Since 2026-11-02 an .fbx is read natively and prepped in process like a .glb, unless the reader names a limit; an animated file of any format is prepped by Blender, and in a static bake without prep an .fbx the native reader leaves by name goes to Unity’s own FBX importer, said in the Console. Static GLB/OBJ/FBX bakes with neither Strip nor Reduce need no Blender: the GLB path uses the self-contained packaged editor/Tools~/glbconv/glbconv.exe (no .NET install required, and its Weld & simplify option decimates without Blender). A dotnet glbconv.dll fallback exists for local dev.

Why Blender does the geometry work (design rationale)

The heavy geometry passes shell out to headless Blender (editor/Tools~/prep_model.py, rig_anim.py, blend_export.py) rather than being written in C# (the prep of a .glb/.gltf is the exception since 2026-10-08: an exact port of what Blender does there, held to Blender’s output by the push gate, with prep_model.py as its fallback). The scripts are Python, but Python is only the remote control — the actual decimation/import/export executes inside Blender’s C/C++ core:

Tests

dotnet test Tests/HumankindAssetFramework.Tests.csproj -c Release

An xUnit suite (net471) over the pure registry/parse/era layer — the half that touches no live-game reflection, and where the bugs have historically been. Needs the same gitignored References\ DLLs as the plugin build (mirrored into the test bin). Full detail — what’s covered, what’s deliberately out of scope and why, how to add a test — is in Testing.md.

The gate cleans up after itself (2026-11-08). Its first step, tools/temp_sweep.sh, removes the gate’s and the drills’ own temporary directories older than two days from your %TEMP%, by their exact generated names only (haf-<producer>.XXXXXXXXXX); it never touches another program’s files and never fails the gate. A new script that makes a temporary directory must use that name form and add its producer to the sweeper’s list, or Tests/test_temp_sweep.py fails. If the gate is suddenly many times slower, compare bash.exe -c : with sh.exe -c : from PowerShell; a large gap was a stuck per-file state on bash.exe that a reboot cleared.

Packaging a player release

ENCReload/Tools/package-release.sh builds the player download: the Humankind mod and the HAF plugin that renders its custom units, in one reproducible artifact.

bash Tools/package-release.sh              # -> Distribution/release/ENCReload-<ver>.zip
bash Tools/package-release.sh --no-zip     # stage only (fast, for inspection)
bash Tools/package-release.sh --haf <dir>  # explicit plugin checkout

Two numbered folders, because the halves install to different roots — the mod is a Humankind Community module, the plugin is a BepInEx DLL, and no single “extract here” covers both:

In the zip Goes to
1_Humankind_game_folder/BepInEx/ the Humankind install (the folder with Humankind.exe)
2_Community_mods_folder/ENCReload.<guid>.<ver>/ the Community folder the player’s other mods are in

READ_ME_FIRST.txt is generated from a tracked template (Tools/release/) with the version and module GUID substituted, so the shipped instructions cannot drift from what shipped. The plugin is built by the script, never collected from wherever a DLL happened to be lying — the hand-made v0.1.0 zip ended up 178 commits behind master exactly that way.

The stale-bundle guard is why this is a script and not a checklist. pack.json’s skel/atlas/clip GUIDs point into the asset bundle, so a re-bake after the last mod build produces a pair that looks fine and is broken — “waiting for leaves to load…” forever, or a scrambled texture from a mismatched mesh/atlas pair. The script refuses to package when any baked asset (or pack.json) is newer than the bundle: the same rule the District Factory’s health check already applies at authoring time, moved to where it would otherwise reach a player. It excludes the bake-test fixtures by the same three prefixes the delete guard uses (__feat_ / __smoketest__ / __convgate__) — a leftover fixture is newer than everything and would otherwise fail every package.

Editor tooling — installable package in this repository

The Model Factory and other authoring windows live in editor/ and install through Unity Package Manager. They compile and run in the host Unity project; ENCReload is the reference consumer. Packaged Blender and converter helpers live under editor/Tools~, and HafPackageContext supplies safe guest-project defaults and derives the guest pack identity. The deleted baker/ editor snapshot must not return: it was a drifting second source.

Native kernels

The editor package ships editor/Plugins/x86_64/hafkernels.dll (Windows Editor-only, x86_64), built from native/ by bash tools/build_native_kernels.sh. It holds the kernels that were measured to be the editor tools’ hot spots (2026-10-21 to 28): the Lab probe’s custom-normal encode and decode, visibility BVH build and world transform (hafkernels.cpp, hafnormals.cpp); the reduce’s edge collapse (hafdecimate.cpp); the Workshop fuse’s exposure ladders from above and from the side (hafcolumn.cpp), twin census (haftwin.cpp) and weld classes (hafweld.cpp); the Vehicle Lab reduce stage’s BMesh build, double search and limited dissolve (hafbmesh.cpp); the PNG codec’s scanline unfilter and pixel expansion, row packing, checksums, composition fills and zlib compression, and SHA-256 through Windows CNG, for the native FBX reader’s textures (hafpng.cpp, with libdeflate 1.26 vendored under native/libdeflate/, MIT; 2026-11-02). Nothing is installed for it: the DLL is part of the package.

What baker/ still holds

Two live things that exist only here, and are built from here: