Bevy plugin to help implement loading states

Overview

Bevy Loading State Progress Tracking Helper Crate

Crates.io docs MIT/Apache 2.0

This is a plugin for the Bevy game engine, to help you implement loading states.

You might have a whole bunch of different tasks to do during a loading screen, before transitioning to the in-game state, depending on your game. For example:

  • wait until your assets finish loading
  • generate a world map
  • download something from a server
  • connect to a multiplayer server
  • wait for other players to become ready
  • any number of other things...

This plugin can help you track any such things, generally, and ergonomically.

Example

See the example for an overview of how to use this crate.

Explanation

To use this plugin, add LoadingPlugin to your App, configuring it for the relevant app states.

To track assets, load them as normal, and then add their handles to the AssetsLoading resource from this crate.

For other things, implement them as regular Bevy systems that return a Progress struct. The return value indicates the progress of your loading task. You can add such "loading systems" to your loading state's on_update, by wrapping them using the track function.

This plugin will check the progress of all tracked systems every frame, and transition to your next state when all of them report completion.

If you need to access the overall progress information (say, to display a progress bar), you can get it from the ProgressCounter resource.

You can have multiple instances of the plugin for different loading states. For example, you can load your UI assets for your main menu during a splash screen, and then prepare the game session and assets during a game loading screen.

Bevy Compatibility

