feat: Add path visualisation (#58)
This commit is contained in:
@@ -27,12 +27,44 @@ impl Plugin for PomPlugin {
|
||||
move_pom,
|
||||
update_pom,
|
||||
perform_interaction,
|
||||
draw_path,
|
||||
)
|
||||
.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>) {
|
||||
commands.spawn((
|
||||
Pom,
|
||||
|
||||
Reference in New Issue
Block a user