From eaed442578c3b1765ec48c84489a122096b6a08f Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 20 Oct 2025 20:58:14 +0200 Subject: Send paths as debug events --- server/bot/src/pathfinding.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'server/bot/src/pathfinding.rs') 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 { -- cgit v1.3