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
impl SectorGraph
Sourcepub fn new(size: usize, types: &[CellType]) -> SectorGraph
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.
Sourcepub fn mark(&mut self, x: i32, y: i32)
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.
Sourcepub fn rebuild(&mut self, types: &[CellType])
pub fn rebuild(&mut self, types: &[CellType])
Rebuild and relink the sectors that mark marked.
Original: FUN_1400adf60.
Sourcepub fn node_near(&self, cell: i32) -> i32
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.
Sourcepub fn distance(
&mut self,
a: i32,
b: i32,
reachable: bool,
store: bool,
types: &[CellType],
) -> i32
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.