diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2023-03-07 14:14:36 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-07 14:14:36 -0600 |
| commit | 719379a8a76ab0685f2bd14bebe2f0cd1e97f06b (patch) | |
| tree | ce5d6c62bc36fb1d1ec31083bc8e81a0109c12df /azalea/src/swarm | |
| parent | bf4ff517890cad3ff4e36b4b78959504192e5374 (diff) | |
| download | azalea-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/src/swarm')
| -rw-r--r-- | azalea/src/swarm/chat.rs | 18 | ||||
| -rw-r--r-- | azalea/src/swarm/events.rs | 8 | ||||
| -rw-r--r-- | azalea/src/swarm/mod.rs | 11 |
3 files changed, 13 insertions, 24 deletions
diff --git a/azalea/src/swarm/chat.rs b/azalea/src/swarm/chat.rs index 18c27cd6..303ce35b 100644 --- a/azalea/src/swarm/chat.rs +++ b/azalea/src/swarm/chat.rs @@ -13,14 +13,14 @@ // in Swarm that's set to the smallest index of all the bots, and we remove all // messages from the queue that are before that index. -use azalea_client::chat::{ChatPacket, ChatReceivedEvent}; -use azalea_ecs::{ - app::{App, Plugin}, +use crate::ecs::{ component::Component, event::{EventReader, EventWriter}, - schedule::IntoSystemDescriptor, + schedule::IntoSystemConfigs, system::{Commands, Query, Res, ResMut, Resource}, }; +use azalea_client::chat::{ChatPacket, ChatReceivedEvent}; +use bevy_app::{App, Plugin}; use std::collections::VecDeque; use super::{Swarm, SwarmEvent}; @@ -30,8 +30,7 @@ pub struct SwarmChatPlugin; impl Plugin for SwarmChatPlugin { fn build(&self, app: &mut App) { app.add_event::<NewChatMessageEvent>() - .add_system(chat_listener.label("chat_listener")) - .add_system(update_min_index_and_shrink_queue.after("chat_listener")) + .add_systems((chat_listener, update_min_index_and_shrink_queue).chain()) .insert_resource(GlobalChatState { chat_queue: VecDeque::new(), chat_min_index: 0, @@ -151,7 +150,7 @@ fn update_min_index_and_shrink_queue( #[cfg(test)] mod tests { - use azalea_ecs::{ecs::Ecs, event::Events, system::SystemState}; + use bevy_ecs::{event::Events, prelude::World, system::SystemState}; use super::*; @@ -161,8 +160,7 @@ mod tests { // event mangement in drain_events app.init_resource::<Events<ChatReceivedEvent>>() .init_resource::<Events<NewChatMessageEvent>>() - .add_system(chat_listener.label("chat_listener")) - .add_system(update_min_index_and_shrink_queue.after("chat_listener")) + .add_systems((chat_listener, update_min_index_and_shrink_queue).chain()) .insert_resource(GlobalChatState { chat_queue: VecDeque::new(), chat_min_index: 0, @@ -170,7 +168,7 @@ mod tests { app } - fn drain_events(ecs: &mut Ecs) -> Vec<ChatPacket> { + fn drain_events(ecs: &mut World) -> Vec<ChatPacket> { let mut system_state: SystemState<ResMut<Events<NewChatMessageEvent>>> = SystemState::new(ecs); let mut events = system_state.get_mut(ecs); diff --git a/azalea/src/swarm/events.rs b/azalea/src/swarm/events.rs index 81d8c731..62593029 100644 --- a/azalea/src/swarm/events.rs +++ b/azalea/src/swarm/events.rs @@ -1,11 +1,7 @@ use azalea_client::LocalPlayer; -use azalea_ecs::{ - app::{App, Plugin}, - event::EventWriter, - query::With, - system::{Query, ResMut, Resource}, -}; use azalea_world::entity::MinecraftEntityId; +use bevy_app::{App, Plugin}; +use bevy_ecs::prelude::*; use derive_more::{Deref, DerefMut}; pub struct SwarmPlugin; diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs index c0d9cb56..97020153 100644 --- a/azalea/src/swarm/mod.rs +++ b/azalea/src/swarm/mod.rs @@ -6,19 +6,14 @@ pub mod prelude; use crate::{bot::DefaultBotPlugins, HandleFn}; use azalea_client::{chat::ChatPacket, init_ecs_app, start_ecs, Account, Client, Event, JoinError}; -use azalea_ecs::{ - app::{App, Plugin, PluginGroup, PluginGroupBuilder}, - component::Component, - ecs::Ecs, - entity::Entity, - system::Resource, -}; use azalea_protocol::{ connect::ConnectionError, resolver::{self, ResolverError}, ServerAddress, }; use azalea_world::WorldContainer; +use bevy_app::{App, Plugin, PluginGroup, PluginGroupBuilder}; +use bevy_ecs::{component::Component, entity::Entity, system::Resource, world::World}; use futures::future::join_all; use log::error; use parking_lot::{Mutex, RwLock}; @@ -35,7 +30,7 @@ use tokio::sync::mpsc; /// It's used to make the [`Swarm::add`] function work. #[derive(Clone, Resource)] pub struct Swarm { - pub ecs_lock: Arc<Mutex<Ecs>>, + pub ecs_lock: Arc<Mutex<World>>, bots: Arc<Mutex<HashMap<Entity, Client>>>, |
