allow local netcode multiplayer
* fix crashing when steam client not available * allow more than 1 connected player * disable settings persistence when in dbg
This commit is contained in:
@@ -87,7 +87,7 @@ fn connect_to_server(
|
||||
mut commands: Commands,
|
||||
config: Res<NetConfig>,
|
||||
channels: Res<RepliconChannels>,
|
||||
steam_client: Res<Client>,
|
||||
steam_client: Option<Res<Client>>,
|
||||
) -> Result {
|
||||
let server_channels_config = channels.server_configs();
|
||||
let client_channels_config = channels.client_configs();
|
||||
@@ -101,6 +101,10 @@ fn connect_to_server(
|
||||
commands.insert_resource(client);
|
||||
|
||||
if let NetConfig::SteamClient(host_steam_id) = &*config {
|
||||
let Some(steam_client) = steam_client else {
|
||||
return Err("Steam client not found".into());
|
||||
};
|
||||
|
||||
info!("connecting to steam host: {host_steam_id:?}");
|
||||
let transport = bevy_replicon_renet::steam::SteamClientTransport::new(
|
||||
(**steam_client).clone(),
|
||||
|
||||
@@ -4,10 +4,11 @@ use bevy_pkv::prelude::*;
|
||||
use crate::{client::audio::SoundSettings, utils::Debounce};
|
||||
|
||||
pub fn plugin(app: &mut App) {
|
||||
#[cfg(not(feature = "dbg"))]
|
||||
app.insert_resource(PkvStore::new("Rustunit", "HEDZ"));
|
||||
|
||||
app.add_systems(Update, persist_settings);
|
||||
app.add_systems(Startup, load_settings);
|
||||
app.add_systems(Update, persist_settings.run_if(resource_exists::<PkvStore>));
|
||||
app.add_systems(Startup, load_settings.run_if(resource_exists::<PkvStore>));
|
||||
}
|
||||
|
||||
fn persist_settings(
|
||||
|
||||
@@ -98,7 +98,7 @@ fn open_renet_server(
|
||||
|
||||
let server_config = bevy_replicon_renet::netcode::ServerConfig {
|
||||
current_time,
|
||||
max_clients: 1,
|
||||
max_clients: 8,
|
||||
protocol_id: 0,
|
||||
authentication: bevy_replicon_renet::netcode::ServerAuthentication::Unsecure,
|
||||
public_addresses: Default::default(),
|
||||
|
||||
Reference in New Issue
Block a user