Skip to main content

Crate bevy_time_runner

Crate bevy_time_runner 

Source
Expand description

§bevy_time_runner

§TimeRunner

TimeRunner will expects you to create an entity containing the TimeRunner component and their children to contain the TimeSpan component like so:

use bevy::prelude::*;
use bevy_time_runner::{TimeRunner, TimeSpan};

fn secs(secs: u64) -> Duration {
    Duration::from_secs(secs)
}

commands
    .spawn(TimeRunner::new(secs(10)))
    .with_children(|c| {
        c.spawn(TimeSpan::try_from(secs(0)..secs(3)).unwrap());
        c.spawn(TimeSpan::try_from(secs(3)..secs(7)).unwrap());
        c.spawn(TimeSpan::try_from(secs(7)..secs(10)).unwrap());
    });

While the TimeRunner is running, for each child with the component TimeSpan, the component TimeSpanProgress will be inserted to each child with the appropriate values and removed if the runner is out of range of the span.

This creates a very flexible timing system that’s useful for variety of purposes.

Structs§

SkipTimeRunner
Skip a TimeRunner.
TimeContext
A marker component attached to TimeRunner to make the time delta applied to it based on a specific TimeCtx
TimeRunner
Advanced timer
TimeRunnerDebugInfodebug
Includes infos at runtime for debugging TimeRunner related issues. This is inserted via TimeRunnerDebugPlugin.
TimeRunnerDebugPlugindebug
Debugs TimeRunner related issues
TimeRunnerElasped
Contains the current elasped time per tick. Have more informations useful for handling edge cases and retain timing accuracy.
TimeRunnerEnded
Fired when a time runner repeated or completed
TimeRunnerPluginbevy_app
Registers all types and adds TimeRunnerRegistrationPlugin with default config
TimeSpan
Define the range of time
TimeSpanProgress
TimeSpanProgress is automatically managed by its runner.

Enums§

NewTimeSpanError
Error type for when creating a new TimeSpan.
Repeat
Timer repeat configuration
RepeatStyle
Time runner repeat behavior
TimeBound
Bounding enum for Duration to be exclusivively checked or inclusivively checked.
TimeDirection
Time direciton
TimeRunnerSet
System set in this crate

Functions§

tag_time_runner_children_with_context
Tag the chilren of newely created TimeRunners with their TimeContext<TimeCtx> to ease querying
tick_time_runner_system
Tick time runner then send TimeRunnerEnded event if qualified for.
time_runner_system
System for updating any TimeSpan with the correct TimeSpanProgress by their runner