Skip to main content

Map

Struct Map 

Source
pub struct Map {
    pub size: usize,
    pub types: Vec<CellType>,
}
Expand description

The gameplay map: the type of each cell. See Map::find_start for the start of a new town.

Fields§

§size: usize

Cells per side (n).

§types: Vec<CellType>

Cell type (byte) per cell, row-major.

Implementations§

Source§

impl Map

Source

pub fn new(size: usize, terrain: &HeightGrid<'_>) -> Map

Classify every cell from the terrain.

Original: FUN_1400a43f0.

Source

pub fn is_clear(&self, x: i32, y: i32, radius: i32, radius_sq: i32) -> bool

Every cell within radius (dx² + dy² ≤ radius_sq) of (x, y) is in the map and buildable ground.

Original: FUN_1400a7d50.

Source

pub fn find_start(&self, radius: i32) -> (i32, i32)

The town’s start cell. Rings outward from the map centre, testing 4, 8, 16, … evenly spaced angles per ring and moving out 3r/4 cells each ring. Loops forever (as the original does) if no clear area exists.

Original: FUN_1400a7bf0.

Auto Trait Implementations§

§

impl Freeze for Map

§

impl RefUnwindSafe for Map

§

impl Send for Map

§

impl Sync for Map

§

impl Unpin for Map

§

impl UnsafeUnpin for Map

§

impl UnwindSafe for Map

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>,

Source§

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>,

Source§

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.