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,
|
mut commands: Commands,
|
||||||
config: Res<NetConfig>,
|
config: Res<NetConfig>,
|
||||||
channels: Res<RepliconChannels>,
|
channels: Res<RepliconChannels>,
|
||||||
steam_client: Res<Client>,
|
steam_client: Option<Res<Client>>,
|
||||||
) -> Result {
|
) -> Result {
|
||||||
let server_channels_config = channels.server_configs();
|
let server_channels_config = channels.server_configs();
|
||||||
let client_channels_config = channels.client_configs();
|
let client_channels_config = channels.client_configs();
|
||||||
@@ -101,6 +101,10 @@ fn connect_to_server(
|
|||||||
commands.insert_resource(client);
|
commands.insert_resource(client);
|
||||||
|
|
||||||
if let NetConfig::SteamClient(host_steam_id) = &*config {
|
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:?}");
|
info!("connecting to steam host: {host_steam_id:?}");
|
||||||
let transport = bevy_replicon_renet::steam::SteamClientTransport::new(
|
let transport = bevy_replicon_renet::steam::SteamClientTransport::new(
|
||||||
(**steam_client).clone(),
|
(**steam_client).clone(),
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ use bevy_pkv::prelude::*;
|
|||||||
use crate::{client::audio::SoundSettings, utils::Debounce};
|
use crate::{client::audio::SoundSettings, utils::Debounce};
|
||||||
|
|
||||||
pub fn plugin(app: &mut App) {
|
pub fn plugin(app: &mut App) {
|
||||||
|
#[cfg(not(feature = "dbg"))]
|
||||||
app.insert_resource(PkvStore::new("Rustunit", "HEDZ"));
|
app.insert_resource(PkvStore::new("Rustunit", "HEDZ"));
|
||||||
|
|
||||||
app.add_systems(Update, persist_settings);
|
app.add_systems(Update, persist_settings.run_if(resource_exists::<PkvStore>));
|
||||||
app.add_systems(Startup, load_settings);
|
app.add_systems(Startup, load_settings.run_if(resource_exists::<PkvStore>));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn persist_settings(
|
fn persist_settings(
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ fn open_renet_server(
|
|||||||
|
|
||||||
let server_config = bevy_replicon_renet::netcode::ServerConfig {
|
let server_config = bevy_replicon_renet::netcode::ServerConfig {
|
||||||
current_time,
|
current_time,
|
||||||
max_clients: 1,
|
max_clients: 8,
|
||||||
protocol_id: 0,
|
protocol_id: 0,
|
||||||
authentication: bevy_replicon_renet::netcode::ServerAuthentication::Unsecure,
|
authentication: bevy_replicon_renet::netcode::ServerAuthentication::Unsecure,
|
||||||
public_addresses: Default::default(),
|
public_addresses: Default::default(),
|
||||||
|
|||||||
Reference in New Issue
Block a user