Skip to content

Self-documenting systems and simpler plugins in Bevy

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

TGRCdev/bevy-butler

Repository files navigation

bevy-butler

A crate for making Bevy systems more self-documenting.

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

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

#[derive(Resource)]
pub struct Hello(pub String);

pub struct MyPlugin;

#[butler_plugin]
impl Plugin for MyPlugin {
    fn build(&self, app: &mut App) {
        app.insert_resource(Hello("World".to_string()));
    }
}

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

#[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();
}