blitz_path/route.rs
1use std::convert::From;
2
3use movingai::Coords2D;
4
5///Describes a route between two points.
6///Giving the total distance needed to travel and a vector of each step needed.
7pub struct Route {
8 distance: f64,
9 steps: Vec<Coords2D>,
10}
11
12impl From<(f64, Vec<Coords2D>)> for Route {
13 fn from(item: (f64, Vec<Coords2D>)) -> Self {
14 Route {
15 distance: item.0,
16 steps: item.1,
17 }
18 }
19}
20
21impl Route {
22 ///Returns a vector of Coords2D, each representing a step in the path.
23 ///Organised in reverse order (destination is at [0]) to allow calling .pop() to get each step.
24 pub fn steps(&self) -> Vec<Coords2D> {
25 self.steps.clone()
26 }
27
28 ///Returns the total distance needed to travel as an f64.
29 pub fn distance(&self) -> f64 {
30 self.distance
31 }
32}