more steamworks test code
This commit is contained in:
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -486,7 +486,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy-steamworks"
|
name = "bevy-steamworks"
|
||||||
version = "0.13.0"
|
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 = [
|
dependencies = [
|
||||||
"bevy_app",
|
"bevy_app",
|
||||||
"bevy_ecs",
|
"bevy_ecs",
|
||||||
@@ -3094,6 +3094,7 @@ dependencies = [
|
|||||||
"rand",
|
"rand",
|
||||||
"ron",
|
"ron",
|
||||||
"serde",
|
"serde",
|
||||||
|
"steamworks",
|
||||||
"vergen-gitcl",
|
"vergen-gitcl",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ bevy_sprite3d = "5.0.0"
|
|||||||
rand = "=0.8.5"
|
rand = "=0.8.5"
|
||||||
bevy-inspector-egui = { version = "0.31", optional = true }
|
bevy-inspector-egui = { version = "0.31", optional = true }
|
||||||
bevy-steamworks = "0.13.0"
|
bevy-steamworks = "0.13.0"
|
||||||
|
steamworks = "0.11"
|
||||||
bevy_ballistic = "0.3.0"
|
bevy_ballistic = "0.3.0"
|
||||||
bevy-ui-gradients = "0.4.0"
|
bevy-ui-gradients = "0.4.0"
|
||||||
bevy_debug_log = "0.6.0"
|
bevy_debug_log = "0.6.0"
|
||||||
@@ -47,7 +48,8 @@ too_many_arguments = "allow"
|
|||||||
type_complexity = "allow"
|
type_complexity = "allow"
|
||||||
|
|
||||||
[patch.crates-io]
|
[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" }
|
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_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" }
|
bevy_trenchbroom = { git = "https://github.com/extrawurst/bevy_trenchbroom.git", branch = "bevy-0.16.0" }
|
||||||
|
|||||||
44
src/main.rs
44
src/main.rs
@@ -37,7 +37,7 @@ use bevy::{
|
|||||||
};
|
};
|
||||||
use bevy_common_assets::ron::RonAssetPlugin;
|
use bevy_common_assets::ron::RonAssetPlugin;
|
||||||
use bevy_sprite3d::Sprite3dPlugin;
|
use bevy_sprite3d::Sprite3dPlugin;
|
||||||
use bevy_steamworks::{Client, FriendFlags, SteamworksPlugin};
|
use bevy_steamworks::{Client, FriendFlags, SteamworksEvent, SteamworksPlugin};
|
||||||
use bevy_trenchbroom::prelude::*;
|
use bevy_trenchbroom::prelude::*;
|
||||||
use bevy_ui_gradients::UiGradientsPlugin;
|
use bevy_ui_gradients::UiGradientsPlugin;
|
||||||
use camera::MainCamera;
|
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) => {
|
Ok(plugin) => {
|
||||||
app.add_plugins(plugin);
|
app.add_plugins(plugin);
|
||||||
}
|
}
|
||||||
@@ -173,7 +181,9 @@ fn main() {
|
|||||||
Startup,
|
Startup,
|
||||||
(
|
(
|
||||||
write_trenchbroom_config,
|
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);
|
app.add_systems(OnEnter(GameState::Playing), music);
|
||||||
@@ -182,7 +192,35 @@ fn main() {
|
|||||||
app.run();
|
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>) {
|
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) {
|
for friend in steam_client.friends().get_friends(FriendFlags::IMMEDIATE) {
|
||||||
info!(
|
info!(
|
||||||
"Steam Friend: {:?} - {}({:?})",
|
"Steam Friend: {:?} - {}({:?})",
|
||||||
|
|||||||
Reference in New Issue
Block a user