From 7ae386176889a87d5092fc8ea0b4896b66b0ecc3 Mon Sep 17 00:00:00 2001 From: Blair Hines Date: Mon, 26 Aug 2024 19:44:41 -0400 Subject: [PATCH] fix: Make adjustments --- crates/bevy_app/src/lib.rs | 5 +++-- crates/bevy_app/src/main_schedule.rs | 1 + crates/bevy_time/src/fixed.rs | 3 +++ crates/bevy_time/src/lib.rs | 5 ++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/bevy_app/src/lib.rs b/crates/bevy_app/src/lib.rs index 0c6cfc8c32aeb..e8f5b5228aedd 100644 --- a/crates/bevy_app/src/lib.rs +++ b/crates/bevy_app/src/lib.rs @@ -32,13 +32,14 @@ pub mod prelude { #[cfg(feature = "fixed_time")] pub use crate::main_schedule::{ FixedFirst, FixedLast, FixedPostUpdate, FixedPreUpdate, FixedUpdate, RunFixedMainLoop, + RunFixedMainLoopSystem, }; #[doc(hidden)] pub use crate::{ app::{App, AppExit}, main_schedule::{ - First, Last, Main, PostStartup, PostUpdate, PreStartup, PreUpdate, - RunFixedMainLoopSystem, SpawnScene, Startup, Update, + First, Last, Main, PostStartup, PostUpdate, PreStartup, PreUpdate, SpawnScene, Startup, + Update, }, sub_app::SubApp, Plugin, PluginGroup, diff --git a/crates/bevy_app/src/main_schedule.rs b/crates/bevy_app/src/main_schedule.rs index f37d8fab0c474..57064a9309044 100644 --- a/crates/bevy_app/src/main_schedule.rs +++ b/crates/bevy_app/src/main_schedule.rs @@ -394,6 +394,7 @@ impl FixedMain { /// /// Note that in contrast to most other Bevy schedules, systems added directly to /// [`RunFixedMainLoop`] will *not* be parallelized between each other. +#[cfg(feature = "fixed_time")] #[derive(Debug, Hash, PartialEq, Eq, Copy, Clone, SystemSet)] pub enum RunFixedMainLoopSystem { /// Runs before the fixed update logic. diff --git a/crates/bevy_time/src/fixed.rs b/crates/bevy_time/src/fixed.rs index 9e5c7c2f2ce87..c0aed88e4f1ab 100644 --- a/crates/bevy_time/src/fixed.rs +++ b/crates/bevy_time/src/fixed.rs @@ -69,12 +69,14 @@ use crate::virt::Virtual; /// frame. Any [`overstep()`](Time::overstep) present in the accumulator will be /// processed according to the new [`timestep()`](Time::timestep) value. #[derive(Debug, Copy, Clone)] +#[cfg(feature = "fixed_time")] #[cfg_attr(feature = "bevy_reflect", derive(Reflect))] pub struct Fixed { timestep: Duration, overstep: Duration, } +#[cfg(feature = "fixed_time")] impl Time { /// Corresponds to 64 Hz. const DEFAULT_TIMESTEP: Duration = Duration::from_micros(15625); @@ -229,6 +231,7 @@ impl Time { } } +#[cfg(feature = "fixed_time")] impl Default for Fixed { fn default() -> Self { Self { diff --git a/crates/bevy_time/src/lib.rs b/crates/bevy_time/src/lib.rs index f4130899354d5..d1a6f2c45f0ab 100644 --- a/crates/bevy_time/src/lib.rs +++ b/crates/bevy_time/src/lib.rs @@ -194,6 +194,7 @@ mod tests { counter.0 += 1; } + #[cfg(feature = "fixed_time")] fn report_time( mut frame_count: Local, virtual_time: Res>, @@ -214,6 +215,7 @@ mod tests { } #[test] + #[cfg(feature = "fixed_time")] fn fixed_main_schedule_should_run_with_time_plugin_enabled() { // Set the time step to just over half the fixed update timestep // This way, it will have not accumulated enough time to run the fixed update after one update @@ -222,7 +224,6 @@ mod tests { let time_step = fixed_update_timestep / 2 + Duration::from_millis(1); let mut app = App::new(); - #[cfg(feature = "fixed_time")] app.add_systems(FixedUpdate, count_fixed_updates); app.add_plugins(TimePlugin) @@ -272,6 +273,7 @@ mod tests { } #[test] + #[cfg(feature = "fixed_time")] fn events_get_dropped_regression_test_11528() -> Result<(), impl Error> { let (tx1, rx1) = std::sync::mpsc::channel(); let (tx2, rx2) = std::sync::mpsc::channel(); @@ -313,6 +315,7 @@ mod tests { } #[test] + #[cfg(feature = "fixed_time")] fn event_update_should_wait_for_fixed_main() { // Set the time step to just over half the fixed update timestep // This way, it will have not accumulated enough time to run the fixed update after one update