more steamworks test code
This commit is contained in:
44
src/main.rs
44
src/main.rs
@@ -37,7 +37,7 @@ use bevy::{
|
||||
};
|
||||
use bevy_common_assets::ron::RonAssetPlugin;
|
||||
use bevy_sprite3d::Sprite3dPlugin;
|
||||
use bevy_steamworks::{Client, FriendFlags, SteamworksPlugin};
|
||||
use bevy_steamworks::{Client, FriendFlags, SteamworksEvent, SteamworksPlugin};
|
||||
use bevy_trenchbroom::prelude::*;
|
||||
use bevy_ui_gradients::UiGradientsPlugin;
|
||||
use camera::MainCamera;
|
||||
@@ -94,7 +94,15 @@ fn main() {
|
||||
}),
|
||||
);
|
||||
|
||||
match SteamworksPlugin::init_app(1603000) {
|
||||
let app_id = 1603000;
|
||||
// should only be done in production builds
|
||||
#[cfg(not(debug_assertions))]
|
||||
if steamworks::restart_app_if_necessary(app_id.into()) {
|
||||
info!("Restarting app via steam");
|
||||
return;
|
||||
}
|
||||
|
||||
match SteamworksPlugin::init_app(app_id) {
|
||||
Ok(plugin) => {
|
||||
app.add_plugins(plugin);
|
||||
}
|
||||
@@ -173,7 +181,9 @@ fn main() {
|
||||
Startup,
|
||||
(
|
||||
write_trenchbroom_config,
|
||||
steam_system.run_if(resource_exists::<Client>),
|
||||
(steam_system, steam_events)
|
||||
.chain()
|
||||
.run_if(resource_exists::<Client>),
|
||||
),
|
||||
);
|
||||
app.add_systems(OnEnter(GameState::Playing), music);
|
||||
@@ -182,7 +192,35 @@ fn main() {
|
||||
app.run();
|
||||
}
|
||||
|
||||
fn steam_events(mut events: EventReader<SteamworksEvent>) {
|
||||
for e in events.read() {
|
||||
info!("steam ev: {:?}", e);
|
||||
}
|
||||
}
|
||||
|
||||
fn steam_system(steam_client: Res<Client>) {
|
||||
steam_client.matchmaking().request_lobby_list(|list| {
|
||||
let Ok(list) = list else { return };
|
||||
|
||||
info!("lobby list: [{}]", list.len());
|
||||
for (i, l) in list.iter().enumerate() {
|
||||
info!("lobby [{i}]: {:?}", l);
|
||||
}
|
||||
});
|
||||
|
||||
steam_client
|
||||
.matchmaking()
|
||||
.create_lobby(
|
||||
steamworks::LobbyType::FriendsOnly,
|
||||
4,
|
||||
|result| match result {
|
||||
Ok(lobby_id) => {
|
||||
info!("Created lobby with ID: {:?}", lobby_id);
|
||||
}
|
||||
Err(e) => error!("Failed to create lobby: {}", e),
|
||||
},
|
||||
);
|
||||
|
||||
for friend in steam_client.friends().get_friends(FriendFlags::IMMEDIATE) {
|
||||
info!(
|
||||
"Steam Friend: {:?} - {}({:?})",
|
||||
|
||||
Reference in New Issue
Block a user