diff options
Diffstat (limited to 'server/bot/src/pathfinding.rs')
| -rw-r--r-- | server/bot/src/pathfinding.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/server/bot/src/pathfinding.rs b/server/bot/src/pathfinding.rs index ec098495..5c5551dd 100644 --- a/server/bot/src/pathfinding.rs +++ b/server/bot/src/pathfinding.rs @@ -16,7 +16,12 @@ */ use hurrycurry_game_core::Game; -use hurrycurry_protocol::glam::{IVec2, Vec2}; +#[cfg(feature = "debug_events")] +use hurrycurry_protocol::{DebugEvent, PlayerID}; +use hurrycurry_protocol::{ + DebugEventDisplay, + glam::{IVec2, Vec2}, +}; use log::{debug, trace}; use std::{ cmp::Ordering, @@ -57,6 +62,25 @@ impl Path { pub fn remaining_segments(&self) -> usize { self.segments.len() } + + #[cfg(feature = "debug_events")] + pub fn debug(&self, id: PlayerID) -> DebugEvent { + use std::f32::consts::TAU; + + use hurrycurry_protocol::glam::Vec3; + let a = id.0 as f32; + DebugEvent { + key: format!("path-{id}"), + color: Vec3::new( + (a + TAU / 3. * 0.).sin(), + (a + TAU / 3. * 1.).sin(), + (a + TAU / 3. * 2.).sin(), + ), + display: DebugEventDisplay::Path { + points: self.segments.clone(), + }, + } + } } pub fn find_path_to_neighbour(game: &Game, from: IVec2, to: IVec2) -> Option<Path> { |