Skip to content
crates · rust · bevy

Proto-driven NPCs forbevy_npc

A game-agnostic NPC registry for Bevy — the shared npcdb.proto compiled into typed Rust structs and wrapped in a searchable NpcDb resource queryable by slug, ULID, type, rarity, or creature family.

One proto, every game

The crate is game-agnostic: any title can load the same proto NPC registry and query it by slug, ULID, type flags, rarity, or creature family.

RustBevy crate
Bevy 0.18Engine
NpcDbRegistry
MITLicense

What it gives you

Features

Proto-driven types

npcdb.proto is compiled to typed Rust structs at build time with prost, keeping the NPC schema in sync across games.

Searchable registry

The NpcDb resource is queryable by slug, ULID, type flags, rarity, or creature family.

Multiple load paths

Hydrate from JSON (from_json), a proto binary (from_bytes), or a decoded proto (from_proto).

Optional creature feature

Adds ECS components for creature pooling, capture, and interaction (CreaturePoolIndex, CreatureState, CapturedCreatures, CreatureCaptureEvent, CreaturePlugin).

Get started

Usage

main.rs
use bevy::prelude::*;
use bevy_npc::{BevyNpcPlugin, NpcDb};

fn load_npcs(mut commands: Commands) {
    let json = include_str!("path/to/npcdb.json");
    let db = NpcDb::from_json(json).expect("Failed to parse NPC JSON");
    commands.insert_resource(db);
}

Questions

Frequently asked

What does the bevy_npc crate do?

It compiles the shared npcdb.proto into typed Rust structs via prost and wraps them in a searchable NpcDb Bevy resource, so any game can load one proto NPC registry and query it by slug, ULID, type flags, rarity, or creature family.

How do you load NPC data into bevy_npc?

Add BevyNpcPlugin to register an empty NpcDb resource, then populate it at startup from JSON with NpcDb::from_json, from a proto binary with NpcDb::from_bytes, or from a decoded proto with NpcDb::from_proto, and insert it via commands.

What is the optional creature feature?

The creature feature enables game-agnostic ECS components for creature pooling, capture, and interaction — CreaturePoolIndex, CreatureState, CapturedCreatures, CreatureCaptureEvent, and CreaturePlugin.