diff --git a/src/components.rs b/src/components.rs index 93974f2..b2de89f 100644 --- a/src/components.rs +++ b/src/components.rs @@ -19,6 +19,9 @@ pub struct HUDRoot; #[derive(Component)] pub struct GameTimerDisplay; +#[derive(Component)] +pub struct NetworkStatsDisplay; + #[derive(Component)] pub struct PlayerPortraitDisplay; diff --git a/src/lib.rs b/src/lib.rs index 1620118..a6dfe99 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,7 @@ mod web; use bevy::{ecs as bevy_ecs, prelude::*}; use bevy_ggrs::prelude::*; +use types::Cooldown; #[cfg(target_arch = "wasm32")] use wasm_bindgen::prelude::*; @@ -72,10 +73,10 @@ pub fn run() { .init_resource::() .init_resource::() .add_state::() - .insert_resource(NetworkStatsTimer(Timer::from_seconds( - 2.0, - TimerMode::Repeating, - ))) + .insert_resource(NetworkStatsCooldown { + cooldown: Cooldown::from_seconds(1.0), + print_cooldown: 0, + }) .add_systems(Update, print_network_stats_system) .add_systems( OnEnter(AppState::Lobby), diff --git a/src/resources.rs b/src/resources.rs index 2e0bd9f..8784d99 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -5,11 +5,14 @@ use rand::{rngs::StdRng, seq::IteratorRandom, Rng}; use crate::{ components::Position, constants::COLORS, - types::{Direction, ICEServerConfig, PlayerID, PostFreezeAction}, + types::{Cooldown, Direction, ICEServerConfig, PlayerID, PostFreezeAction}, }; #[derive(Resource)] -pub struct NetworkStatsTimer(pub Timer); +pub struct NetworkStatsCooldown { + pub cooldown: Cooldown, + pub print_cooldown: usize, +} #[derive(Resource)] pub struct Fonts { diff --git a/src/systems.rs b/src/systems.rs index 59db101..350c9e1 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -41,19 +41,54 @@ use crate::{ pub fn print_network_stats_system( time: Res