add convenience methods to actiondebuginstant
This commit is contained in:
parent
80e2a79de1
commit
09581f5848
2 changed files with 13 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
||||||
use std::time::Instant;
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
prelude::{Component, ReflectResource, Resource, Vec3},
|
prelude::{Component, ReflectResource, Resource, Vec3},
|
||||||
|
@ -14,6 +14,16 @@ impl Default for ActionDebugInstant {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ActionDebugInstant {
|
||||||
|
pub fn reset(&mut self) {
|
||||||
|
self.0 = Instant::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn elapsed(&self) -> Duration {
|
||||||
|
self.0.elapsed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Component)]
|
#[derive(Debug, Component)]
|
||||||
pub(super) struct Tunneling {
|
pub(super) struct Tunneling {
|
||||||
pub frames: usize,
|
pub frames: usize,
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
#[cfg(feature = "inspector")]
|
|
||||||
use std::time::Instant;
|
|
||||||
|
|
||||||
use bevy::prelude::{Commands, Entity, Query, Res, ResMut, Time, Transform, Vec3, With, Without};
|
use bevy::prelude::{Commands, Entity, Query, Res, ResMut, Time, Transform, Vec3, With, Without};
|
||||||
use bevy_rapier3d::prelude::{
|
use bevy_rapier3d::prelude::{
|
||||||
|
@ -68,10 +66,9 @@ pub(super) fn falling_cat(
|
||||||
|
|
||||||
#[cfg(feature = "inspector")]
|
#[cfg(feature = "inspector")]
|
||||||
{
|
{
|
||||||
let now = Instant::now();
|
if debug_instant.elapsed().as_millis() > 1000 {
|
||||||
if (now - debug_instant.0).as_millis() > 1000 {
|
|
||||||
dbg!(&control_vars, mag);
|
dbg!(&control_vars, mag);
|
||||||
debug_instant.0 = now;
|
debug_instant.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
control_vars.decay();
|
control_vars.decay();
|
||||||
|
|
Loading…
Reference in a new issue