Use Time resource instead of Extracting Time (#7316)

# Objective

- "Fixes #7308".

## Solution

- Use the `Time` `Resource` instead of `Extract<Res<Time>>`
This commit is contained in:
targrub 2023-01-21 17:55:39 +00:00
parent cb4e8c832c
commit ff5e4fd1ec

View file

@ -8,7 +8,7 @@ use bevy::{
math::{DVec2, DVec3}, math::{DVec2, DVec3},
pbr::{ExtractedPointLight, GlobalLightMeta}, pbr::{ExtractedPointLight, GlobalLightMeta},
prelude::*, prelude::*,
render::{camera::ScalingMode, Extract, RenderApp, RenderStage}, render::{camera::ScalingMode, RenderApp, RenderStage},
window::{PresentMode, WindowPlugin}, window::{PresentMode, WindowPlugin},
}; };
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
@ -156,15 +156,13 @@ impl Plugin for LogVisibleLights {
Err(_) => return, Err(_) => return,
}; };
render_app render_app.add_system_to_stage(RenderStage::Prepare, print_visible_light_count);
.add_system_to_stage(RenderStage::Extract, extract_time)
.add_system_to_stage(RenderStage::Prepare, print_visible_light_count);
} }
} }
// System for printing the number of meshes on every tick of the timer // System for printing the number of meshes on every tick of the timer
fn print_visible_light_count( fn print_visible_light_count(
time: Res<ExtractedTime>, time: Res<Time>,
mut timer: Local<PrintingTimer>, mut timer: Local<PrintingTimer>,
visible: Query<&ExtractedPointLight>, visible: Query<&ExtractedPointLight>,
global_light_meta: Res<GlobalLightMeta>, global_light_meta: Res<GlobalLightMeta>,
@ -180,13 +178,6 @@ fn print_visible_light_count(
} }
} }
#[derive(Resource, Deref, DerefMut)]
pub struct ExtractedTime(Time);
fn extract_time(mut commands: Commands, time: Extract<Res<Time>>) {
commands.insert_resource(ExtractedTime(time.clone()));
}
struct PrintingTimer(Timer); struct PrintingTimer(Timer);
impl Default for PrintingTimer { impl Default for PrintingTimer {