//! This Example shows how you can create custom promises //! with `Promise::register()` method and resolve them from //! you system with `commands.promise(id).resolve(result)` use bevy::prelude::*; use pecs::prelude::*; fn main() { App::new() .add_plugins(DefaultPlugins) .add_plugins(PecsPlugin) .add_systems(Startup, setup) .add_systems(Update, process_timers_system) .run(); } #[derive(Component)] /// Holds PromiseId and the time when the timer should time out. pub struct MyTimer(PromiseId, f32); /// creates promise that will resolve after [`duration`] seconds pub fn delay(duration: f32) -> Promise<(), ()> { Promise::register( // this will be invoked when promise's turn comes move |world, id| { let now = world.resource::