Skip to content

Commit

Permalink
Multiplayer: impl ping stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Indy2222 committed Jul 7, 2023
1 parent 06eeb60 commit e2615c8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/multiplayer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use bevy::{app::PluginGroupBuilder, prelude::*};
use game::GamePlugin;
use lifecycle::LifecyclePlugin;
use messages::MessagesPlugin;
use stats::StatsPlugin;

pub use crate::{
config::{NetGameConf, ServerPort},
Expand All @@ -25,6 +26,7 @@ mod lifecycle;
mod messages;
mod netstate;
mod network;
mod stats;

pub struct MultiplayerPluginGroup;

Expand All @@ -36,5 +38,6 @@ impl PluginGroup for MultiplayerPluginGroup {
.add(NetworkPlugin)
.add(MessagesPlugin)
.add(GamePlugin)
.add(StatsPlugin)
}
}
30 changes: 30 additions & 0 deletions crates/multiplayer/src/stats.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use bevy::prelude::*;

pub(crate) struct StatsPlugin;

impl Plugin for StatsPlugin {
fn build(&self, app: &mut App) {
app.add_system(setup.in_schedule(OnEnter(NetState::Joined)))
.add_system(cleanup.in_schedule(OnExit(NetState::Joined)))
.add_system(
// TODO periadically
ping.in_base_set(GameSet::PostUpdate)
.before(MessagesSet::SendMessages),
)
.add_system(
pong.in_base_set(GameSet::PreMovement)
.run_if(on_event::<FromMainServerEvent>())
.after(MessagesSet::RecvMessages),
);

// TODO
}
}

fn setup() {}

fn cleanup() {}

fn ping() {}

fn pong() {}

0 comments on commit e2615c8

Please sign in to comment.