| 50 | } |
| 51 | |
| 52 | pub fn process_movement(world: &mut World, resources: &mut Resources) { |
| 53 | for (_, (movement, position)) in world.query::<(&mut Movement, &mut Position)>().iter() { |
| 54 | let (target_x, target_y) = match movement.move_queue.pop_front() { |
| 55 | Some(MoveAction::Up) => (position.x, position.y - 1), |
| 56 | Some(MoveAction::Down) => (position.x, position.y + 1), |
| 57 | Some(MoveAction::Left) => (position.x - 1, position.y), |
| 58 | Some(MoveAction::Right) => (position.x + 1, position.y), |
| 59 | _ => continue, |
| 60 | }; |
| 61 | |
| 62 | if let Some(tile) = resources.map.get(target_x, target_y) { |
| 63 | if tile.solid { |
| 64 | continue; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | position.x = target_x; |
| 69 | position.y = target_y; |
| 70 | movement.energy = 0; |
| 71 | |
| 72 | if movement.player_input { |
| 73 | resources.turn_state.waiting = false; |
| 74 | } |
| 75 | } |
| 76 | } |