Skip to main content

RoomExitsData

Struct RoomExitsData 

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

Compactly stores information about all the exits in a room.

Implementations§

Source§

impl RoomExitsData

Source

pub fn new_from_compressed_edge_terrain_data( data: RoomEdgeTerrain, room: RoomName, ) -> Self

Source

pub fn memory_size(&self) -> usize

The amount of memory used to store this data, in bytes.

Source

pub fn top_edge_exits(&self) -> Vec<RoomExit>

The exits, if any, along the top edge of the room.

Source

pub fn right_edge_exits(&self) -> Vec<RoomExit>

The exits, if any, along the right edge of the room.

Source

pub fn bottom_edge_exits(&self) -> Vec<RoomExit>

The exits, if any, along the bottom edge of the room.

Source

pub fn left_edge_exits(&self) -> Vec<RoomExit>

The exits, if any, along the left edge of the room.

Source

pub fn num_top_exits(&self) -> usize

The number of exits along the top edge of the room.

This is more efficient than constructing all of the exits, if you just need the exit count.

Source

pub fn num_right_exits(&self) -> usize

The number of exits along the right edge of the room.

This is more efficient than constructing all of the exits, if you just need the exit count.

Source

pub fn num_bottom_exits(&self) -> usize

The number of exits along the bottom edge of the room.

This is more efficient than constructing all of the exits, if you just need the exit count.

Source

pub fn num_left_exits(&self) -> usize

The number of exits along the left edge of the room.

This is more efficient than constructing all of the exits, if you just need the exit count.

Source

pub fn num_exits(&self) -> usize

The total number of exits along all edges of the room.

This is more efficient than constructing all of the exits, if you just need the exit count.

Source

pub fn edge_terrain_data(&self) -> &RoomEdgeTerrain

A reference to the underlying edge terrain data for the room.

Source

pub fn connected_to_top_neighbor(&self) -> bool

Returns true if the top edge has exits and has a neighbor to the north, false otherwise.

This is more efficient than self.top_edge_exits().len() if you’re just wanting connectivity data, as it doesn’t create the exits themselves, just checks for their existence.

Source

pub fn connected_to_right_neighbor(&self) -> bool

Returns true if the right edge has exits and has a neighbor to the east, false otherwise.

This is more efficient than self.right_edge_exits().len() if you’re just wanting connectivity data, as it doesn’t create the exits themselves, just checks for their existence.

Source

pub fn connected_to_bottom_neighbor(&self) -> bool

Returns true if the bottom edge has exits and has a neighbor to the south, false otherwise.

This is more efficient than self.bottom_edge_exits().len() if you’re just wanting connectivity data, as it doesn’t create the exits themselves, just checks for their existence.

Source

pub fn connected_to_left_neighbor(&self) -> bool

Returns true if the left edge has exits and has a neighbor to the west, false otherwise.

This is more efficient than self.left_edge_exits().len() if you’re just wanting connectivity data, as it doesn’t create the exits themselves, just checks for their existence.

Source

pub fn get_exit_by_index(&self, index: usize) -> Option<RoomExit>

Returns the room exit identified by iterating through edges clockwise (top, right, bottom, left) and then scanning through each edge linearly (left-to-right, top-to-bottom).

Example: If a room has no exits along the top edge, but has 2 exits along the right edge, then the exit at index 0 would be the exit on the right edge with the lower start position, and the exit at index 1 would be the exit on the right edge with the higher start position.

Returns None if the index represents a non-existent exit; this can happen if:

  • There are no exits to the room
  • There are exits to the room, but the index is greater than the number of exits - 1 (since we use a zero-based index)
Source

pub fn room(&self) -> RoomName

The room this data is for.

Source

pub fn iter(&self) -> RoomExitsIter

Returns an iterator over all the exits in the room.

Trait Implementations§

Source§

impl Clone for RoomExitsData

Source§

fn clone(&self) -> RoomExitsData

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RoomExitsData

Source§

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

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

impl Copy for RoomExitsData

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> CloneToUninit for T
where T: Clone,

Source§

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
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

Uses borrowed data to replace owned data, usually by cloning. Read more
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.