Skip to content

Commit

Permalink
Merge pull request #219 from cBournhonesque/cb/0.13
Browse files Browse the repository at this point in the history
0.13
  • Loading branch information
cBournhonesque authored Apr 1, 2024
2 parents b29db4f + 0b188fe commit 9e3b053
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 69 deletions.
14 changes: 7 additions & 7 deletions examples/leafwing_inputs/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
use bevy::utils::Duration;
use std::net::{Ipv4Addr, SocketAddr};

#[cfg(not(target_family = "wasm"))]
use crate::server::Certificate;
use crate::{client, server};
use async_compat::Compat;
use bevy::tasks::IoTaskPool;
use serde::{Deserialize, Serialize};
use lightyear::prelude::client::Authentication;
#[cfg(not(target_family = "wasm"))]
use lightyear::prelude::client::{SteamConfig};
use lightyear::prelude::client::{Authentication};
use lightyear::prelude::client::SteamConfig;
use lightyear::prelude::{ClientId, IoConfig, LinkConditionerConfig, TransportConfig};
#[cfg(not(target_family = "wasm"))]
use crate::server::Certificate;
use crate::{client, server};
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub enum ClientTransports {
Expand Down Expand Up @@ -294,7 +294,7 @@ pub fn get_client_net_config(settings: &Settings, client_id: u64) -> client::Net
client_addr,
server_addr,
#[cfg(target_family = "wasm")]
certificate_digest: certificate_digest.to_string()j,
certificate_digest: certificate_digest.to_string(),
},
),
ClientTransports::WebSocket => build_client_netcode_config(
Expand Down
86 changes: 43 additions & 43 deletions lightyear/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lightyear"
version = "0.12.0"
version = "0.13.0"
authors = ["Charles Bournhonesque <[email protected]>"]
edition = "2021"
rust-version = "1.65"
Expand All @@ -14,30 +14,30 @@ exclude = ["/tests"]

[features]
metrics = [
"dep:metrics",
"metrics-util",
"metrics-tracing-context",
"metrics-exporter-prometheus",
"dep:tokio",
"dep:metrics",
"metrics-util",
"metrics-tracing-context",
"metrics-exporter-prometheus",
"dep:tokio",
]
mock_time = ["dep:mock_instant"]
render = ["bevy/bevy_render"]
webtransport = [
"dep:wtransport",
"dep:xwt-core",
"dep:xwt-web-sys",
"dep:web-sys",
"dep:tokio",
"dep:ring",
"dep:wtransport",
"dep:xwt-core",
"dep:xwt-web-sys",
"dep:web-sys",
"dep:tokio",
"dep:ring",
]
leafwing = ["dep:leafwing-input-manager", "lightyear_macros/leafwing"]
xpbd_2d = ["dep:bevy_xpbd_2d"]
websocket = [
"dep:tokio",
"dep:tokio-tungstenite",
"dep:futures-util",
"dep:web-sys",
"dep:wasm-bindgen",
"dep:tokio",
"dep:tokio-tungstenite",
"dep:futures-util",
"dep:web-sys",
"dep:wasm-bindgen",
]
steam = ["dep:steamworks"]

Expand Down Expand Up @@ -71,7 +71,7 @@ bevy_xpbd_2d = { version = "0.4", optional = true }

# serialization
bitcode = { version = "0.5.1", package = "bitcode_lightyear_patch", path = "../vendor/bitcode", features = [
"serde",
"serde",
] }
bytes = { version = "1.5", features = ["serde"] }
self_cell = "1.0"
Expand All @@ -82,14 +82,14 @@ chacha20poly1305 = { version = "0.10", features = ["std"] }
byteorder = "1.5.0"

# derive
lightyear_macros = { version = "0.12.0", path = "../macros" }
lightyear_macros = { version = "0.13.0", path = "../macros" }

# tracing
tracing = "0.1.40"
tracing-log = "0.2.0"
tracing-subscriber = { version = "0.3.17", features = [
"registry",
"env-filter",
"registry",
"env-filter",
] }

# server
Expand All @@ -100,12 +100,12 @@ metrics = { version = "0.22", optional = true }
metrics-util = { version = "0.15", optional = true }
metrics-tracing-context = { version = "0.15", optional = true }
metrics-exporter-prometheus = { version = "0.13.0", optional = true, default-features = false, features = [
"http-listener",
"http-listener",
] }

# bevy
bevy = { version = "0.13", default-features = false, features = [
"multi-threaded",
"multi-threaded",
] }


Expand All @@ -115,7 +115,7 @@ futures-util = { version = "0.3.30", optional = true }
# transport
# we don't need any tokio features, we use only use the tokio channels
tokio = { version = "1.36", features = [
"sync",
"sync",
], default-features = false, optional = true }
async-compat = "0.2.3"

Expand All @@ -125,37 +125,37 @@ async-compat = "0.2.3"
steamworks = { version = "0.11", optional = true }
# webtransport
wtransport = { version = "=0.1.11", optional = true, features = [
"self-signed",
"dangerous-configuration",
"self-signed",
"dangerous-configuration",
] }
# websocket
tokio-tungstenite = { version = "0.21.0", optional = true, features = [
"connect",
"handshake",
"connect",
"handshake",
] }

[target."cfg(target_family = \"wasm\")".dependencies]
console_error_panic_hook = { version = "0.1.7" }
ring = { version = "0.17.7", optional = true }
web-sys = { version = "0.3", optional = true, features = [
"WebTransport",
"WebTransportHash",
"WebTransportOptions",
"WebTransportBidirectionalStream",
"WebTransportSendStream",
"WebTransportReceiveStream",
"ReadableStreamDefaultReader",
"WritableStreamDefaultWriter",
"WebTransportDatagramDuplexStream",
"WebSocket",
"CloseEvent",
"ErrorEvent",
"MessageEvent",
"BinaryType",
"WebTransport",
"WebTransportHash",
"WebTransportOptions",
"WebTransportBidirectionalStream",
"WebTransportSendStream",
"WebTransportReceiveStream",
"ReadableStreamDefaultReader",
"WritableStreamDefaultWriter",
"WebTransportDatagramDuplexStream",
"WebSocket",
"CloseEvent",
"ErrorEvent",
"MessageEvent",
"BinaryType",
] }
futures-lite = { version = "2.1.0", optional = true }
getrandom = { version = "0.2.11", features = [
"js", # feature 'js' is required for wasm
"js", # feature 'js' is required for wasm
] }
xwt-core = { version = "0.2", optional = true }
xwt-web-sys = { version = "0.6", optional = true }
Expand Down
20 changes: 10 additions & 10 deletions lightyear/src/client/events.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Bevy [`Event`](bevy::prelude::Event) that are emitted when certain network events occur on the client
//! Bevy [`Event`] that are emitted when certain network events occur on the client
//!
//! You can use this to react to network events in your game systems.
//! ```rust,ignore
Expand Down Expand Up @@ -47,7 +47,7 @@ impl<P: Protocol> Plugin for ClientEventsPlugin<P> {
}
}

