diff --git a/Cargo.toml b/Cargo.toml index 75e2982..ea9aafe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_replicon_snap" -version = "0.2.3" +version = "0.2.4" edition = "2021" authors = ["Ben Dzaebel "] hompage = "bendz.dev" @@ -13,16 +13,15 @@ description = "High-level networking crate that extends the bevy_replicon crate # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bevy = { version = "0.13", default_features = false } -bevy_replicon = "0.26.3" -bevy_replicon_renet = "0.3.0" +bevy = { version = "0.14", default_features = false } +bevy_replicon = "0.27" serde = "1.0" bevy_replicon_snap_macros = { version = "0.2.0", path = "macros" } [dev-dependencies] clap = { version = "4.1", features = ["derive"] } -bevy = { version = "0.13", default-features = false, features = [ +bevy = { version = "0.14", default-features = false, features = [ "bevy_asset", "bevy_core_pipeline", "bevy_render", @@ -33,6 +32,7 @@ bevy = { version = "0.13", default-features = false, features = [ "x11", "default_font", ] } +bevy_replicon_renet = "0.4.0" [package.metadata.commands] example_interpolation = "cargo run --example interpolated -- server & cargo run --example interpolated -- client && fg" diff --git a/examples/interpolated.rs b/examples/interpolated.rs index 67b5cbd..9ad8dff 100644 --- a/examples/interpolated.rs +++ b/examples/interpolated.rs @@ -86,7 +86,7 @@ impl SimpleBoxPlugin { commands.spawn(PlayerBundle::new( ClientId::SERVER, Vec2::ZERO, - Color::GREEN, + bevy::color::palettes::css::GREEN.into(), )); } Cli::Server { port } => { @@ -125,7 +125,7 @@ impl SimpleBoxPlugin { commands.spawn(PlayerBundle::new( ClientId::SERVER, Vec2::ZERO, - Color::GREEN, + bevy::color::palettes::css::GREEN.into(), )); } Cli::Client { port, ip } => { @@ -184,7 +184,7 @@ impl SimpleBoxPlugin { commands.spawn(PlayerBundle::new( *client_id, Vec2::ZERO, - Color::rgb(r, g, b), + Color::srgb(r, g, b), )); } ServerEvent::ClientDisconnected { client_id, reason } => { diff --git a/examples/no_interpolation_or_prediction.rs b/examples/no_interpolation_or_prediction.rs index ff7c08f..cc2d6c4 100644 --- a/examples/no_interpolation_or_prediction.rs +++ b/examples/no_interpolation_or_prediction.rs @@ -79,7 +79,7 @@ impl SimpleBoxPlugin { commands.spawn(PlayerBundle::new( ClientId::SERVER, Vec2::ZERO, - Color::GREEN, + bevy::color::palettes::css::GREEN.into(), )); } Cli::Server { port } => { @@ -118,7 +118,7 @@ impl SimpleBoxPlugin { commands.spawn(PlayerBundle::new( ClientId::SERVER, Vec2::ZERO, - Color::GREEN, + bevy::color::palettes::css::GREEN.into(), )); } Cli::Client { port, ip } => { @@ -177,7 +177,7 @@ impl SimpleBoxPlugin { commands.spawn(PlayerBundle::new( *client_id, Vec2::ZERO, - Color::rgb(r, g, b), + Color::srgb(r, g, b), )); } ServerEvent::ClientDisconnected { client_id, reason } => { diff --git a/examples/owner_predicted.rs b/examples/owner_predicted.rs index a8f35e2..0ca668e 100644 --- a/examples/owner_predicted.rs +++ b/examples/owner_predicted.rs @@ -90,7 +90,7 @@ impl SimpleBoxPlugin { commands.spawn(PlayerBundle::new( ClientId::SERVER, Vec2::ZERO, - Color::GREEN, + bevy::color::palettes::css::GREEN.into(), )); } Cli::Server { port } => { @@ -129,7 +129,7 @@ impl SimpleBoxPlugin { commands.spawn(PlayerBundle::new( ClientId::SERVER, Vec2::ZERO, - Color::GREEN, + bevy::color::palettes::css::GREEN.into(), )); } Cli::Client { port, ip } => { @@ -188,7 +188,7 @@ impl SimpleBoxPlugin { commands.spawn(PlayerBundle::new( *client_id, Vec2::ZERO, - Color::rgb(r, g, b), + Color::srgb(r, g, b), )); } ServerEvent::ClientDisconnected { client_id, reason } => { diff --git a/src/interpolation.rs b/src/interpolation.rs index e1f702e..8278830 100644 --- a/src/interpolation.rs +++ b/src/interpolation.rs @@ -18,12 +18,12 @@ use bevy_replicon::{ bincode, core::{ command_markers::{AppMarkerExt, MarkerConfig}, + common_conditions::client_connected, ctx::{RemoveCtx, WriteCtx}, replication_registry::rule_fns::RuleFns, replication_rules::AppRuleExt, }, }; -use bevy_replicon_renet::renet::RenetClient; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use crate::{ @@ -168,7 +168,7 @@ impl AppInterpolationExt for App { PreUpdate, (snapshot_buffer_init_system::.after(owner_prediction_init_system)) .in_set(InterpolationSet::Init) - .run_if(resource_exists::), + .run_if(client_connected), ); self.add_systems( PreUpdate, @@ -178,7 +178,7 @@ impl AppInterpolationExt for App { ) .chain() .in_set(InterpolationSet::Interpolate) - .run_if(resource_exists::), + .run_if(client_connected), ) .replicate::() .register_marker_with::(MarkerConfig { diff --git a/src/lib.rs b/src/lib.rs index 1a4f409..4b29686 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,6 @@ use std::fmt::Debug; use bevy::prelude::*; use bevy_replicon::prelude::*; -use bevy_replicon_renet::renet::transport::NetcodeClientTransport; use serde::{Deserialize, Serialize}; pub use bevy_replicon_snap_macros; @@ -53,7 +52,7 @@ impl Plugin for SnapshotInterpolationPlugin { .add_systems( Update, owner_prediction_init_system - .run_if(resource_exists::) + .run_if(client_connected) .in_set(InterpolationSet::Init), ) .insert_resource(SnapshotInterpolationConfig { diff --git a/src/prediction.rs b/src/prediction.rs index cf7fe26..4f31462 100644 --- a/src/prediction.rs +++ b/src/prediction.rs @@ -5,22 +5,22 @@ use bevy::{ entity::Entity, event::{Event, EventReader}, query::{Added, With, Without}, - schedule::{common_conditions::resource_exists, IntoSystemConfigs}, + schedule::IntoSystemConfigs, system::{Commands, Query, Res, ResMut, Resource}, }, reflect::Reflect, time::Time, }; use bevy_replicon::{ - client::{ - confirm_history::ConfirmHistory, - events::{ClientEventAppExt, FromClient}, - }, + client::confirm_history::ConfirmHistory, core::{ - channels::RepliconChannel, common_conditions::has_authority, replication_rules::AppRuleExt, + channels::RepliconChannel, + common_conditions::{client_connected, has_authority}, + replication_rules::AppRuleExt, + replicon_client::RepliconClient, }, + prelude::{ClientEventAppExt, FromClient}, }; -use bevy_replicon_renet::renet::{transport::NetcodeClientTransport, RenetClient}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::collections::vec_deque::Iter; use std::collections::VecDeque; @@ -87,12 +87,12 @@ impl PredictedEventHistory { pub fn owner_prediction_init_system( q_owners: Query<(Entity, &NetworkOwner), Added>, - client: Res, + client: Res, mut commands: Commands, ) { - let client_id = client.client_id(); + let client_id = client.id().expect("No client id id found"); for (e, id) in q_owners.iter() { - if id.0 == client_id.raw() { + if id.0 == client_id.get() { commands.entity(e).insert(Predicted); } else { commands.entity(e).insert(Interpolated); @@ -203,7 +203,7 @@ impl AppPredictionExt for App { Update, ( server_update_system::.run_if(has_authority), // Runs only on the server or a single player. - predicted_update_system::.run_if(resource_exists::), // Runs only on clients. + predicted_update_system::.run_if(client_connected), // Runs only on clients. ), ) .replicate::()