From 719379a8a76ab0685f2bd14bebe2f0cd1e97f06b Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Tue, 7 Mar 2023 14:14:36 -0600 Subject: 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 --- azalea-client/src/disconnect.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'azalea-client/src/disconnect.rs') 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::() - .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::().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) { +pub fn remove_components_from_disconnected_players( + mut commands: Commands, + mut events: EventReader, +) { for DisconnectEvent { entity } in events.iter() { commands.entity(*entity).remove::(); } -- cgit v1.2.3