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
impl RoomExit
Sourcepub fn new_from_packed(packed: u16) -> Self
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.
Sourcepub fn new(start: u8, length: u8, direction: ExitDirection) -> Self
pub fn new(start: u8, length: u8, direction: ExitDirection) -> Self
Creates a new RoomExit from the start and length parameters.
Sourcepub fn get_packed_from_parameters(
start: u8,
length: u8,
direction: ExitDirection,
) -> u16
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.
Sourcepub fn exit_direction(&self) -> ExitDirection
pub fn exit_direction(&self) -> ExitDirection
The edge that this exit is on.
Sourcepub fn memory_size(&self) -> usize
pub fn memory_size(&self) -> usize
How much space this exit takes up in memory (in bytes).
Sourcepub fn get_exits_from_edge_terrain(
terrain: &RoomEdgeTerrain,
) -> (Vec<Self>, Vec<Self>, Vec<Self>, Vec<Self>)
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
Sourcepub fn get_exits_from_single_edge(
terrain: &[Terrain; 50],
direction: ExitDirection,
) -> Vec<Self>
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.