Skip to content
Viewing as a member
crates · rust · bevy

Proto-driven map registry forbevy_mapdb

A game-agnostic Bevy crate that wraps the mapdb.proto types in a searchable MapDb resource for zones, regions, and world objects.

One proto, every game

It takes the mapdb.proto types from the shared kbve-proto crate and wraps them in a searchable MapDb resource, so any game can query zones, regions, and world object definitions by slug, ULID, biome, or type.

RustLanguage
0.1.1Version
protoSchema
MITLicense

What it gives you

Features

Proto-driven schema

Map types come from the shared kbve-proto crate rather than a generated copy, so the crate cannot drift from the schema.

Searchable registry

MapDb looks up zones, regions, and world object defs by ProtoMapId, ref, or ULID, and filters zones by biome or type.

Multiple load paths

MapDb::from_bytes (the baked registry), MapDb::from_json (the /api/mapdb.json rows), and MapDb::from_proto (in-memory MapRegistry).

Game-agnostic

BevyMapDbPlugin registers an empty MapDb; games populate it at startup and insert it as a resource.

Get started

Usage

main.rs
use bevy::prelude::*;
use bevy_mapdb::{BevyMapDbPlugin, MapDb};

fn load_maps(mut commands: Commands) {
    let db = MapDb::from_bytes(kbve_registry::MAPDB).expect("the map registry decodes");
    commands.insert_resource(db);
}

Questions

Frequently asked

What does the bevy_mapdb crate do?

It re-exports the shared mapdb.proto types from kbve-proto and wraps them in a searchable MapDb Bevy resource, so any game can query zones, regions, and world object definitions by slug, ULID, biome, or type.

How do you load map data into bevy_mapdb?

The docs/mapdb rows are baked into one encoded registry — kbve_registry::MAPDB inside the workspace, https://kbve.com/api/registry/mapdb.binpb outside it — which MapDb::from_bytes decodes. MapDb::from_json reads the /api/mapdb.json rows and MapDb::from_proto takes an in-memory MapRegistry. Insert the result as a Bevy resource during startup.

Is bevy_mapdb tied to a specific game?

No. It is game-agnostic. Any Bevy game can load the same shared proto map registry; BevyMapDbPlugin registers an empty MapDb that the game populates at startup, and with default features off the lookups work without Bevy.

Discuss on the forum

Questions, fixes and notes on this page live in the KBVE forum.