Giter VIP home page Giter VIP logo

bevy_schedules_ext's Introduction

Bevy Schedules, improved

Adds functionality to Bevy's existing Schedules, allowing nesting and using schedules as a replacement for Sets for system grouping and ordering.

Extends Bevy's existing structures, no .add_plugin or managing new Resources.

Features

Nesting

Nest one or more schedules:

With bevy_schedules_ext Vanilla bevy
// Schedules can be added to other schedules
app.add_schedules(Update, Child);
app.add_schedules(Child, (GrandchildOne, GrandchildTwo));

// Add systems to schedules directly, no appending `.in_set(...)` to everything!
app.add_systems(Update, update_system);
app.add_systems(Child, child_system);
app.add_systems(GrandchildOne, grandchild_system_one);
app.add_systems(GrandchildTwo, grandchild_system_two);
// Sets configured manually, Update must be prepended to everything
app.configure_sets(Update, Child);
app.configure_sets(Update, (GrandchildOne, GrandchildTwo).chain().in_set(Child));

// Adding systems to sets requires `.in_set(...)`
app.add_systems(Update, update_system);
app.add_systems(Update, child_system.in_set(Child));
app.add_systems(Update, grandchild_system_one.in_set(GrandchildOne));
app.add_systems(Update, grandchild_system_two.in_set(GrandchildTwo));

All systems will run in Bevy's update loop without having to manually call run on the custom schedules.

A full example is available in examples/nested_schedules.rs.

States

Use Bevy's States as Schedules, so you can add systems to your states and have them run when the state is active, no run conditions needed.

With bevy_schedules_ext Vanilla bevy
// Init state and add it to our Update loop
app.init_state_to_schedule::<GameState>(Update);

// Add systems to the specific states
app.add_systems(GameState::Menu, menu_system);
app.add_systems(GameState::Playing, playing_system);
// Initialize the state, pretty much the same
app.init_state::<GameState>();

// Add systems to our update loop, but we need to check on every frame if the state is active
app.add_systems(Update, menu_system.run_if(in_state(GameState::Menu)));
app.add_systems(Update, playing_system.run_if(in_state(GameState::Playing)));

A full example is available in examples/states.rs.

Downsides

Since running a schedule requires exclusive world access, schedules can't run in parallel. So any time systems in different groupings need to run in parallel, nesting or using schedule states will block that. Ideally, you'd use a combination of both this crate and vanilla Bevy, with schedules to contain the larger groupings of systems and vanilla Bevy to handle groups that might overlap.

Bevy compatibility

Bevy version bevy_schedules_ext version
main branch master branch
0.13 0.13

Note: A newer version of this crate may work on an older version of Bevy and vice versa, however it's not tested and would require extra work on your part (e.g. patching Cargo.toml to match the versions).

License

All code in this repository is dual-licensed under either:

at your option. This means you can select the license you prefer.

Your contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

bevy_schedules_ext's People

Contributors

vonforum avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.