wde_terrain_navigation/
lib.rs1use bevy::prelude::*;
2
3mod navgrid;
4mod navigation;
5
6pub mod prelude {
7 pub use super::TerrainNavigator;
8 pub use super::navgrid::{CONTROL_ROOM_ROLE, NavBase, NavBuilding, NavGrid, NavNeighbor};
9 pub use super::navigation::{AIRLOCK_ROLE, Indoors, NavAgent, WalkSpeeds};
10}
11
12pub struct TerrainNavigationPlugin;
13impl Plugin for TerrainNavigationPlugin {
14 fn build(&self, app: &mut App) {
15 app.add_plugins((navigation::NavigationPlugin, navgrid::NavMapPlugin))
16 .init_resource::<TerrainNavigator>();
17 }
18}
19
20#[derive(Resource, Default)]
23pub struct TerrainNavigator {
24 new_entities: Vec<(Entity, Vec3)>,
25 groups: Vec<(Vec<Entity>, Vec3)>,
26 removed_entities: Vec<Entity>
27}
28impl TerrainNavigator {
29 pub fn add(&mut self, entity: Entity, destination: Vec3) {
31 self.new_entities.push((entity, destination));
32 }
33
34 pub fn add_group(&mut self, entities: impl IntoIterator<Item = Entity>, destination: Vec3) {
37 self.groups
38 .push((entities.into_iter().collect(), destination));
39 }
40
41 pub fn remove(&mut self, entity: Entity) {
43 self.removed_entities.push(entity);
44 }
45}