Plugin Version Bevy Version
0.1 0.5
main 0.5
bevy_main main
Comments
  • Crate name

    Crate name

    Can we consider renaming this crate as long as it's not widely used yet? I find the name bevy_loading misleading, because loading is only one use case, while the functionality the crate offers is progress tracking in general. This can be applied to loading, but also to (terrain-) generation, connection, or simple task tracking.

    How about bevy_progress_tracking?

    opened by NiklasEi 3
  • iyes_progress v0.3.0 and iyes_loopless v0.6.0 not integrating

    iyes_progress v0.3.0 and iyes_loopless v0.6.0 not integrating

    Using iyes_progress to track asset loading in a loopless state. When I run my game, I get an error message:

    thread 'main' panicked at 'State Transiton Stage not found (assuming auto-added label)', cargo\registry\src\github.com-1ecc6299db9ec823\iyes_loopless-0.5.1\src\state.rs:240:18

    Looking at the cargo.toml, it seems that iyes_progress is requiring an older version of iyes_loopless. Would it be possible to update iyes_progress to require v0.6.0 or at least v0.5.0 and above?

    opened by Semihazah 2
  • Bevy main

    Bevy main

    The way the dependencies are currently setup, one cannot use the bevy git version. This way it always tracks bevy_main without resorting to patches (which are ignored for those using it in their repository)

    opened by TheNeikos 2
  • unique name for each plugin instance

    unique name for each plugin instance

    Instead of marking the plugin as not unique, give it a unique name depending on the state it's loading in.

    This means that

            // Add plugin for the splash screen
            .add_plugin(
                ProgressPlugin::new(AppState::Splash)
                    .continue_to(AppState::MainMenu)
                    .track_assets(),
            )
            // Add plugin for our game loading screen
            .add_plugin(ProgressPlugin::new(AppState::GameLoading).continue_to(AppState::InGame))
    

    will work, but

            // Add plugin for the splash screen
            .add_plugin(
                ProgressPlugin::new(AppState::Splash)
                    .continue_to(AppState::MainMenu)
                    .track_assets(),
            )
            // Add plugin for our game loading screen
            .add_plugin(ProgressPlugin::new(AppState::Splash).continue_to(AppState::InGame))
    

    won't, blocking adding by mistake the plugin twice with the same state

    opened by mockersf 1
  • 0.4.0 doesn't seem to work?

    0.4.0 doesn't seem to work?

    With these deps:

    bevy = "0.8.0"
    iyes_loopless = "0.7.0"
    iyes_progress = "0.4.0" 
    

    And a system like this:

                .add_system_set(
                    ConditionSet::new()
                        .run_in_state(GameState::Loading)
                        .with_system(setup.track_progress())
                        .into(),
                )
    

    Where setup looks something like:

    pub fn setup(mut commands: Commands) -> Progress {
        commands
            .spawn()
            .insert(RenderCamera::default())
            .insert(Controller::default());
    
        true.into()
    }
    

    I consistently get an unhappy compiler:

    error[E0277]: the trait bound `ParallelSystemDescriptor: IntoSystem<(), (), _>` is not satisfied
       --> src\camera.rs:71:34
        |
    71  |                     .with_system(setup.track_progress())
        |                      ----------- ^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoSystem<(), (), _>` is not implemented for `ParallelSystemDescriptor`
        |                      |
        |                      required by a bound introduced by this call
        |
        = help: the trait `AddConditionalToSet<ConditionSystemSet, ()>` is implemented for `ConditionalSystemDescriptor`
        = note: required because of the requirements on the impl of `iyes_loopless::condition::IntoConditionalSystem<_>` for `ParallelSystemDescriptor`
        = note: required because of the requirements on the impl of `AddConditionalToSet<ConditionSystemSet, _>` for `ParallelSystemDescriptor`
    note: required by a bound in `iyes_loopless::condition::ConditionSet::with_system`
       --> c:\dev\tools\cargo\registry\src\github.com-1ecc6299db9ec823\iyes_loopless-0.7.0\src\condition.rs:652:12
        |
    652 |         S: AddConditionalToSet<ConditionSystemSet, P>,
        |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `iyes_loopless::condition::ConditionSet::with_system`
    
    For more information about this error, try `rustc --explain E0277`.
    

    It isn't clear to me why this wouldn't be satisfied, but I'm relatively new to Rust trait stuff.

    opened by brandon-reinhart 1
  • `track` should be useable without specifying `.system()`

    `track` should be useable without specifying `.system()`

    bevy has recently switched to using IntoSystem so as to allow users to not have to specify .system everywhere. I believe that this should be reflected in the track function as well and would make it fit more.

    opened by TheNeikos 1
  • Udate to latest Bevy main; prep for 0.8

    Udate to latest Bevy main; prep for 0.8

    • [x] Point to upstream iyes_looplesas soon as IyesGames/iyes_loopless#24 is merged

    • we need a manual StageLabel impl now

    • some formatting (just cargo fmt)

    • fixed doc test from the bevy_loading times

    opened by NiklasEi 0
  • Simplify ordering and support persisted Progress

    Simplify ordering and support persisted Progress

    • makes preparation and check system exclusive
      • preparation runs at_start
      • check runs at_end
      • this removes the requirement for manual system ordering in most scenarios
    • support persisting Progress for the rest of the loading State

    based on/merge after #11

    opened by NiklasEi 0
  • Update to bevy 0.7 and make next state optional

    Update to bevy 0.7 and make next state optional

    There might be other plugins or custom systems taking care of the state progression, so I made the next_state optional.

    Changes due to Bevy 0.7 are minimal, but some changes were required (no more system config API).

    opened by NiklasEi 0
  • Tracking Progress from exclusive systems

    Tracking Progress from exclusive systems

    I can't seem to use the tracking function with exclusive systems (can they even return something and be chained?). It also currently is not possible to manually update the ProgressCounter because the fields are private and no functions are exposed to update them.

    How can I track the progress of exclusive systems?

    opened by NiklasEi 0
  • Crash with simultaneous ProgressPlugins (on different state types)

    Crash with simultaneous ProgressPlugins (on different state types)

    I have two separate state machines, Client and Network. Client has the states LoadingGame and InGame and Network has Connecting and Connected. Each of these pairs has a ProgressPlugin associated with it. The transition of Network::Connecting to Network::Connected is one of the items I want to track in the outer progress plugin (Client->InGame), but when the inner one (Network->Connected) completes it pops the ProgressCounter resource leaving Client without one (at least I think this is what is happening, I haven't verified the root cause).

    This might be solvable by making ProgressCounter generic over S in ProgressPlugin.

    opened by siler 3
  • Duplicated handles increase the total counter

    Duplicated handles increase the total counter

    The following code also increases the total counter for already added handles which shouldn't be the case.

    https://github.com/IyesGames/bevy_loading/blob/5981c76aa2f98b56d322d29b536617343015e91c/src/asset.rs#L29-L32

    This should fix it:

    pub fn add<T: Into<HandleId>>(&mut self, handle: T) { 
         if self.handles.insert(handle.into()) {
              self.total += 1;
         }
    } 
    
    opened by albmar 0
Owner
Ida Iyes
Ida Iyes
ECS-friendly ldtk plugin for bevy, leveraging bevy_ecs_tilemap

bevy_ecs_ldtk An ECS-friendly ldtk plugin for bevy. Uses bevy_ecs_tilemap as a base. Not released yet, still in development. bevy_ecs_tilemap once sup

Trevor Lovell 247 Jan 10, 2023
Inverse kinematics plugin for Bevy implementing the FABRIK algorithm.

Inverse kinematics plugin for Bevy implementing the FABRIK algorithm.

Georg Friedrich Schuppe 11 Dec 31, 2022
A example bevy application using bevy-kajiya for its renderer

☀️ bevy-kajiya playground A example bevy application using bevy-kajiya for its renderer NOTE: only tested on Windows. For more context, check out the

Sebastian Hamel 20 Dec 5, 2022
Hi I'm Sophy, a discord bot in devlopment, soon I'll be available to help everyone (❁´◡`❁)

