set_rich_presence, more logging
This commit is contained in:
@@ -61,6 +61,14 @@ fn test_steam_system(steam_client: Res<Client>) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let id = steam_client.user().steam_id();
|
||||||
|
|
||||||
|
info!("Steam ID: {:?}", id);
|
||||||
|
|
||||||
|
steam_client
|
||||||
|
.friends()
|
||||||
|
.set_rich_presence("connect", Some(id.raw().to_string().as_str()));
|
||||||
|
|
||||||
for friend in steam_client.friends().get_friends(FriendFlags::IMMEDIATE) {
|
for friend in steam_client.friends().get_friends(FriendFlags::IMMEDIATE) {
|
||||||
info!(
|
info!(
|
||||||
"Steam Friend: {:?} - {}({:?})",
|
"Steam Friend: {:?} - {}({:?})",
|
||||||
|
|||||||
@@ -45,12 +45,14 @@ use bevy::app::ScheduleRunnerPlugin;
|
|||||||
use bevy::{core_pipeline::tonemapping::Tonemapping, prelude::*};
|
use bevy::{core_pipeline::tonemapping::Tonemapping, prelude::*};
|
||||||
use bevy_common_assets::ron::RonAssetPlugin;
|
use bevy_common_assets::ron::RonAssetPlugin;
|
||||||
use bevy_replicon::{RepliconPlugins, prelude::ClientId};
|
use bevy_replicon::{RepliconPlugins, prelude::ClientId};
|
||||||
use bevy_replicon_renet::RepliconRenetPlugins;
|
use bevy_replicon_renet::{RepliconRenetPlugins, steam::SteamServerPlugin};
|
||||||
use bevy_sprite3d::Sprite3dPlugin;
|
use bevy_sprite3d::Sprite3dPlugin;
|
||||||
|
use bevy_steamworks::SteamworksEvent;
|
||||||
use bevy_trenchbroom::{
|
use bevy_trenchbroom::{
|
||||||
TrenchBroomPlugins, config::TrenchBroomConfig, prelude::TrenchBroomPhysicsPlugin,
|
TrenchBroomPlugins, config::TrenchBroomConfig, prelude::TrenchBroomPhysicsPlugin,
|
||||||
};
|
};
|
||||||
use bevy_trenchbroom_avian::AvianPhysicsBackend;
|
use bevy_trenchbroom_avian::AvianPhysicsBackend;
|
||||||
|
use steamworks::{CallbackResult, P2PSessionRequest};
|
||||||
use utils::{billboards, squish_animation};
|
use utils::{billboards, squish_animation};
|
||||||
|
|
||||||
pub const HEDZ_GREEN: Srgba = Srgba::rgb(0.0, 1.0, 0.0);
|
pub const HEDZ_GREEN: Srgba = Srgba::rgb(0.0, 1.0, 0.0);
|
||||||
@@ -90,6 +92,7 @@ pub fn launch() {
|
|||||||
.auto_open_threshold(bevy::log::tracing::level_filters::LevelFilter::OFF),
|
.auto_open_threshold(bevy::log::tracing::level_filters::LevelFilter::OFF),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
app.add_plugins(SteamServerPlugin);
|
||||||
app.add_plugins(PhysicsPlugins::default());
|
app.add_plugins(PhysicsPlugins::default());
|
||||||
app.add_plugins((RepliconPlugins, RepliconRenetPlugins));
|
app.add_plugins((RepliconPlugins, RepliconRenetPlugins));
|
||||||
app.add_plugins(Sprite3dPlugin);
|
app.add_plugins(Sprite3dPlugin);
|
||||||
@@ -163,6 +166,8 @@ pub fn plugin(app: &mut App) {
|
|||||||
} else {
|
} else {
|
||||||
app.add_systems(OnEnter(GameState::Waiting), start_dedicated_server);
|
app.add_systems(OnEnter(GameState::Waiting), start_dedicated_server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.add_systems(Update, accept_p2p_sessions);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource, Reflect, Debug)]
|
#[derive(Resource, Reflect, Debug)]
|
||||||
@@ -192,6 +197,23 @@ pub enum GameState {
|
|||||||
Playing,
|
Playing,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn accept_p2p_sessions(
|
||||||
|
mut events: MessageReader<SteamworksEvent>,
|
||||||
|
steam_client: Res<bevy_steamworks::Client>,
|
||||||
|
) {
|
||||||
|
for event in events.read() {
|
||||||
|
if let SteamworksEvent::CallbackResult(CallbackResult::P2PSessionRequest(
|
||||||
|
P2PSessionRequest { remote },
|
||||||
|
)) = event
|
||||||
|
{
|
||||||
|
info!("Accepting P2P session from: {:?}", remote);
|
||||||
|
steam_client.networking().accept_p2p_session(*remote);
|
||||||
|
} else {
|
||||||
|
info!("steamworks event: {:?}", event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn start_solo_client(
|
fn start_solo_client(
|
||||||
commands: Commands,
|
commands: Commands,
|
||||||
mut next: ResMut<NextState<GameState>>,
|
mut next: ResMut<NextState<GameState>>,
|
||||||
|
|||||||
@@ -76,10 +76,10 @@ fn open_renet_server(
|
|||||||
let client = (**steam_client).clone();
|
let client = (**steam_client).clone();
|
||||||
let transport = SteamServerTransport::new(client, steam_config)?;
|
let transport = SteamServerTransport::new(client, steam_config)?;
|
||||||
|
|
||||||
commands.insert_resource(server);
|
commands.queue(|w: &mut World| {
|
||||||
commands.insert_resource(transport);
|
w.insert_resource(server);
|
||||||
|
w.insert_non_send_resource(transport);
|
||||||
info!("hosting a server");
|
});
|
||||||
|
|
||||||
next.set(GameState::Playing);
|
next.set(GameState::Playing);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user