Skip to content

Add missing documentation to bevy_time #9428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/bevy_time/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Bevy Time

The built-in timekeeping plugin for the Bevy game engine.
7 changes: 6 additions & 1 deletion crates/bevy_time/src/fixed_timestep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ impl FixedTime {
self.accumulated += delta_time;
}

/// Returns the current amount of accumulated time
/// Returns the current amount of accumulated time.
///
/// Approximately, this is how far behind the fixed update schedule is from the main schedule.
pub fn accumulated(&self) -> Duration {
self.accumulated
}
Expand Down Expand Up @@ -92,9 +94,12 @@ impl Default for FixedTime {
/// An error returned when working with [`FixedTime`].
#[derive(Debug, Error)]
pub enum FixedUpdateError {
/// There is not enough accumulated time to advance the fixed update schedule.
#[error("At least one period worth of time must be accumulated.")]
NotEnoughTime {
/// The amount of time available to advance the fixed update schedule.
accumulated: Duration,
/// The length of one fixed update.
period: Duration,
},
}
Expand Down
16 changes: 11 additions & 5 deletions crates/bevy_time/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![allow(clippy::type_complexity)]
#![warn(missing_docs)]
#![doc = include_str!("../README.md")]

/// Common run conditions
pub mod common_conditions;
Expand Down Expand Up @@ -69,23 +71,27 @@ impl Plugin for TimePlugin {
/// you may prefer to set the next [`Time`] value manually.
#[derive(Resource, Default)]
pub enum TimeUpdateStrategy {
/// [`Time`] will be automatically updated according to the length of the previous frame.
#[default]
Automatic,
// Update [`Time`] with an exact `Instant` value
/// [`Time`] will be updated to the specified [`Instant`] value.
/// In order for time to progress, this value must be manually updated each frame.
///
/// Note that the `Time` resource will not be updated until [`TimeSystem`] runs.
ManualInstant(Instant),
// Update [`Time`] with the last update time + a specified `Duration`
/// [`Time`] will be incremented by the specified [`Duration`] each frame.
ManualDuration(Duration),
}

/// Channel resource used to receive time from render world
/// Channel resource used to receive time from the render world.
#[derive(Resource)]
pub struct TimeReceiver(pub Receiver<Instant>);

/// Channel resource used to send time from render world
/// Channel resource used to send time from the render world.
#[derive(Resource)]
pub struct TimeSender(pub Sender<Instant>);

/// Creates channels used for sending time between render world and app world
/// Creates channels used for sending time between the render world and the main world.
pub fn create_time_channels() -> (TimeSender, TimeReceiver) {
// bound the channel to 2 since when pipelined the render phase can finish before
// the time system runs.
Expand Down