flatland_pathfinding/mode.rs
1//! Auto-nav / AI path cost mode.
2
3/// How A* weights walkable terrain.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
5pub enum PathMode {
6 /// Minimize travel time using `1 / move_speed_mult` (default).
7 #[default]
8 Fastest,
9 /// Minimize geometric length; all walkable cells share the same cost.
10 Direct,
11}
12
13impl PathMode {
14 pub fn parse(s: &str) -> Self {
15 match s.trim().to_ascii_lowercase().as_str() {
16 "direct" => Self::Direct,
17 _ => Self::Fastest,
18 }
19 }
20
21 pub fn as_str(self) -> &'static str {
22 match self {
23 Self::Fastest => "fastest",
24 Self::Direct => "direct",
25 }
26 }
27}