Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Bevy 0.14 #258

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@ license = "MIT OR Apache-2.0"
include = ["/benches", "/src", "/tests", "/LICENSE*"]

[dependencies]
bevy = { version = "0.13", default-features = false, features = ["bevy_scene"] }
bevy = { git = "https://github.com/bevyengine/bevy.git", default-features = false, features = [
"bevy_scene",
] }
bytes = "1.5"
bincode = "1.3"
serde = "1.0"
varint-rs = "2.2"
ordered-multimap = "0.7"

[dev-dependencies]
bevy = { version = "0.13", default-features = false, features = [
bevy = { git = "https://github.com/bevyengine/bevy.git", default-features = false, features = [
"serialize",
"bevy_asset",
"bevy_sprite",
"bevy_state",
] }
criterion = { version = "0.5", default-features = false, features = [
"cargo_bench_support",
Expand Down
28 changes: 14 additions & 14 deletions benches/replication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn replication<C: Component + Default + Serialize + DeserializeOwned + Clone>(c:
}

server_app
.world
.world_mut()
.spawn_batch(vec![(Replicated, C::default()); ENTITIES as usize]);

let instant = Instant::now();
Expand All @@ -74,7 +74,7 @@ fn replication<C: Component + Default + Serialize + DeserializeOwned + Clone>(c:
for client_app in &mut client_apps {
server_app.exchange_with_client(client_app);
client_app.update();
assert_eq!(client_app.world.entities().len(), ENTITIES);
assert_eq!(client_app.world().entities().len(), ENTITIES);
}
}

Expand All @@ -95,20 +95,20 @@ fn replication<C: Component + Default + Serialize + DeserializeOwned + Clone>(c:
}

server_app
.world
.world_mut()
.spawn_batch(vec![(Replicated, C::default()); ENTITIES as usize]);
let mut query = server_app.world.query::<&mut C>();
let mut query = server_app.world_mut().query::<&mut C>();

server_app.update();
for client_app in &mut client_apps {
server_app.exchange_with_client(client_app);
client_app.update();
assert_eq!(client_app.world.entities().len(), ENTITIES);
assert_eq!(client_app.world().entities().len(), ENTITIES);
}

let mut elapsed = Duration::ZERO;
for _ in 0..iter {
for mut component in query.iter_mut(&mut server_app.world) {
for mut component in query.iter_mut(&mut server_app.world_mut()) {
component.set_changed();
}

Expand All @@ -119,7 +119,7 @@ fn replication<C: Component + Default + Serialize + DeserializeOwned + Clone>(c:
for client_app in &mut client_apps {
server_app.exchange_with_client(client_app);
client_app.update();
assert_eq!(client_app.world.entities().len(), ENTITIES);
assert_eq!(client_app.world().entities().len(), ENTITIES);
}
}

Expand All @@ -138,7 +138,7 @@ fn replication<C: Component + Default + Serialize + DeserializeOwned + Clone>(c:
server_app.connect_client(&mut client_app);

server_app
.world
.world_mut()
.spawn_batch(vec![(Replicated, C::default()); ENTITIES as usize]);

server_app.update();
Expand All @@ -147,7 +147,7 @@ fn replication<C: Component + Default + Serialize + DeserializeOwned + Clone>(c:
let instant = Instant::now();
client_app.update();
elapsed += instant.elapsed();
assert_eq!(client_app.world.entities().len(), ENTITIES);
assert_eq!(client_app.world_mut().entities().len(), ENTITIES);
}

elapsed
Expand All @@ -162,18 +162,18 @@ fn replication<C: Component + Default + Serialize + DeserializeOwned + Clone>(c:
server_app.connect_client(&mut client_app);

server_app
.world
.world_mut()
.spawn_batch(vec![(Replicated, C::default()); ENTITIES as usize]);
let mut query = server_app.world.query::<&mut C>();
let mut query = server_app.world_mut().query::<&mut C>();

server_app.update();
server_app.exchange_with_client(&mut client_app);
client_app.update();
assert_eq!(client_app.world.entities().len(), ENTITIES);
assert_eq!(client_app.world().entities().len(), ENTITIES);

let mut elapsed = Duration::ZERO;
for _ in 0..iter {
for mut component in query.iter_mut(&mut server_app.world) {
for mut component in query.iter_mut(&mut server_app.world_mut()) {
component.set_changed();
}

Expand All @@ -184,7 +184,7 @@ fn replication<C: Component + Default + Serialize + DeserializeOwned + Clone>(c:

client_app.update();
elapsed += instant.elapsed();
assert_eq!(client_app.world.entities().len(), ENTITIES);
assert_eq!(client_app.world().entities().len(), ENTITIES);
}

elapsed
Expand Down
6 changes: 3 additions & 3 deletions bevy_replicon_renet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ include = ["/src", "/tests", "../LICENSE*"]

[dependencies]
bevy_replicon = { version = "0.25", path = ".." }
bevy_renet = { version = "0.0.11", default-features = false }
bevy = { version = "0.13", default-features = false }
bevy_renet = { git = "https://github.com/notmd/renet.git", branch = "v0.14", default-features = false }
bevy = { git = "https://github.com/bevyengine/bevy.git", default-features = false }

[dev-dependencies]
serde = "1.0"
clap = { version = "4.1", features = ["derive"] }
bevy = { version = "0.13", default-features = false, features = [
bevy = { git = "https://github.com/bevyengine/bevy.git", default-features = false, features = [
"bevy_text",
"bevy_ui",
"bevy_gizmos",
Expand Down
7 changes: 4 additions & 3 deletions bevy_replicon_renet/examples/simple_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{
};

use bevy::{
color::palettes::css,
prelude::*,
winit::{UpdateMode::Continuous, WinitSettings},
};
Expand Down Expand Up @@ -75,7 +76,7 @@ impl SimpleBoxPlugin {
commands.spawn(PlayerBundle::new(
ClientId::SERVER,
Vec2::ZERO,
Color::GREEN,
css::GREEN.into(),
));
}
Cli::Server { port } => {
Expand Down Expand Up @@ -114,7 +115,7 @@ impl SimpleBoxPlugin {
commands.spawn(PlayerBundle::new(
ClientId::SERVER,
Vec2::ZERO,
Color::GREEN,
css::GREEN.into(),
));
}
Cli::Client { port, ip } => {
Expand Down Expand Up @@ -173,7 +174,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 } => {
Expand Down
15 changes: 8 additions & 7 deletions bevy_replicon_renet/examples/tic_tac_toe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl Plugin for TicTacToePlugin {

const GRID_SIZE: usize = 3;

const BACKGROUND_COLOR: Color = Color::rgb(0.9, 0.9, 0.9);
const BACKGROUND_COLOR: Color = Color::srgb(0.9, 0.9, 0.9);

const PROTOCOL_ID: u64 = 0;

Expand All @@ -110,7 +110,7 @@ impl TicTacToePlugin {
const LINE_THICKNESS: f32 = 10.0;
const BOARD_SIZE: f32 = CELL_SIZE * GRID_SIZE as f32 + LINES_COUNT as f32 * LINE_THICKNESS;

const BOARD_COLOR: Color = Color::rgb(0.8, 0.8, 0.8);
const BOARD_COLOR: Color = Color::srgb(0.8, 0.8, 0.8);

for line in 0..LINES_COUNT {
let position = -BOARD_SIZE / 2.0
Expand Down Expand Up @@ -149,7 +149,7 @@ impl TicTacToePlugin {
const BUTTON_SIZE: f32 = CELL_SIZE / 1.2;
const BUTTON_MARGIN: f32 = (CELL_SIZE + LINE_THICKNESS - BUTTON_SIZE) / 2.0;

const TEXT_COLOR: Color = Color::rgb(0.5, 0.5, 1.0);
const TEXT_COLOR: Color = Color::srgb(0.5, 0.5, 1.0);
const FONT_SIZE: f32 = 40.0;

commands
Expand Down Expand Up @@ -196,7 +196,8 @@ impl TicTacToePlugin {
margin: UiRect::all(Val::Px(BUTTON_MARGIN)),
..Default::default()
},
background_color: BACKGROUND_COLOR.into(),
image: UiImage::default()
.with_color(BACKGROUND_COLOR.into()),
..Default::default()
});
}
Expand Down Expand Up @@ -379,7 +380,7 @@ impl TicTacToePlugin {
children: Query<&Children>,
mut pick_events: EventWriter<CellPick>,
) {
const HOVER_COLOR: Color = Color::rgb(0.85, 0.85, 0.85);
const HOVER_COLOR: Color = Color::srgb(0.85, 0.85, 0.85);

for (button_entity, button_parent, interaction, mut background) in &mut buttons {
match interaction {
Expand Down Expand Up @@ -600,8 +601,8 @@ impl Symbol {

fn color(self) -> Color {
match self {
Symbol::Cross => Color::rgb(1.0, 0.5, 0.5),
Symbol::Nought => Color::rgb(0.5, 0.5, 1.0),
Symbol::Cross => Color::srgb(1.0, 0.5, 0.5),
Symbol::Nought => Color::srgb(0.5, 0.5, 1.0),
}
}

Expand Down
2 changes: 1 addition & 1 deletion bevy_replicon_renet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use bevy_replicon_renet::{renet::ConnectionConfig, RenetChannelsExt, RepliconRen

# let mut app = App::new();
# app.add_plugins(RepliconPlugins);
let channels = app.world.resource::<RepliconChannels>();
let channels = app.world_mut().resource::<RepliconChannels>();
let connection_config = ConnectionConfig {
server_channels_config: channels.get_server_configs(),
client_channels_config: channels.get_client_configs(),
Expand Down
26 changes: 13 additions & 13 deletions bevy_replicon_renet/tests/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ fn connect_disconnect() {

setup(&mut server_app, &mut client_app);

let mut renet_client = client_app.world.resource_mut::<RenetClient>();
let mut renet_client = client_app.world_mut().resource_mut::<RenetClient>();
assert!(renet_client.is_connected());
renet_client.disconnect();

client_app.update();
server_app.update();

let renet_server = server_app.world.resource::<RenetServer>();
let renet_server = server_app.world().resource::<RenetServer>();
assert_eq!(renet_server.connected_clients(), 0);

let connected_clients = server_app.world.resource::<ConnectedClients>();
let connected_clients = server_app.world().resource::<ConnectedClients>();
assert_eq!(connected_clients.len(), 0);

let replicon_client = client_app.world.resource_mut::<RepliconClient>();
let replicon_client = client_app.world_mut().resource_mut::<RepliconClient>();
assert!(replicon_client.is_disconnected());
}

Expand All @@ -66,12 +66,12 @@ fn replication() {

setup(&mut server_app, &mut client_app);

server_app.world.spawn(Replicated);
server_app.world_mut().spawn(Replicated);

server_app.update();
client_app.update();

assert_eq!(client_app.world.entities().len(), 1);
assert_eq!(client_app.world().entities().len(), 1);
}

#[test]
Expand All @@ -92,15 +92,15 @@ fn server_event() {

setup(&mut server_app, &mut client_app);

server_app.world.send_event(ToClients {
server_app.world_mut().send_event(ToClients {
mode: SendMode::Broadcast,
event: DummyEvent,
});

server_app.update();
client_app.update();

let dummy_events = client_app.world.resource::<Events<DummyEvent>>();
let dummy_events = client_app.world().resource::<Events<DummyEvent>>();
assert_eq!(dummy_events.len(), 1);
}

Expand All @@ -122,13 +122,13 @@ fn client_event() {

setup(&mut server_app, &mut client_app);

client_app.world.send_event(DummyEvent);
client_app.world_mut().send_event(DummyEvent);

client_app.update();
server_app.update();

let client_events = server_app
.world
.world()
.resource::<Events<FromClient<DummyEvent>>>();
assert_eq!(client_events.len(), 1);
}
Expand All @@ -141,7 +141,7 @@ fn setup(server_app: &mut App, client_app: &mut App) {
}

fn setup_client(app: &mut App, client_id: u64, port: u16) {
let channels = app.world.resource::<RepliconChannels>();
let channels = app.world().resource::<RepliconChannels>();

let server_channels_config = channels.get_server_configs();
let client_channels_config = channels.get_client_configs();
Expand All @@ -157,7 +157,7 @@ fn setup_client(app: &mut App, client_id: u64, port: u16) {
}

fn setup_server(app: &mut App, max_clients: usize) -> u16 {
let channels = app.world.resource::<RepliconChannels>();
let channels = app.world().resource::<RepliconChannels>();

let server_channels_config = channels.get_server_configs();
let client_channels_config = channels.get_client_configs();
Expand Down Expand Up @@ -218,7 +218,7 @@ fn wait_for_connection(server_app: &mut App, client_app: &mut App) {
loop {
client_app.update();
server_app.update();
if client_app.world.resource::<RenetClient>().is_connected() {
if client_app.world().resource::<RenetClient>().is_connected() {
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub mod server_entity_map;

use std::{io::Cursor, mem};

use bevy::{ecs::system::CommandQueue, prelude::*};
use bevy::{ecs::world::CommandQueue, prelude::*};
use bincode::{DefaultOptions, Options};
use bytes::Bytes;
use varint_rs::VarintReader;
Expand Down
2 changes: 1 addition & 1 deletion src/client/server_entity_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl ServerEntityMap {
/// # Examples
///
/// ```
/// # use bevy::{ecs::system::CommandQueue, prelude::*};
/// # use bevy::{ecs::world::CommandQueue, prelude::*};
/// # use bevy_replicon::{client::server_entity_map::ServerEntityMap, prelude::*};
/// # let mut entity_map = ServerEntityMap::default();
/// # let mut queue = CommandQueue::default();
Expand Down
Loading
Loading