aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/disconnect.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2023-03-07 14:14:36 -0600
committerGitHub <noreply@github.com>2023-03-07 14:14:36 -0600
commit719379a8a76ab0685f2bd14bebe2f0cd1e97f06b (patch)
treece5d6c62bc36fb1d1ec31083bc8e81a0109c12df /azalea-client/src/disconnect.rs
parentbf4ff517890cad3ff4e36b4b78959504192e5374 (diff)
downloadazalea-drasl-719379a8a76ab0685f2bd14bebe2f0cd1e97f06b.tar.xz
Bevy 0.10 (#79)
* replace 0.9.1 with 0.10.0 * start migrating to bevy .10 * well it compiles * doesn't immediately panic * remove unused imports * fmt * delete azalea-ecs * make RelativeEntityUpdate an EntityCommand * fix a doc test * explain what FixedUpdate does
Diffstat (limited to 'azalea-client/src/disconnect.rs')
-rw-r--r--azalea-client/src/disconnect.rs29
1 files changed, 16 insertions, 13 deletions
diff --git a/azalea-client/src/disconnect.rs b/azalea-client/src/disconnect.rs
index 9fd57e57..3b8d133e 100644
--- a/azalea-client/src/disconnect.rs
+++ b/azalea-client/src/disconnect.rs
@@ -1,30 +1,30 @@
//! Disconnect a client from the server.
-use azalea_ecs::{
- app::{App, CoreStage, Plugin},
+use bevy_app::{App, CoreSet, Plugin};
+use bevy_ecs::{
component::Component,
entity::Entity,
event::{EventReader, EventWriter},
query::Changed,
- schedule::IntoSystemDescriptor,
+ schedule::IntoSystemConfigs,
system::{Commands, Query},
- AppTickExt,
};
use derive_more::Deref;
-use crate::{client::JoinedClientBundle, movement::send_position, LocalPlayer};
+use crate::{client::JoinedClientBundle, LocalPlayer};
pub struct DisconnectPlugin;
impl Plugin for DisconnectPlugin {
fn build(&self, app: &mut App) {
- app.add_event::<DisconnectEvent>()
- .add_system_to_stage(CoreStage::PostUpdate, handle_disconnect)
- .add_tick_system(
- update_read_packets_task_running_component
- .before(disconnect_on_read_packets_ended)
- .before(send_position),
+ app.add_event::<DisconnectEvent>().add_systems(
+ (
+ update_read_packets_task_running_component,
+ disconnect_on_read_packets_ended,
+ remove_components_from_disconnected_players,
)
- .add_tick_system(disconnect_on_read_packets_ended);
+ .in_base_set(CoreSet::PostUpdate)
+ .chain(),
+ );
}
}
@@ -35,7 +35,10 @@ pub struct DisconnectEvent {
/// System that removes the [`JoinedClientBundle`] from the entity when it
/// receives a [`DisconnectEvent`].
-pub fn handle_disconnect(mut commands: Commands, mut events: EventReader<DisconnectEvent>) {
+pub fn remove_components_from_disconnected_players(
+ mut commands: Commands,
+ mut events: EventReader<DisconnectEvent>,
+) {
for DisconnectEvent { entity } in events.iter() {
commands.entity(*entity).remove::<JoinedClientBundle>();
}