Skip to content

Uniti

uniti is the C FFI bridge that exposes the KBVE Bevy game-logic crates to the Unity runtime used by RareIcon. It compiles as a cdylib and is loaded by Unity as a native plugin.

Bindings on the C# side are generated by csbindgen at build time and committed to the Unity project as Uniti.g.cs.

CratePurpose
bevy_pathfindingGrid flow-field navigation + chokepoint detection
bevy_inventoryItem / slot persistence
bevy_battleCombat resolution
bevy_skillsSkill / proc tables

Plus two runtime helpers compiled into the dylib so Unity does not need them on the host:

  • rusqlite with the bundled feature — save-archive persistence, no system libsqlite3 dep.
  • zstd with default features disabled — pure-Rust compression for save blobs.

Each Nx target builds the release cdylib and copies it into the Unity Plugins/ tree for the matching platform.

Terminal window
npx nx run uniti:build:macos
npx nx run uniti:build:windows
npx nx run uniti:build:linux
npx nx run uniti:build:all

On macOS the target also runs xattr -cr and an adhoc codesign --force --deep --sign - so the dylib loads through Gatekeeper without a quarantine prompt.

build.rs invokes csbindgen and writes the C# wrapper to:

apps/rareicon/unity-rareicon/Assets/_RareIcon/Scripts/Native/Uniti.g.cs

Hand-written wrapper classes live alongside it under Native/Wrappers/ (for example NativeWorld).

Tracked in the dispatch manifest under the crates pipeline. The standard test / lint nx targets are wired:

Terminal window
npx nx run uniti:test
npx nx run uniti:lint

MIT