Struct movingai::MovingAiMap

source ·
pub struct MovingAiMap { /* private fields */ }
Expand description

Contains data structure for 2D MovingAI maps. An immutable representation of a MovingAI map.

Implementations§

source§

impl MovingAiMap

source

pub fn new( map_type: String, height: usize, width: usize, map: Vec<char> ) -> MovingAiMap

Create a new MovingAIMap object from basic components.

§Arguments
  • map_type: The type of map you are registering. Usually octile.
  • height: the height of the map.
  • width: the width of the map.
  • map: A vector representing the map in row-major order.
§Panics

The new call will panic id the size of the map vector is different from heigth*width.

source

pub fn new_from_slice( map_type: String, height: usize, width: usize, map: Box<[char]> ) -> MovingAiMap

Create a new MovingAIMap object from basic components.

§Arguments
  • map_type: The type of map you are registering. Usually octile.
  • height: the height of the map.
  • width: the width of the map.
  • map: A boxed slice representing the map in row-major order.
§Panics

The new call will panic id the size of the map vector is different from heigth*width.

Trait Implementations§

source§

impl Debug for MovingAiMap

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Index<(usize, usize)> for MovingAiMap

§

type Output = char

The returned type after indexing.
source§

fn index(&self, coords: Coords2D) -> &char

Performs the indexing (container[index]) operation. Read more
source§

impl Map2D<char> for MovingAiMap

source§

fn width(&self) -> usize

Every Map2D must have a width.
source§

fn height(&self) -> usize

Every Map2D must have an height.
source§

fn get(&self, coords: Coords2D) -> &char

In every Map2D must be possible to get a tile. Read more
source§

fn is_out_of_bound(&self, coords: Coords2D) -> bool

Check if the given coordinates are out of bound. Read more
source§

fn is_traversable(&self, tile: Coords2D) -> bool

Check if a tile in the map can be traversed. Read more
source§

fn is_traversable_from(&self, from: Coords2D, to: Coords2D) -> bool

Check if a tile in the map can be traversed coming from the from tile. Read more
source§

fn coords(&self) -> CoordsIter

Return an iterator returning all the coordinates in the map in row-major order.
source§

fn free_states(&self) -> usize

Return the number of free states of a map. Read more
source§

fn neighbors(&self, tile: Coords2D) -> Vec<Coords2D>

Return the list of accessible neighbors of a tile.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.