/// Bevy [`Event`](bevy::prelude::Event) emitted on the client on the frame where the connection is established
/// Bevy [`Event`] emitted on the client on the frame where the connection is established
///
/// We keep this separate from the server's ConnectEvent so that we have different events emitted on the client
/// and the server when running in HostServer mode
Expand All @@ -63,19 +63,19 @@ impl ConnectEvent {
}
}

/// Bevy [`Event`](bevy::prelude::Event) emitted on the client on the frame where the connection is disconnected
/// Bevy [`Event`] emitted on the client on the frame where the connection is disconnected
pub type DisconnectEvent = crate::shared::events::components::DisconnectEvent<()>;
/// Bevy [`Event`](bevy::prelude::Event) emitted on the client to indicate the user input for the tick
/// Bevy [`Event`] emitted on the client to indicate the user input for the tick
pub type InputEvent<I> = crate::shared::events::components::InputEvent<I, ()>;
/// Bevy [`Event`](bevy::prelude::Event) emitted on the client when a EntitySpawn replication message is received
/// Bevy [`Event`] emitted on the client when a EntitySpawn replication message is received
pub type EntitySpawnEvent = crate::shared::events::components::EntitySpawnEvent<()>;
/// Bevy [`Event`](bevy::prelude::Event) emitted on the client when a EntityDespawn replication message is received
/// Bevy [`Event`] emitted on the client when a EntityDespawn replication message is received
pub type EntityDespawnEvent = crate::shared::events::components::EntityDespawnEvent<()>;
/// Bevy [`Event`](bevy::prelude::Event) emitted on the client when a ComponentUpdate replication message is received
/// Bevy [`Event`] emitted on the client when a ComponentUpdate replication message is received
pub type ComponentUpdateEvent<C> = crate::shared::events::components::ComponentUpdateEvent<C, ()>;
/// Bevy [`Event`](bevy::prelude::Event) emitted on the client when a ComponentInsert replication message is received
/// Bevy [`Event`] emitted on the client when a ComponentInsert replication message is received
pub type ComponentInsertEvent<C> = crate::shared::events::components::ComponentInsertEvent<C, ()>;
/// Bevy [`Event`](bevy::prelude::Event) emitted on the client when a ComponentRemove replication message is received
/// Bevy [`Event`] emitted on the client when a ComponentRemove replication message is received
pub type ComponentRemoveEvent<C> = crate::shared::events::components::ComponentRemoveEvent<C, ()>;
/// Bevy [`Event`](bevy::prelude::Event) emitted on the client when a (non-replication) message is received
/// Bevy [`Event`] emitted on the client when a (non-replication) message is received
pub type MessageEvent<M> = crate::shared::events::components::MessageEvent<M, ()>;
16 changes: 8 additions & 8 deletions lightyear/src/utils/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<T> Pool<T> {
F: Fn() -> T,
{
Pool {
objects: Mutex::new((0..cap).into_iter().map(|_| init()).collect()),
objects: Mutex::new((0..cap).map(|_| init()).collect()),
}
}

Expand Down Expand Up @@ -189,16 +189,16 @@ mod tests {

#[test]
fn detach() {
let pool = Pool::new(1, || Vec::new());
let pool = Pool::new(1, Vec::new);
let (pool, mut object) = pool.try_pull().unwrap().detach();
object.push(1);
Reusable::new(&pool, object);
Reusable::new(pool, object);
assert_eq!(pool.try_pull().unwrap()[0], 1);
}

#[test]
fn detach_then_attach() {
let pool = Pool::new(1, || Vec::new());
let pool = Pool::new(1, Vec::new);
let (pool, mut object) = pool.try_pull().unwrap().detach();
object.push(1);
pool.attach(object);
Expand All @@ -207,11 +207,11 @@ mod tests {

#[test]
fn pull() {
let pool = Pool::<Vec<u8>>::new(1, || Vec::new());
let pool = Pool::<Vec<u8>>::new(1, Vec::new);

let object1 = pool.try_pull();
let object2 = pool.try_pull();
let object3 = pool.pull(|| Vec::new());
let object3 = pool.pull(Vec::new);

assert!(object1.is_some());
assert!(object2.is_none());
Expand All @@ -223,7 +223,7 @@ mod tests {

#[test]
fn e2e() {
let pool = Pool::new(10, || Vec::new());
let pool = Pool::new(10, Vec::new);
let mut objects = Vec::new();

for i in 0..10 {
Expand All @@ -236,7 +236,7 @@ mod tests {
drop(objects);
assert!(pool.try_pull().is_some());

for i in (10..0).rev() {
for i in (0..10).rev() {
let mut object = pool.objects.lock().pop().unwrap();
assert_eq!(object.pop(), Some(i));
}
Expand Down
2 changes: 1 addition & 1 deletion macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lightyear_macros"
version = "0.12.0"
version = "0.13.0"
authors = ["Charles Bournhonesque <[email protected]>"]
edition = "2021"
rust-version = "1.65"
Expand Down

0 comments on commit 9e3b053

Please sign in to comment.