Skip to content

Commit 866958b

Browse files
committed
Formatting fixes
1 parent 7f22e4a commit 866958b

File tree

10 files changed

+129
-103
lines changed

10 files changed

+129
-103
lines changed

crates/bevy_gilrs/src/rumble.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use bevy_ecs::{
55
};
66
use bevy_input::gamepad::{GamepadRumbleIntensity, GamepadRumbleRequest};
77
use bevy_log::{debug, warn};
8-
use bevy_time::{Time, Real};
8+
use bevy_time::{Real, Time};
99
use bevy_utils::{Duration, HashMap};
1010
use gilrs::{
1111
ff::{self, BaseEffect, BaseEffectType, Repeat, Replay},

crates/bevy_time/src/common_conditions.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ mod tests {
5151
#[test]
5252
fn distributive_run_if_compiles() {
5353
Schedule::default().add_systems(
54-
(test_system, test_system)
55-
.distributive_run_if(on_timer(Duration::new(1, 0)))
54+
(test_system, test_system).distributive_run_if(on_timer(Duration::new(1, 0))),
5655
);
5756
}
5857
}

crates/bevy_time/src/fixed.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,35 @@
1-
use bevy_utils::Duration;
21
use bevy_ecs::world::World;
32
use bevy_reflect::{FromReflect, Reflect};
3+
use bevy_utils::Duration;
44

5-
use crate::FixedUpdate;
6-
use crate::time::Time;
7-
use crate::virt::Virtual;
5+
use crate::{time::Time, virt::Virtual, FixedUpdate};
86

97
/// The fixed timestep game clock following virtual time.
108
///
119
/// Normally used as `Time<Fixed>`. It is automatically inserted as a resource
1210
/// by `TimePlugin` and updated based on `Time<Virtual>`. The fixed clock is
1311
/// automatically set as the generic `Time` resource during `FixedUpdate`
1412
/// schedule processing.
15-
///
13+
///
1614
/// The fixed timestep game clock runs at a regular interval and is extremely
17-
/// useful for steady, frame-rate independent gameplay logic and physics.
18-
///
15+
/// useful for steady, frame-rate independent gameplay logic and physics.
16+
///
1917
/// To run a system on a fixed timestep, add it to the `FixedUpdate` schedule.
2018
/// This schedule is run a number of times between `PreUpdate` and `Update`
2119
/// according to the accumulated `overstep()` time divided by the `timestep()`.
2220
/// This means the schedule may run 0, 1 or more times during a single update.
23-
///
21+
///
2422
/// `Time<Fixed>` and the generic `Time` resource will report a `delta()` equal
2523
/// to `timestep()` and always grow `elapsed()` by one `timestep()` per
2624
/// iteration.
27-
///
25+
///
2826
/// The fixed timestep clock follows the `Time<Virtual>` clock, which means it
2927
/// is affected by `paused()`, `relative_speed()` and `max_delta()` from virtual
3028
/// time. If the virtual clock is paused, the `FixedUpdate` schedule will not
3129
/// run. It is guaranteed that the `elapsed()` time in `Time<Fixed>` is always
3230
/// between the previous `elapsed()` and the next `elapsed()` value in
3331
/// `Time<Virtual>`, so the values are compatible.
34-
///
32+
///
3533
/// Changing the timestep size while the game is running should not normally be
3634
/// done, as having a regular interval is the point of this schedule, but it may
3735
/// be necessary for effects like "bullet-time" if the normal granularity of the
@@ -78,34 +76,41 @@ impl Time<Fixed> {
7876

7977
/// Sets the amount of virtual time that must pass before the fixed timestep
8078
/// schedule is run again, as [`Duration`].
81-
///
79+
///
8280
/// Takes effect immediately on the next run of the schedule, respecting
8381
/// what is currently in `overstep()`.
8482
pub fn set_timestep(&mut self, timestep: Duration) {
85-
assert_ne!(timestep, Duration::ZERO, "attempted to set fixed timestep to zero");
83+
assert_ne!(
84+
timestep,
85+
Duration::ZERO,
86+
"attempted to set fixed timestep to zero"
87+
);
8688
self.context_mut().timestep = timestep;
8789
}
8890

8991
/// Sets the amount of virtual time that must pass before the fixed timestep
9092
/// schedule is run again, as seconds.
91-
///
93+
///
9294
/// Timestep is stored as a `Duration`, which has fixed nanosecond
9395
/// resolution and will be converted from the floating point number.
94-
///
96+
///
9597
/// Takes effect immediately on the next run of the schedule, respecting
9698
/// what is currently in `overstep()`.
9799
pub fn set_timestep_seconds(&mut self, seconds: f64) {
98-
assert!(seconds.is_sign_positive(), "seconds less than or equal to zero");
100+
assert!(
101+
seconds.is_sign_positive(),
102+
"seconds less than or equal to zero"
103+
);
99104
assert!(seconds.is_finite(), "seconds is infinite");
100105
self.set_timestep(Duration::from_secs_f64(seconds));
101106
}
102107

103108
/// Sets the amount of virtual time that must pass before the fixed timestep
104109
/// schedule is run again, as frequency.
105-
///
110+
///
106111
/// The timestep value is set to `1 / hz`, converted to a `Duration` which
107112
/// has fixed nanosecond resolution.
108-
///
113+
///
109114
/// Takes effect immediately on the next run of the schedule, respecting
110115
/// what is currently in `overstep()`.
111116
pub fn set_timestep_hz(&mut self, hz: f64) {
@@ -159,9 +164,7 @@ impl Default for Fixed {
159164
}
160165
}
161166

162-
pub fn run_fixed_update_schedule(
163-
world: &mut World
164-
) {
167+
pub fn run_fixed_update_schedule(world: &mut World) {
165168
let delta = world.resource::<Time<Virtual>>().delta();
166169
world.resource_mut::<Time<Fixed>>().accumulate(delta);
167170

crates/bevy_time/src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
/// Common run conditions
44
pub mod common_conditions;
5+
mod fixed;
6+
mod real;
57
mod stopwatch;
68
#[allow(clippy::module_inception)]
79
mod time;
810
mod timer;
9-
mod real;
10-
mod fixed;
1111
mod virt;
1212

13+
pub use fixed::*;
14+
pub use real::*;
1315
pub use stopwatch::*;
1416
pub use time::*;
1517
pub use timer::*;
16-
pub use real::*;
1718
pub use virt::*;
18-
pub use fixed::*;
1919

2020
use bevy_ecs::system::{Res, ResMut};
2121
use bevy_utils::{tracing::warn, Duration, Instant};
@@ -24,7 +24,7 @@ use crossbeam_channel::{Receiver, Sender};
2424
pub mod prelude {
2525
//! The Bevy Time Prelude.
2626
#[doc(hidden)]
27-
pub use crate::{Time, Timer, TimerMode, Real, Virtual, Fixed};
27+
pub use crate::{Fixed, Real, Time, Timer, TimerMode, Virtual};
2828
}
2929

3030
use bevy_app::{prelude::*, RunFixedUpdateLoop};
@@ -52,7 +52,10 @@ impl Plugin for TimePlugin {
5252
.register_type::<Time<Fixed>>()
5353
.register_type::<Timer>()
5454
.register_type::<Stopwatch>()
55-
.add_systems(First, (time_system, virtual_time_system.after(time_system)).in_set(TimeSystem))
55+
.add_systems(
56+
First,
57+
(time_system, virtual_time_system.after(time_system)).in_set(TimeSystem),
58+
)
5659
.add_systems(RunFixedUpdateLoop, run_fixed_update_schedule);
5760

5861
#[cfg(feature = "bevy_ci_testing")]
@@ -72,8 +75,8 @@ impl Plugin for TimePlugin {
7275

7376
/// Configuration resource used to determine how the time system should run.
7477
///
75-
/// For most cases, [`TimeUpdateStrategy::Automatic`] is fine. When writing tests, dealing with networking, or similar
76-
/// you may prefer to set the next [`Time`] value manually.
78+
/// For most cases, [`TimeUpdateStrategy::Automatic`] is fine. When writing tests, dealing with
79+
/// networking, or similar you may prefer to set the next [`Time`] value manually.
7780
#[derive(Resource, Default)]
7881
pub enum TimeUpdateStrategy {
7982
#[default]
@@ -100,8 +103,8 @@ pub fn create_time_channels() -> (TimeSender, TimeReceiver) {
100103
(TimeSender(s), TimeReceiver(r))
101104
}
102105

103-
/// The system used to update the [`Time`] used by app logic. If there is a render world the time is sent from
104-
/// there to this system through channels. Otherwise the time is updated in this system.
106+
/// The system used to update the [`Time`] used by app logic. If there is a render world the time is
107+
/// sent from there to this system through channels. Otherwise the time is updated in this system.
105108
fn time_system(
106109
mut time: ResMut<Time<Real>>,
107110
update_strategy: Res<TimeUpdateStrategy>,

crates/bevy_time/src/real.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
use bevy_utils::{Duration, Instant};
21
use bevy_reflect::{FromReflect, Reflect};
2+
use bevy_utils::{Duration, Instant};
33

44
use crate::time::Time;
55

66
/// Real time clock representing elapsed wall clock time.
7-
///
7+
///
88
/// Normally used as `Time<Real>`. It is automatically inserted as a resource by
99
/// `TimePlugin` and updated with time instants based on `TimeUpdateStrategy`.
10-
///
10+
///
1111
/// The `delta()` and `elapsed()` values of this clock should be used for
1212
/// anything which deals specifically with real time (wall clock time). It will
1313
/// not be affected by relative game speed adjustments, pausing or other
1414
/// adjustments.
15-
///
15+
///
1616
/// The clock does not count time from `startup()` to `first_update()` into
1717
/// elapsed, but instead will start counting time from the first update call.
1818
/// `delta()` and `elapsed()` will report zero on the first update as there is
1919
/// no previous update instant. This means that a `delta()` of zero must be
2020
/// handled without errors in application logic, as it may theoretically also
2121
/// happen at other times.
22-
///
22+
///
2323
/// `Instant`s for `startup()`, `first_update()` and `last_update()` are
2424
/// recorded and accessible.
2525
#[derive(Debug, Copy, Clone, Reflect, FromReflect)]
@@ -60,7 +60,7 @@ impl Time<Real> {
6060
/// Updates time with a specified [`Duration`].
6161
///
6262
/// This method is provided for use in tests.
63-
///
63+
///
6464
/// Calling this method as part of your app will most likely result in inaccurate timekeeping,
6565
/// as the `Time` resource is ordinarily managed by the [`TimePlugin`](crate::TimePlugin).
6666
pub fn update_with_duration(&mut self, duration: Duration) {
@@ -71,7 +71,7 @@ impl Time<Real> {
7171
/// Updates time with a specified [`Instant`].
7272
///
7373
/// This method is provided for use in tests.
74-
///
74+
///
7575
/// Calling this method as part of your app will most likely result in inaccurate timekeeping,
7676
/// as the `Time` resource is ordinarily managed by the [`TimePlugin`](crate::TimePlugin).
7777
pub fn update_with_instant(&mut self, instant: Instant) {

crates/bevy_time/src/stopwatch.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use bevy_reflect::prelude::*;
2-
use bevy_reflect::Reflect;
1+
use bevy_reflect::{prelude::*, Reflect};
32
use bevy_utils::Duration;
43

54
/// A Stopwatch is a struct that track elapsed time when started.

0 commit comments

Comments
 (0)