Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

RegionGraph

Struct RegionGraph 

Source
pub struct RegionGraph { /* private fields */ }
Expand description

Regions, the walk distance between neighbours, and for each region the set of regions that must be resident while the player is in it (the cooker’s closure V(R)).

Implementations§

Source§

impl RegionGraph

Source

pub fn new() -> Self

An empty graph.

Source

pub fn chain(count: u32, sectors: u32, length: u32) -> Self

A chain of count regions of sectors sectors, neighbours length units apart, each needing itself only until Self::needs_with_neighbors.

Source

pub fn grid(width: u32, height: u32, sectors: u32, length: u32) -> Self

A width x height grid, row-major on disc, neighbours length apart.

Source

pub fn add_region(&mut self, sectors: u32) -> u32

Add a region; returns its id (ids are dense from 0). Its disc position is set by Self::layout_in_order or Self::place.

Source

pub fn place(&mut self, region: u32, lba: u32)

Put region at sector lba.

Source

pub fn layout_in_order(&mut self, start_lba: u32, gap: u32)

Lay regions out in id order from start_lba, gap sectors apart.

Source

pub fn connect(&mut self, a: u32, b: u32, length: u32)

Connect two regions both ways, length units apart.

Source

pub fn set_needs(&mut self, region: u32, needs: &[u32])

Set the regions that must be resident while the player is in region.

Source

pub fn needs_with_neighbors(&mut self)

Every region needs itself and its direct neighbours.

Source

pub fn region_count(&self) -> usize

Number of regions.

Source

pub fn region(&self, id: u32) -> SimRegion

Region id.

Source

pub fn needs(&self, region: u32) -> &[u32]

Regions needed while the player is in region.

Source

pub fn edge_length(&self, a: u32, b: u32) -> Option<u32>

Edge length between two neighbours.

Source

pub fn total_sectors(&self) -> u64

Total sectors of all regions.

Source

pub fn distances_from(&self, from: u32) -> Vec<u32>

Walk distance from from to every region (Dijkstra over edge lengths); u32::MAX for unreachable regions.

Trait Implementations§

Source§

impl Clone for RegionGraph

Source§

fn clone(&self) -> RegionGraph

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RegionGraph

Source§

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

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

impl Default for RegionGraph

Source§

fn default() -> RegionGraph

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for RegionGraph

§

impl RefUnwindSafe for RegionGraph

§

impl Send for RegionGraph

§

impl Sync for RegionGraph

§

impl Unpin for RegionGraph

§

impl UnsafeUnpin for RegionGraph

§

impl UnwindSafe for RegionGraph

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.