Skip to content

Commit

Permalink
BevyRenet: fix bevy sets (#126)
Browse files Browse the repository at this point in the history
Add missing set for some bevy systems
  • Loading branch information
Shatur authored Nov 16, 2023
1 parent b0a66a1 commit 9af9325
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions bevy_renet/src/steam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,26 @@ impl Plugin for SteamClientPlugin {
app.add_systems(
PreUpdate,
Self::update_system
.in_set(RenetReceive)
.run_if(resource_exists::<SteamClientTransport>())
.run_if(resource_exists::<RenetClient>())
.after(RenetClientPlugin::update_system),
);
app.add_systems(
PostUpdate,
(Self::send_packets, Self::disconnect_on_exit)
(Self::send_packets.in_set(RenetSend), Self::disconnect_on_exit)
.run_if(resource_exists::<SteamClientTransport>())
.run_if(resource_exists::<RenetClient>()),
);
}
}

impl SteamClientPlugin {
pub fn update_system(mut transport: ResMut<SteamClientTransport>, mut client: ResMut<RenetClient>) {
fn update_system(mut transport: ResMut<SteamClientTransport>, mut client: ResMut<RenetClient>) {
transport.update(&mut client);
}

pub fn send_packets(
fn send_packets(
mut transport: ResMut<SteamClientTransport>,
mut client: ResMut<RenetClient>,
mut transport_errors: EventWriter<SteamTransportError>,
Expand Down
7 changes: 4 additions & 3 deletions bevy_renet/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,22 @@ impl Plugin for NetcodeClientPlugin {
app.add_systems(
PreUpdate,
Self::update_system
.in_set(RenetReceive)
.run_if(resource_exists::<NetcodeClientTransport>())
.run_if(resource_exists::<RenetClient>())
.after(RenetClientPlugin::update_system),
);
app.add_systems(
PostUpdate,
(Self::send_packets, Self::disconnect_on_exit)
(Self::send_packets.in_set(RenetSend), Self::disconnect_on_exit)
.run_if(resource_exists::<NetcodeClientTransport>())
.run_if(resource_exists::<RenetClient>()),
);
}
}

impl NetcodeClientPlugin {
pub fn update_system(
fn update_system(
mut transport: ResMut<NetcodeClientTransport>,
mut client: ResMut<RenetClient>,
time: Res<Time>,
Expand All @@ -88,7 +89,7 @@ impl NetcodeClientPlugin {
}
}

pub fn send_packets(
fn send_packets(
mut transport: ResMut<NetcodeClientTransport>,
mut client: ResMut<RenetClient>,
mut transport_errors: EventWriter<NetcodeTransportError>,
Expand Down

0 comments on commit 9af9325

Please sign in to comment.