MCPcopy Index your code
hub / github.com/Leafwing-Studios/leafwing_manifest

github.com/Leafwing-Studios/leafwing_manifest @v0.7

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.7 ↗ · + Follow
99 symbols 135 edges 12 files 35 documented · 35%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Leafwing Manifest

leafwing_manifest is a straightforward, opinionated tool to transform "assets on disk" into flexible, robust objects inside of your Bevy game. There are four key concepts:

  1. Id: A unique identifier for objects of a given class (e.g. monsters, tile types or levels). Commonly stored as a components on game entities.
  2. Item: An in-memory representation of all of the shared data (e.g. name, asset handles, statistics) of game objects of a given kind.
  3. Manifest: a Bevy Resource which contains a mapping from identitifiers to items.
  4. Raw manifest: a serialization-friendly representation of the data stored in a manifest.

Data is deserialized from disk into a raw manifest, which is processed into a manifest which contains a list of all available game objects of a given class. That manifest is then used to spawn and look up the properties of specific kinds of game objects in your game code.

Bevy compatibility

bevy Version leafwing_manifest Version
0.18 0.6
0.17 0.5
0.16 0.4
0.15 0.3
0.14 0.2
0.13 0.1

Why manifests rock

An in-memory resource where you can look up the statistics for various game objects is incredibly useful:

  1. It's super easy to spawn new game objects dynamically inside of gameplay code, including spawning multiple copies of an object well after the initial asset load. Simply write a helper method once, and then spawn any object you want in a single command.
  2. Spawning multiple clones of the same gameplay object is safer. Since the manifest is generally read-only, you know you always have a "clean" version to clone from.
  3. Manifests offer a clear list of all objects of a given kind: great for both dev tools and in-game encyclopedias.
  4. Using manifests abstracts away messy asset loading (and unloading) code into a single consistent pattern that can grow with your project.
  5. Heavy data can be deduplicated by simply looking it up in the manifest when needed.

For more background reading on why this crate exists, and the design decisions made, check out MOTIVATION.md.

Usage

To get started:

  1. Add an asset loading state that implements AssetState (like the SimpleAssetState that we ship) to your app that handles the lifecycle of loading assets.
  2. Add ManifestPlugin<S: AssetState> to your App.
  3. Create a struct (e.g. Monster) that stores the final data that you want to share between all objects of the same kind.
  4. Put your game design hat on and define each monster's life, level, name and so on in a serialized format like RON.
  5. Register the manifest in your app with app.register_manifest::<Monster>, supplying the path to the data to load.
  6. In your game logic, spawn monsters or look up their statistics by calling Manifest<Monster>.get(id: Id<Monster>).

See the simple.rs example to jump right in!

If your assets require processing (for validation, or if they contain references to other assets), you will need a raw manifest type, and corresponding raw item type. Take a look at the raw_manifest.rs example next!

Note that we don't compress our manifests into a binary format in our examples. While you can do so, we don't encourage you to (except as an optimization in shipped games). The added pain during version control and debugging is typically not worth the improvements to file size or loading speed during development.

Extension points exported contracts — how you extend this code

Manifest (Interface)
A manifest is a collection of ready-to-use game objects, which are loaded from disk and stored in the ECS as a resource. [6 …
src/manifest.rs
AssetLoadingState (Interface)
A trait that translates your custom [`States`] enum into the states required for asset loading. Note that you are not r [2 …
src/asset_state.rs
RegisterManifest (Interface)
An extension trait for registering manifests with an app. [1 implementers]
src/plugin.rs
MutableManifest (Interface)
A trait for manifests that can be modified. In many cases, manifests are read-only, and are loaded from disk at the sta
src/manifest.rs

Core symbols most depended-on inside this repo

clone
called by 10
src/identifier.rs
iter
called by 7
src/plugin.rs
load
called by 5
examples/custom_asset_lifecycle.rs
get
called by 3
examples/simple.rs
update_load_states
called by 2
src/plugin.rs
processing_status
called by 2
src/plugin.rs
set_processing_status
called by 2
src/plugin.rs
get_by_name
called by 2
src/manifest.rs

Shape

Method 39
Class 28
Function 21
Enum 7
Interface 4

Languages

Rust100%

Modules by API surface

src/plugin.rs21 symbols
examples/entities_from_manifests.rs12 symbols
examples/custom_asset_lifecycle.rs12 symbols
examples/preprocess_assets.rs11 symbols
src/identifier.rs10 symbols
examples/raw_manifest.rs9 symbols
src/manifest.rs8 symbols
examples/simple.rs7 symbols
examples/items_by_name.rs6 symbols
src/asset_state.rs2 symbols
tools/ci/src/main.rs1 symbols

For agents

$ claude mcp add leafwing_manifest \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page