fix: Pom diagonal movement #50
This commit is contained in:
@@ -53,10 +53,11 @@ fn handle_move(
|
|||||||
) {
|
) {
|
||||||
for message in move_messages.read() {
|
for message in move_messages.read() {
|
||||||
for (grid_pos, mut path_queue) in pom_query.iter_mut() {
|
for (grid_pos, mut path_queue) in pom_query.iter_mut() {
|
||||||
let start = (grid_pos.x, grid_pos.y);
|
let grid_start = (grid_pos.x, grid_pos.y);
|
||||||
|
let start = path_queue.steps.front().unwrap_or(&grid_start);
|
||||||
let end = (message.x, message.y);
|
let end = (message.x, message.y);
|
||||||
|
|
||||||
match find_path(start, end, &grid, &tile_query) {
|
match find_path(*start, end, &grid, &tile_query) {
|
||||||
Some(new_path) => {
|
Some(new_path) => {
|
||||||
path_queue.steps = new_path;
|
path_queue.steps = new_path;
|
||||||
}
|
}
|
||||||
@@ -65,7 +66,7 @@ fn handle_move(
|
|||||||
"Cannot move to ({}, {}). Path blocked or invalid.",
|
"Cannot move to ({}, {}). Path blocked or invalid.",
|
||||||
message.x, message.y
|
message.x, message.y
|
||||||
);
|
);
|
||||||
dbg!(msg);
|
dbg!(&msg);
|
||||||
invalid_move_messages.write(InvalidMoveMessage { message: msg });
|
invalid_move_messages.write(InvalidMoveMessage { message: msg });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ pub fn find_path(
|
|||||||
path.push_front(curr);
|
path.push_front(curr);
|
||||||
curr = *came_from.get(&curr).unwrap();
|
curr = *came_from.get(&curr).unwrap();
|
||||||
}
|
}
|
||||||
|
path.push_front(start);
|
||||||
return Some(path);
|
return Some(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user