feat: Add path visualisation (#58)

This commit is contained in:
demenik
2025-12-02 14:48:03 +01:00
parent 6d25c5b9ad
commit c4f0543bb6

View File

@@ -27,12 +27,44 @@ impl Plugin for PomPlugin {
move_pom, move_pom,
update_pom, update_pom,
perform_interaction, perform_interaction,
draw_path,
) )
.run_if(in_state(AppState::GameScreen)), .run_if(in_state(AppState::GameScreen)),
); );
} }
} }
fn draw_path(
mut gizmos: Gizmos,
query: Query<(&Transform, &PathQueue), With<Pom>>,
config: Res<GameConfig>,
) {
let Ok((transform, path_queue)) = query.single() else {
return;
};
if path_queue.steps.is_empty() {
return;
}
let line_z = 0.5;
let mut current_pos = transform.translation;
current_pos.z = line_z;
for step in &path_queue.steps {
let next_pos = grid_to_world_coords(
step.0,
step.1,
Some(line_z),
config.grid_width,
config.grid_height,
);
gizmos.line(current_pos, next_pos, Color::srgba(1.0, 1.0, 1.0, 0.3));
current_pos = next_pos;
}
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>, config: Res<GameConfig>) { fn setup(mut commands: Commands, asset_server: Res<AssetServer>, config: Res<GameConfig>) {
commands.spawn(( commands.spawn((
Pom, Pom,