Sophy Bot Hi I'm Sophy, a discord bot in devlopment, soon I'll be available to help everyone (❁´◡`❁) Contribution Do you like me and want to help me?

Far Dragi 0 May 30, 2022
A bunch of commented Anchor programs and JavaScript tests, to help me learn Anchor.

learning-anchor A bunch of commented Anchor programs and JavaScript tests, to help me learn Anchor.

Matt Lim 3 Nov 21, 2021
Telegram bot help you to run Rust code in Telegram via Rust playground

RPG_BOT (Rust Playground Bot) Telegram bot help you to run Rust code in Telegram via Rust playground Bot interface The bot supports 3 straightforward

TheAwiteb 8 Dec 6, 2022
Help project managers and project owners with easy-to-understand views of github issue dependencies.

Help project managers and project owners with easy-to-understand views of github issue dependencies.

nasa 56 Dec 15, 2022
A Github webhook server to help with CI/CD written in Rust.

This application will automatically updates local GitHub repositories and triggers a command once the update is complete. This can be extremely useful

Luca 9 Apr 4, 2023
Provides a Suricata Eve output for Kafka with Suricate Eve plugin

Suricata Eve Kafka Output Plugin for Suricata 6.0.x This plugin provides a Suricata Eve output for Kafka. Base on suricata-redis-output: https://githu

Center 7 Dec 15, 2022
A powerful minecraft bedrock software written in Rust with a powerful Typescript plugin API.

Netrex A powerful minecraft bedrock software written in RustLang. Why Netrex? It's written in Rust. Unique and straight to the point. Typescript Plugi

Netrex 51 Dec 26, 2022
An example Kibana plugin written in Rust and Typescript

An example Kibana plugin written in Rust and Typescript

Aleh Zasypkin 3 Dec 24, 2022
A collection of exponentially-smoothed camera controllers for the Bevy Engine.

smooth-bevy-cameras A collection of exponentially-smoothed camera controllers for the Bevy Engine. Look Transform All controllers are based on a LookT

Duncan 122 Dec 24, 2022
An ability / resource / cooldown management library for Bevy.

About leafwing-abilities is an opinionated, ready-to-use Bevy library and plugin for handling abilities. It features: cooldown tracking resource manag

null 2 Mar 30, 2022
Easier joystick, mouse and keyboard input handling in Bevy

Easier joystick, mouse and keyboard input handling in Bevy

Pedro Henrique 31 Dec 20, 2022
Here are a few cargo-generate templates for use when creating bevy applications

Bevy-template-rs Here are a few cargo-generate templates for use when creating bevy applications. Templates Game This is a template for starting a new

Johnny Tidemand Vestergaard 19 Nov 4, 2022
Composable Alternatives to Bevy's RunCriteria, States, FixedTimestep

Composable Alternatives to Bevy's RunCriteria, States, FixedTimestep This crate offers alternatives to the Run Criteria, States, and FixedTimestep sch

null 221 Jan 2, 2023
A Bevy plugin for loading the LDtk 2D tile map format.

bevy_ldtk ( Tileset from "Cavernas" by Adam Saltsman ) A Bevy plugin for loading LDtk tile maps. Usage use bevy::prelude::*; use bevy_ldtk::*; fn mai

Katharos Technology 23 Jul 4, 2022
Bevy plugin helping with asset loading and organisation

Bevy asset loader This Bevy plugin reduces boilerplate when loading game assets. The crate offers the AssetCollection trait and can automatically load

Niklas Eicker 205 Jan 2, 2023
Bevy asset loader that transparently supports loading over http(s)

Bevy Web Asset This is a tiny crate that that wraps the standard bevy asset loader, and adds the ability to load assets from http and https urls. Supp

Johan Klokkhammer Helsing 28 Jan 2, 2023
A framework for saving and loading game state in Bevy.

Bevy_save A framework for saving and loading game state in Bevy. Features bevy_save is primarily built around extension traits to Bevy's World. Serial

Hank Jordan 10 Jan 24, 2023