use screeps::{Direction, Position};
pub fn get_next_step_direction_in_vec_pos(
current_pos: &Position,
path: &[Position],
) -> Option<Direction> {
if path.is_empty() {
return None;
}
for i in 0..path.len() {
let path_pos = path[i];
if path_pos == *current_pos {
if i == (path.len() - 1) {
return None; } else {
let next_pos = path[i + 1];
let direction = current_pos.get_direction_to(next_pos);
return direction;
}
}
}
if let Some(path_pos) = path.first() {
current_pos.get_direction_to(*path_pos)
} else {
None
}
}