add renet_steam support (#92)
This commit is contained in:
@@ -34,7 +34,7 @@ pub mod utils;
|
||||
pub mod water;
|
||||
|
||||
use crate::{
|
||||
config::NetworkingConfig,
|
||||
config::NetConfig,
|
||||
heads_database::{HeadDatabaseAsset, HeadsDatabase},
|
||||
protocol::{PlayerIdCounter, messages::AssignClientPlayer},
|
||||
tb_entities::SpawnPoint,
|
||||
@@ -47,6 +47,7 @@ use bevy_common_assets::ron::RonAssetPlugin;
|
||||
use bevy_replicon::{RepliconPlugins, prelude::ClientId};
|
||||
use bevy_replicon_renet::RepliconRenetPlugins;
|
||||
use bevy_sprite3d::Sprite3dPlugin;
|
||||
use bevy_steamworks::SteamworksEvent;
|
||||
use bevy_trenchbroom::{
|
||||
TrenchBroomPlugins, config::TrenchBroomConfig, prelude::TrenchBroomPhysicsPlugin,
|
||||
};
|
||||
@@ -148,21 +149,21 @@ pub fn plugin(app: &mut App) {
|
||||
if cfg!(feature = "client") {
|
||||
app.add_systems(
|
||||
OnEnter(GameState::Waiting),
|
||||
start_solo_client
|
||||
.run_if(|config: Res<NetworkingConfig>| config.server.is_none() && !config.host),
|
||||
start_solo_client.run_if(|config: Res<NetConfig>| config.is_singleplayer()),
|
||||
);
|
||||
app.add_systems(
|
||||
OnEnter(GameState::Waiting),
|
||||
start_listen_server
|
||||
.run_if(|config: Res<NetworkingConfig>| config.server.is_none() && config.host),
|
||||
start_listen_server.run_if(|config: Res<NetConfig>| config.is_host()),
|
||||
);
|
||||
app.add_systems(
|
||||
OnEnter(GameState::Waiting),
|
||||
start_client.run_if(|config: Res<NetworkingConfig>| config.server.is_some()),
|
||||
start_client.run_if(|config: Res<NetConfig>| config.is_client()),
|
||||
);
|
||||
} else {
|
||||
app.add_systems(OnEnter(GameState::Waiting), start_dedicated_server);
|
||||
}
|
||||
|
||||
app.add_systems(Update, log_steam_events);
|
||||
}
|
||||
|
||||
#[derive(Resource, Reflect, Debug)]
|
||||
@@ -192,6 +193,17 @@ pub enum GameState {
|
||||
Playing,
|
||||
}
|
||||
|
||||
fn log_steam_events(events: Option<MessageReader<SteamworksEvent>>) {
|
||||
let Some(mut events) = events else {
|
||||
return;
|
||||
};
|
||||
|
||||
for event in events.read() {
|
||||
let SteamworksEvent::CallbackResult(result) = event;
|
||||
info!("steam: {:?}", result);
|
||||
}
|
||||
}
|
||||
|
||||
fn start_solo_client(
|
||||
commands: Commands,
|
||||
mut next: ResMut<NextState<GameState>>,
|
||||
|
||||
Reference in New Issue
Block a user