diff options
| author | metamuffin <metamuffin@disroot.org> | 2025-10-20 20:58:14 +0200 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2025-10-21 00:18:11 +0200 |
| commit | eaed442578c3b1765ec48c84489a122096b6a08f (patch) | |
| tree | bd5eeb82ea6f49691a4c5bad91a1b1614f0948a8 /server/bot/src/pathfinding.rs | |
| parent | a3b0879a98bf5a0881b426913d7dd4cb9010e327 (diff) | |
| download | hurrycurry-eaed442578c3b1765ec48c84489a122096b6a08f.tar hurrycurry-eaed442578c3b1765ec48c84489a122096b6a08f.tar.bz2 hurrycurry-eaed442578c3b1765ec48c84489a122096b6a08f.tar.zst | |
Send paths as debug events
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> { |