Trait BaseMap

Source
pub trait BaseMap {
    // Provided methods
    fn is_opaque(&self, _idx: usize) -> bool { ... }
    fn get_available_exits(&self, _idx: usize) -> SmallVec<[(usize, f32); 10]> { ... }
    fn get_pathing_distance(&self, _idx1: usize, _idx2: usize) -> f32 { ... }
}
Expand description

Implement this trait to support path-finding functions.

Provided Methods§

Source

fn is_opaque(&self, _idx: usize) -> bool

True is you cannot see through the tile, false otherwise. Default implementation always returns true, and is provided so you don’t have to implement it if you aren’t using it.

Source

fn get_available_exits(&self, _idx: usize) -> SmallVec<[(usize, f32); 10]>

Return a vector of tile indices to which one can path from the idx. These do NOT have to be contiguous - if you want to support teleport pads, that’s awesome. Default implementation is provided that proves an empty list, in case you aren’t using it.

Note that you should never return the current tile as an exit. The A* implementation really doesn’t like that.

Source

fn get_pathing_distance(&self, _idx1: usize, _idx2: usize) -> f32

Return the distance you would like to use for path-finding. Generally, Pythagoras distance (implemented in geometry) is fine, but you might use Manhattan or any other heuristic that fits your problem. Default implementation returns 1.0, which isn’t what you want but prevents you from having to implement it when not using it.

Implementors§