Skip to main content

SectorGraph

Struct SectorGraph 

Source
pub struct SectorGraph {
    pub cell_node: Vec<i32>,
    /* private fields */
}
Expand description

The sector graph: the map cut into 8 × 8-cell sectors, the walkable areas of each sector as nodes, and links between neighbouring areas. It gives the “path rank” distance that storage, job and resource searches use, and caches it.

Fields§

§cell_node: Vec<i32>

Cell: node of each cell (-1 none).

Implementations§

Source§

impl SectorGraph

Source

pub fn new(size: usize, types: &[CellType]) -> SectorGraph

The graph of a map: every sector is built, then linked, in index order.

Original: FUN_1400adb40, then FUN_1400adf60.

Source

pub fn mark(&mut self, x: i32, y: i32)

A cell changed; rebuild its sector and relink the 3 × 3 around it.

Original: FUN_1400ae160.

Source

pub fn rebuild(&mut self, types: &[CellType])

Rebuild and relink the sectors that mark marked.

Original: FUN_1400adf60.

Source

pub fn node_near(&self, cell: i32) -> i32

The node of cell, else the first node found on rings 1–3 around it.

Original: FUN_1400a2570.

Source

pub fn distance( &mut self, a: i32, b: i32, reachable: bool, store: bool, types: &[CellType], ) -> i32

The path-rank distance from cell a to cell b, or -1 when b cannot be reached. reachable is the caller’s region test (both cells in the same walkable region); store keeps a computed distance in the cache.

Original: FUN_1400a4ce0.

Source

pub fn age_cache(&mut self, dt: i64)

Age the cache by dt ticks, and drop the entries older than 120 seconds. The game calls it once per simulation iteration.

Original: FUN_1400ab1e0.

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

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.