Crate bevy_butler

Crate bevy_butler 

Source
Expand description

§bevy-butler

A set of procedural macros for making Bevy plugins and systems more self-documenting.

Crates.io License Crates.io Version docs.rs Crates.io MSRV

§Version Compatibility

bevybevy-butler
0.170.7
0.160.6
0.150.5

§Example

use bevy::prelude::*;
use bevy_butler::*;

#[butler_plugin]
struct MyPlugin;

#[derive(Resource)]
#[insert_resource(plugin = MyPlugin, init = Hello("World".to_string()))]
struct Hello(String);

#[add_system(schedule = Update, plugin = MyPlugin)]
fn hello_plugin(name: Res<Hello>)
{
    info!("Hello, {}!", name.0);
}

#[add_system(schedule = Update, plugin = MyPlugin, after = hello_plugin)]
fn goodbye_plugin(name: Res<Hello>)
{
    info!("Goodbye, {}!", name.0);
}

fn main() {
    App::new()
        .add_plugins(MyPlugin)
        .run();
}

§WebAssembly support

WebAssembly support is currently locked behind the wasm-experimental flag. See the relevant issue for more information.

Attribute Macros§

add_message
Registers the annotated Message upon the given #[butler_plugin] being built.
add_observer
Registers an observer function to a #[butler_plugin]-annotated Plugin.
add_plugin
Adds the given Plugin to the target Plugin/PluginGroup
add_plugin_group
Adds the given PluginGroup to the target Plugin/PluginGroup
add_sub_state
Adds the annotated sub state to a #[butler_plugin]
add_system
Registers a system to a #[butler_plugin]-annotated Plugin.
butler_plugin
Configures a plugin to be usable within bevy_butler’s various macros as a plugin argument.
butler_plugin_group
Implements PluginGroup and configures it to be used with add_plugin/add_plugin_group.
insert_resource
Registers the annotated Resource to a #[butler_plugin] and initializes it upon the plugin being added.
insert_state
Adds the annotated state to a #[butler_plugin]
register_type
Registers the annotated Reflect type into the app’s type registry for reflection.