Skip to main content

RoomExit

Struct RoomExit 

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

Compact representation of an entire exit along a room edge.

Note: Storing collections of these will not be as efficient as just storing the raw edge terrain. This structure should be used for when you need to work with and reason about the exit properties, not for when you need to store all of the exits on an edge. For storing all the exit data in a compact representation, see RoomExitsData.

Implementations§

Source§

impl RoomExit

Source

pub fn new_from_packed(packed: u16) -> Self

Creates a new RoomExit from the packed representation.

Note: This will convert the exit direction to ExitDirection::Top if the relevant bits are not a valid ExitDirection.

Source

pub fn new(start: u8, length: u8, direction: ExitDirection) -> Self

Creates a new RoomExit from the start and length parameters.

Source

pub fn get_packed_from_parameters( start: u8, length: u8, direction: ExitDirection, ) -> u16

Helper function to get the packed representation from the start and length parameters.

Source

pub fn start(&self) -> u8

The start position of this exit.

Source

pub fn len(&self) -> u8

The length of this exit.

Source

pub fn end(&self) -> u8

The end position of this exit.

Source

pub fn exit_direction(&self) -> ExitDirection

The edge that this exit is on.

Source

pub fn packed(&self) -> u16

The packed representation of this exit.

Source

pub fn memory_size(&self) -> usize

How much space this exit takes up in memory (in bytes).

Source

pub fn get_exits_from_edge_terrain( terrain: &RoomEdgeTerrain, ) -> (Vec<Self>, Vec<Self>, Vec<Self>, Vec<Self>)

Extracts the individual exits for each edge from the compressed room edge terrain.

Returned ordering is: Top, Right, Bottom, Left

Source

pub fn get_exits_from_single_edge( terrain: &[Terrain; 50], direction: ExitDirection, ) -> Vec<Self>

Utility function that processes edge terrain into a list of exits.

Returned vector can be empty if the edge is entirely Walls, and thus has no exits.

Trait Implementations§

Source§

impl Clone for RoomExit

Source§

fn clone(&self) -> RoomExit

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 RoomExit

Source§

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

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

impl PartialEq for RoomExit

Source§

fn eq(&self, other: &RoomExit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for RoomExit

Source§

impl StructuralPartialEq for RoomExit

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.