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

Update bevy to 0.11 #93

Merged
merged 6 commits into from
Jul 14, 2023
Merged
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
4 changes: 2 additions & 2 deletions bevy_renet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ default = ["transport"]
transport = ["renet/transport"]

[dependencies]
bevy = {version = "0.10.1", default-features = false}
bevy = {version = "0.11.0", default-features = false}
renet = {path = "../renet", version = "0.0.12", features = ["bevy"]}

[dev-dependencies]
bevy = {version = "0.10.1", default-features = false, features = ["bevy_core_pipeline", "bevy_render", "bevy_asset", "bevy_pbr", "x11"]}
bevy = {version = "0.11.0", default-features = false, features = ["bevy_core_pipeline", "bevy_render", "bevy_asset", "bevy_pbr", "x11"]}
bincode = "1.3.1"
env_logger = "0.10.0"
serde = {version = "1.0", features = ["derive"]}
8 changes: 4 additions & 4 deletions bevy_renet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ impl Plugin for RenetServerPlugin {
fn build(&self, app: &mut App) {
app.init_resource::<Events<ServerEvent>>();

app.configure_set(RenetSet::Server.run_if(resource_exists::<RenetServer>()));
app.configure_set(Update, RenetSet::Server.run_if(resource_exists::<RenetServer>()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You configure set for Update, but use it in PreUpdate. I think that's the issue.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to configure this with all default sets?
Like:

app.configure_set(PreUpdate, RenetSet::Server.run_if(resource_exists::<RenetServer>()));
app.configure_set(Update, RenetSet::Server.run_if(resource_exists::<RenetServer>()));
app.configure_set(PostUpdate, RenetSet::Server.run_if(resource_exists::<RenetServer>()));

This set is used to simplify the run_if(resource_exists::<RenetServer>()

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we hit this issue:
bevyengine/bevy#9139

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we shouldn't be using SystemSets, and should just use directly run_if(resource_exists::<RenetServer> / run_if(resource_exists::<RenetClient>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will go and remove the SystemSets.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably should remove the set enum too then.


app.add_system(Self::update_system.in_base_set(CoreSet::PreUpdate).in_set(RenetSet::Server));
app.add_systems(PreUpdate, Self::update_system.in_set(RenetSet::Server));
}
}

Expand All @@ -42,9 +42,9 @@ impl RenetServerPlugin {

impl Plugin for RenetClientPlugin {
fn build(&self, app: &mut App) {
app.configure_set(RenetSet::Client.run_if(resource_exists::<RenetClient>()));
app.configure_set(Update, RenetSet::Client.run_if(resource_exists::<RenetClient>()));

app.add_system(Self::update_system.in_base_set(CoreSet::PreUpdate).in_set(RenetSet::Client));
app.add_systems(PreUpdate, Self::update_system.in_set(RenetSet::Client));
}
}

Expand Down
43 changes: 23 additions & 20 deletions bevy_renet/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ pub struct NetcodeClientPlugin;
impl Plugin for NetcodeServerPlugin {
fn build(&self, app: &mut App) {
app.add_event::<NetcodeTransportError>();
app.configure_set(
TransportSet::Server
.run_if(resource_exists::<NetcodeServerTransport>().and_then(resource_exists::<RenetServer>()))

app.add_systems(
PreUpdate,
Self::update_system
.run_if(resource_exists::<NetcodeServerTransport>())
.run_if(resource_exists::<RenetServer>())
.after(RenetSet::Server),
);

app.add_system(Self::update_system.in_base_set(CoreSet::PreUpdate).in_set(TransportSet::Server));
app.add_system(Self::send_packets.in_base_set(CoreSet::PostUpdate).in_set(TransportSet::Server));
app.add_system(
Self::disconnect_on_exit
.in_base_set(CoreSet::PostUpdate)
.in_set(TransportSet::Server),
app.add_systems(
PostUpdate,
(Self::send_packets, Self::disconnect_on_exit)
.run_if(resource_exists::<NetcodeServerTransport>())
.run_if(resource_exists::<RenetServer>())
.after(RenetSet::Server),
);
}
}
Expand Down Expand Up @@ -64,18 +66,19 @@ impl Plugin for NetcodeClientPlugin {
fn build(&self, app: &mut App) {
app.add_event::<NetcodeTransportError>();

app.configure_set(
TransportSet::Client
.run_if(resource_exists::<NetcodeClientTransport>().and_then(resource_exists::<RenetClient>()))
app.add_systems(
PreUpdate,
Self::update_system
.run_if(resource_exists::<NetcodeClientTransport>())
.run_if(resource_exists::<RenetClient>())
.after(RenetSet::Client),
);

app.add_system(Self::update_system.in_base_set(CoreSet::PreUpdate).in_set(TransportSet::Client));
app.add_system(Self::send_packets.in_base_set(CoreSet::PostUpdate).in_set(TransportSet::Client));
app.add_system(
Self::disconnect_on_exit
.in_base_set(CoreSet::PostUpdate)
.in_set(TransportSet::Client),
app.add_systems(
PostUpdate,
(Self::send_packets, Self::disconnect_on_exit)
.run_if(resource_exists::<NetcodeClientTransport>())
.run_if(resource_exists::<RenetClient>())
.after(RenetSet::Client),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion renet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ default = ["transport"]
transport = ["dep:renetcode"]

[dependencies]
bevy_ecs = { version = "0.10.1", optional = true }
bevy_ecs = { version = "0.11.0", optional = true }
bytes = "1.1"
log = "0.4.17"
octets = "0.2"
Expand Down
1 change: 1 addition & 0 deletions renet/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use bytes::Bytes;

/// Connection and disconnection events in the server.
#[derive(Debug)]
#[cfg_attr(feature = "bevy", derive(bevy_ecs::prelude::Event))]
pub enum ServerEvent {
ClientConnected { client_id: u64 },
ClientDisconnected { client_id: u64, reason: DisconnectReason },
Expand Down
1 change: 1 addition & 0 deletions renet/src/transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub use renetcode::{
};

#[derive(Debug)]
#[cfg_attr(feature = "bevy", derive(bevy_ecs::prelude::Event))]
pub enum NetcodeTransportError {
Netcode(NetcodeError),
Renet(crate::DisconnectReason),
Expand Down
2 changes: 1 addition & 1 deletion renet_visualizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ bevy = ["dep:bevy_ecs"]
[dependencies]
renet = { path = "../renet", version = "0.0.12" }
egui = "0.22"
bevy_ecs = { version = "0.10.0", optional = true }
bevy_ecs = { version = "0.11.0", optional = true }