flatland-pathfinding 0.2.83

Shared grid A* pathfinding for Flatland3 clients and sim
Documentation
//! Auto-nav / AI path cost mode.

/// How A* weights walkable terrain.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum PathMode {
    /// Minimize travel time using `1 / move_speed_mult` (default).
    #[default]
    Fastest,
    /// Minimize geometric length; all walkable cells share the same cost.
    Direct,
}

impl PathMode {
    pub fn parse(s: &str) -> Self {
        match s.trim().to_ascii_lowercase().as_str() {
            "direct" => Self::Direct,
            _ => Self::Fastest,
        }
    }

    pub fn as_str(self) -> &'static str {
        match self {
            Self::Fastest => "fastest",
            Self::Direct => "direct",
        }
    }
}