diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2023-08-24 22:59:40 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-24 22:59:40 -0500 |
| commit | 11d14c74c53c07231c8ca33b622380df99bf9a59 (patch) | |
| tree | ea1d0c61a6d5f8af550a708ff3b71fbbaed5d122 /azalea/src | |
| parent | 57e5a0f0b96a38674bd18ac38d2d07e4f4ca2fd6 (diff) | |
| download | azalea-drasl-11d14c74c53c07231c8ca33b622380df99bf9a59.tar.xz | |
Support properly switching instances (#106)
* start implementing switching dimensions
* fix removeentity in shared worlds
* also store entity ids per local player
* uncomment a trace in pathfinder
* cleanup
---------
Co-authored-by: mat <git@matdoes.dev>
Diffstat (limited to 'azalea/src')
| -rw-r--r-- | azalea/src/pathfinder/mod.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index 9237aa81..58b59fd4 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -24,10 +24,11 @@ use azalea_physics::PhysicsSet; use azalea_world::{InstanceContainer, InstanceName}; use bevy_app::{FixedUpdate, Update}; use bevy_ecs::prelude::Event; +use bevy_ecs::query::Changed; use bevy_ecs::schedule::IntoSystemConfigs; use bevy_tasks::{AsyncComputeTaskPool, Task}; use futures_lite::future; -use log::{debug, error}; +use log::{debug, error, trace}; use std::collections::VecDeque; use std::sync::Arc; @@ -49,6 +50,7 @@ impl Plugin for PathfinderPlugin { goto_listener, add_default_pathfinder, (handle_tasks, path_found_listener).chain(), + stop_pathfinding_on_instance_change, ), ); } @@ -249,7 +251,7 @@ fn tick_execute_path( entity, position: center, }); - debug!( + trace!( "tick: pathfinder {entity:?}; going to {:?}; currently at {position:?}", target.pos ); @@ -280,6 +282,22 @@ fn tick_execute_path( } } +fn stop_pathfinding_on_instance_change( + mut query: Query<(Entity, &mut Pathfinder), Changed<InstanceName>>, + mut walk_events: EventWriter<StartWalkEvent>, +) { + for (entity, mut pathfinder) in &mut query { + if !pathfinder.path.is_empty() { + debug!("instance changed, clearing path"); + pathfinder.path.clear(); + walk_events.send(StartWalkEvent { + entity, + direction: WalkDirection::None, + }); + } + } +} + /// Information about our vertical velocity #[derive(Eq, PartialEq, Hash, Clone, Copy, Debug)] pub enum VerticalVel { |
