diff --git a/crates/bevy_core/src/time/stopwatch.rs b/crates/bevy_core/src/time/stopwatch.rs index 9fa84cba07a6b..c13f2773918a8 100644 --- a/crates/bevy_core/src/time/stopwatch.rs +++ b/crates/bevy_core/src/time/stopwatch.rs @@ -1,4 +1,3 @@ -use bevy_ecs::{component::Component, reflect::ReflectComponent}; use bevy_reflect::Reflect; use bevy_utils::Duration; @@ -23,8 +22,7 @@ use bevy_utils::Duration; /// assert!(stopwatch.paused()); /// assert_eq!(stopwatch.elapsed_secs(), 0.0); /// ``` -#[derive(Component, Clone, Debug, Default, Reflect)] -#[reflect(Component)] +#[derive(Clone, Debug, Default, Reflect)] pub struct Stopwatch { elapsed: Duration, paused: bool, diff --git a/crates/bevy_core/src/time/timer.rs b/crates/bevy_core/src/time/timer.rs index b9bd0800de38e..0cf3e89d4f5fa 100644 --- a/crates/bevy_core/src/time/timer.rs +++ b/crates/bevy_core/src/time/timer.rs @@ -1,5 +1,4 @@ use crate::Stopwatch; -use bevy_ecs::{component::Component, reflect::ReflectComponent}; use bevy_reflect::Reflect; use bevy_utils::Duration; @@ -10,8 +9,7 @@ use bevy_utils::Duration; /// exceeded, and can still be reset at any given point. /// /// Paused timers will not have elapsed time increased. -#[derive(Component, Clone, Debug, Default, Reflect)] -#[reflect(Component)] +#[derive(Clone, Debug, Default, Reflect)] pub struct Timer { stopwatch: Stopwatch, duration: Duration, diff --git a/examples/2d/contributors.rs b/examples/2d/contributors.rs index cefce614588a7..cc5bd3c42c34a 100644 --- a/examples/2d/contributors.rs +++ b/examples/2d/contributors.rs @@ -15,6 +15,7 @@ fn main() { .add_system(move_system) .add_system(collision_system) .add_system(select_system) + .insert_resource(SelectTimer(Timer::from_seconds(SHOWCASE_TIMER_SECS, true))) .run(); } @@ -26,8 +27,7 @@ struct ContributorSelection { idx: usize, } -#[derive(Component)] -struct SelectTimer; +struct SelectTimer(Timer); #[derive(Component)] struct ContributorDisplay; @@ -120,8 +120,6 @@ fn setup(mut commands: Commands, asset_server: Res) { commands.spawn_bundle(OrthographicCameraBundle::new_2d()); commands.spawn_bundle(UiCameraBundle::default()); - commands.spawn_bundle((SelectTimer, Timer::from_seconds(SHOWCASE_TIMER_SECS, true))); - commands .spawn() .insert(ContributorDisplay) @@ -157,22 +155,13 @@ fn setup(mut commands: Commands, asset_server: Res) { /// Finds the next contributor to display and selects the entity fn select_system( + mut timer: ResMut, mut contributor_selection: ResMut, mut text_query: Query<&mut Text, With>, - mut timer_query: Query<&mut Timer, With>, mut query: Query<(&Contributor, &mut Sprite, &mut Transform)>, time: Res