Skip to content

A simple one-shot systems for 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

SDesya74/bevy_oneshot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bevy_oneshot

Crates.io Crates.io docs.rs

Naive implementation of one-shot systems for Bevy.

Why?

The library is made mainly for the convenience of working with the GUI. Remember that feeling when you created a system that creates GUI with a couple of input parameters? Nothing foretold trouble, but then the first button appears in the interface, the processing of which adds a few arguments to the system. The second button needed a resource, the third needed a query. After the fourth button you get a clippy::too_many_arguments warn... Pretty frustrating, huh?

With bevy_oneshot you can put all the arguments a particular button needs into a separate system, or even not write a system at all, by making a lambda, which greatly reduces the amount of unnecessary stuff in the system scope.

I really hope one-shot systems will be introduced in Bevy soon and this crate will become irrelevant.

Installation

cargo add bevy_oneshot

or add this to your Cargo.toml

[dependencies]
bevy_oheshot = "0.2"

Usage

use bevy::prelude::*;
use bevy_oneshot::CommandRunOnce;

fn some_system(mut commands: Commands) {
    // run once without arguments
    commands.run_once(|_query: Query<&Window>| {
        // your code here
    });

    // run once with input arguments
    commands.run_once_with(
        |input: In<u32>| {
            println!("{}", input.0);
        },
        42,
    );
}

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_startup_system(some_system)
        .run();
}

Compatibility

Bevy Version Plugin Version
0.10 0.1.0-0.1.1
0.11 0.2.0
0.13 0.2.1

Contributing

PRs are very welcome.

About

A simple one-shot systems for Bevy

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages