bevy/src/diagnostic/mod.rs

41 lines
1.1 KiB
Rust
Raw Normal View History

2020-04-05 21:12:14 +00:00
mod diagnostic;
2020-04-04 19:43:16 +00:00
pub mod diagnostics;
2020-04-05 21:12:14 +00:00
pub use diagnostic::*;
2020-03-27 22:03:47 +00:00
2020-04-05 21:12:14 +00:00
use crate::app::{plugin::AppPlugin, AppBuilder};
use std::time::Duration;
use diagnostics::{print_diagnostics_system, frame_time_diagnostic_system};
2020-03-27 22:03:47 +00:00
2020-04-05 21:12:14 +00:00
pub struct DiagnosticsPlugin {
pub print_wait_duration: Duration,
pub print_diagnostics: bool,
pub add_defaults: bool,
2020-03-27 22:03:47 +00:00
}
2020-04-05 21:12:14 +00:00
impl Default for DiagnosticsPlugin {
fn default() -> Self {
DiagnosticsPlugin {
print_wait_duration: Duration::from_secs_f64(1.0),
print_diagnostics: false,
add_defaults: true,
2020-03-27 22:03:47 +00:00
}
}
}
2020-04-05 21:12:14 +00:00
impl AppPlugin for DiagnosticsPlugin {
fn build(&self, mut app: AppBuilder) -> AppBuilder {
app = app.add_resource(Diagnostics::default());
if self.add_defaults {
let frame_time_diagnostic_system =
{ frame_time_diagnostic_system(&mut app.resources, 10) };
app = app.add_system(frame_time_diagnostic_system)
}
2020-03-27 22:03:47 +00:00
2020-04-05 21:12:14 +00:00
if self.print_diagnostics {
app = app.add_system(print_diagnostics_system(self.print_wait_duration));
2020-03-27 22:03:47 +00:00
}
2020-04-05 21:12:14 +00:00
app
2020-03-27 22:03:47 +00:00
}
2020-04-04 19:43:16 +00:00
}