MCPcopy Index your code
hub / github.com/MrGVSV/bevy_proto

github.com/MrGVSV/bevy_proto @v0.11.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.11.0 ↗ · + Follow
637 symbols 1,152 edges 111 files 247 documented · 39% updated 2y agov0.11.0 · 2023-07-29★ 24110 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

bevy_proto

Crates.io Docs License

Spawn entities in Bevy with a simple configuration file, similar to Unity's prefabs.

This crate can be used for:

  • Quick prototyping
  • Modding support
  • Data-defined behaviors

📋 Features

  • Define entities easily with config files:

rust ( name: "player", schematics: { "game::creature::Health": ( value: 100, ), }, )

  • Inherit functionality from other prototypes:

rust ( name: "Skeleton", templates: ["Enemy", "Creature"], // ... )

  • Setup entire entity hierarchies:

rust ( name: "Blaster", schematics: { "game::weapon::AmmoEntity": ( // Even reference other entities in the tree: entity: EntityPath("./@1"), ), }, children: ["Scope", "AmmoPack"] )

  • Load assets automatically:

rust ( name: "Puppy", schematics: { "game::image::GameImage": ( handle: AssetPath("textures/puppy.png"), ), }, )

  • Spawn!

rust fn spawn_player(mut commands: ProtoCommands) { commands.spawn("player"); }

📲 Installation

Add the following to your [dependencies] section in Cargo.toml:

bevy_proto = "0.11"

Or use cargo add:

cargo add bevy_proto

📓 Examples

Check out the examples folder for examples and tutorials for using the crate.

🕊 Bevy Compatibility

bevy bevy_proto
0.11.0 0.11.0
0.10.1 0.10.0

For previous versions of this crate, see the Previous Versions section below.

🥅 Goals

This crate is mostly feature-complete.

There are a few more things I think would be really nice to add. Below is a list of my current goals and what's been accomplished thus far:

Goal Status
Reflection support
Nested prototypes
Package-specifier 🚧
Configurable schematics filtering and processing
Prototype arguments 🚧
Entity-less prototypes
Value access 🚧
Custom file format support
Improved documentation 🚧
Benchmarks 🚧

🕰 Previous Versions

Before version 0.8 of bevy_proto, this crate relied on the typetag crate. This allowed us to accomplish similar goals by using serde' s Deserialize instead of bevy's FromReflect. This was nice in that it meant we could avoid having to register every type, but it had a few drawbacks.

For one, it had issues working on WASM, which made its usage platform-specific. Additionally, its life-before-main behavior is not guaranteed to exist or work as intended by the Rust compiler, meaning it could suddenly stop working at some future point in time.

Lastly, and most importantly, is that it's not the direction Bevy itself is currently taking. Bevy is building upon its reflection library, and much of the community is following the same. As this becomes more and more standard (especially with an editor), it will just be better to lean into reflection.

However, in the interest of allowing users to decide if they also want to make the switch, I have preserved the original typetag-based code under a new crate:

bevy_proto_typetag

I imagine the crate won't see many updates outside those to bump the Bevy version. I may come back to it to create a similar flow as this crate, but I'm not going to make any promises on that as I want this crate to be the main focus.

Extension points exported contracts — how you extend this code

FromSchematicInput (Interface)
A custom [`From`]-like trait used to convert the [input] of a [schematic] to itself. This is used by [derive macro] to [15 …
bevy_proto_backend/src/schematics/schematic.rs
Schematic (Interface)
Trait used to create a [prototype] schematic for modifying an [entity] (or the [world] in general). This trait can eith [2 …
bevy_proto_backend/src/schematics/schematic.rs
ProtoPathContext (Interface)
The context used when processing a [`ProtoPath`]; [`ProtoPath`]: crate::path::ProtoPath [2 implementers]
bevy_proto_backend/src/path/context.rs
Loader (Interface)
Configures how a [prototype] should be loaded. [prototype]: Prototypical [2 implementers]
bevy_proto_backend/src/load/loader.rs
Prototypical (Interface)
The trait used to define a prototype. Prototypes are containers for [`Schematics`] that can be spawned in at runtime. T [1 …
bevy_proto_backend/src/proto/prototypical.rs

Core symbols most depended-on inside this repo

iter
called by 28
bevy_proto_backend/src/deps/collection.rs
push
called by 25
bevy_proto_backend/src/load/load_context.rs
id
called by 24
bevy_proto_backend/src/cycles/node.rs
spawn
called by 22
bevy_proto_backend/src/proto/commands.rs
as_ref
called by 22
bevy_proto_backend/src/path/proto_path.rs
insert
called by 17
bevy_proto_backend/src/proto/storage.rs
clone
called by 16
bevy_proto_backend/src/cycles/node.rs
load
called by 16
bevy_proto_backend/src/proto/prototypes.rs

Shape

Method 402
Class 115
Function 85
Enum 28
Interface 7

Languages

Rust100%

Modules by API surface

src/custom.rs25 symbols
bevy_proto_backend/src/tree/entity_tree.rs23 symbols
bevy_proto_derive/src/schematic/field_attributes.rs22 symbols
bevy_proto_backend/src/load/load_context.rs22 symbols
bevy_proto_backend/src/registration/registry.rs21 symbols
bevy_proto_backend/src/proto/commands.rs21 symbols
bevy_proto_backend/src/schematics/collection.rs19 symbols
bevy_proto_backend/src/tree/access.rs16 symbols
bevy_proto_derive/src/schematic/derive.rs14 symbols
bevy_proto_backend/src/schematics/dynamic.rs14 symbols
src/config.rs13 symbols
bevy_proto_derive/src/schematic/fields.rs13 symbols

For agents

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

⬇ download graph artifact