diff --git a/Cargo.lock b/Cargo.lock index bc9ed17..b5d0310 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -486,7 +486,7 @@ dependencies = [ [[package]] name = "bevy-steamworks" version = "0.13.0" -source = "git+https://github.com/HouraiTeahouse/bevy_steamworks.git?rev=0bc62fc#0bc62fc8691364ad5babec14c96c9cb895d6c27d" +source = "git+https://github.com/extrawurst/bevy_steamworks.git?branch=derive-debug-event#579062f5edb8fea6dd0b2ab23b1c4fe49742e8c6" dependencies = [ "bevy_app", "bevy_ecs", @@ -3094,6 +3094,7 @@ dependencies = [ "rand", "ron", "serde", + "steamworks", "vergen-gitcl", ] diff --git a/Cargo.toml b/Cargo.toml index d52edfc..2617eb0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ bevy_sprite3d = "5.0.0" rand = "=0.8.5" bevy-inspector-egui = { version = "0.31", optional = true } bevy-steamworks = "0.13.0" +steamworks = "0.11" bevy_ballistic = "0.3.0" bevy-ui-gradients = "0.4.0" bevy_debug_log = "0.6.0" @@ -47,7 +48,8 @@ too_many_arguments = "allow" type_complexity = "allow" [patch.crates-io] -bevy-steamworks = { git = "https://github.com/HouraiTeahouse/bevy_steamworks.git", rev = "0bc62fc" } +bevy-steamworks = { git = "https://github.com/extrawurst/bevy_steamworks.git", branch = "derive-debug-event" } +# bevy-steamworks = { path = "../../forks/bevy_steamworks" } avian3d = { git = "https://github.com/Jondolf/avian.git", rev = "9511076" } bevy_ballistic = { git = "https://github.com/rustunit/bevy_ballistic.git", branch = "bevy-0.16" } bevy_trenchbroom = { git = "https://github.com/extrawurst/bevy_trenchbroom.git", branch = "bevy-0.16.0" } diff --git a/src/main.rs b/src/main.rs index eeb4ff6..1ee065c 100644 --- a/src/main.rs +++ b/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::), + (steam_system, steam_events) + .chain() + .run_if(resource_exists::), ), ); app.add_systems(OnEnter(GameState::Playing), music); @@ -182,7 +192,35 @@ fn main() { app.run(); } +fn steam_events(mut events: EventReader) { + for e in events.read() { + info!("steam ev: {:?}", e); + } +} + fn steam_system(steam_client: Res) { + 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: {:?} - {}({:?})",