Move egui layer to a separate DebugGuiStack structure

This commit is contained in:
Tony Klink 2024-03-31 14:09:38 -06:00
parent 3f367e19ac
commit 92c0278ef0
Signed by: klink
GPG key ID: 85175567C4D19231
5 changed files with 104 additions and 9 deletions

43
src/core/time.rs Normal file
View file

@ -0,0 +1,43 @@
//! Provides time related functionality for Clocks.
use std::time::{Duration, Instant};
use flax::component;
component! {
pub clock: Clock,
}
/// Measures high precision time
#[allow(dead_code)]
pub struct Clock {
start: Instant,
}
#[allow(dead_code)]
impl Clock {
// Creates and starts a new clock
pub fn new() -> Self {
Clock {
start: Instant::now(),
}
}
// Returns the elapsed time
pub fn elapsed(&self) -> Duration {
Instant::now() - self.start
}
// Resets the clock and returns the elapsed time
pub fn reset(&mut self) -> Duration {
let elapsed = self.elapsed();
self.start = Instant::now();
elapsed
}
}
impl Default for Clock {
fn default() -> Self {
Self::new()
}
}