From de7ff295e1059c2765f0241bccb20acb6983778c Mon Sep 17 00:00:00 2001 From: IcyLeave6109 <33421921+juliohq@users.noreply.github.com> Date: Sun, 12 May 2024 20:19:07 -0300 Subject: [PATCH] Make `bevy_time` optionally depend on `bevy_reflect` (#13263) # Objective Fixes #13246. --- crates/bevy_time/Cargo.toml | 4 ++-- crates/bevy_time/src/fixed.rs | 4 +++- crates/bevy_time/src/lib.rs | 19 ++++++++++++------- crates/bevy_time/src/real.rs | 4 +++- crates/bevy_time/src/stopwatch.rs | 5 +++-- crates/bevy_time/src/time.rs | 9 ++++++--- crates/bevy_time/src/timer.rs | 9 +++++---- crates/bevy_time/src/virt.rs | 4 +++- 8 files changed, 37 insertions(+), 21 deletions(-) diff --git a/crates/bevy_time/Cargo.toml b/crates/bevy_time/Cargo.toml index a2ea432d86..9fcfaf93df 100644 --- a/crates/bevy_time/Cargo.toml +++ b/crates/bevy_time/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" keywords = ["bevy"] [features] -default = [] +default = ["bevy_reflect"] serialize = ["serde"] [dependencies] @@ -20,7 +20,7 @@ bevy_ecs = { path = "../bevy_ecs", version = "0.14.0-dev", features = [ ] } bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev", features = [ "bevy", -] } +], optional = true } bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" } # other diff --git a/crates/bevy_time/src/fixed.rs b/crates/bevy_time/src/fixed.rs index 9e5314d4d8..a497639055 100644 --- a/crates/bevy_time/src/fixed.rs +++ b/crates/bevy_time/src/fixed.rs @@ -1,5 +1,6 @@ use bevy_app::FixedMain; use bevy_ecs::world::World; +#[cfg(feature = "bevy_reflect")] use bevy_reflect::Reflect; use bevy_utils::Duration; @@ -63,7 +64,8 @@ use crate::{time::Time, virt::Virtual}; /// [`FixedUpdate`](bevy_app::FixedUpdate), even if it is still during the same /// frame. Any [`overstep()`](Time::overstep) present in the accumulator will be /// processed according to the new [`timestep()`](Time::timestep) value. -#[derive(Debug, Copy, Clone, Reflect)] +#[derive(Debug, Copy, Clone)] +#[cfg_attr(feature = "bevy_reflect", derive(Reflect))] pub struct Fixed { timestep: Duration, overstep: Duration, diff --git a/crates/bevy_time/src/lib.rs b/crates/bevy_time/src/lib.rs index 912a600bb2..9778e1517e 100644 --- a/crates/bevy_time/src/lib.rs +++ b/crates/bevy_time/src/lib.rs @@ -51,13 +51,18 @@ impl Plugin for TimePlugin { .init_resource::>() .init_resource::>() .init_resource::>() - .init_resource::() - .register_type::