pub struct RoomExitsData { /* private fields */ }Expand description
Compactly stores information about all the exits in a room.
Implementations§
Source§impl RoomExitsData
impl RoomExitsData
pub fn new_from_compressed_edge_terrain_data( data: RoomEdgeTerrain, room: RoomName, ) -> Self
Sourcepub fn memory_size(&self) -> usize
pub fn memory_size(&self) -> usize
The amount of memory used to store this data, in bytes.
Sourcepub fn top_edge_exits(&self) -> Vec<RoomExit>
pub fn top_edge_exits(&self) -> Vec<RoomExit>
The exits, if any, along the top edge of the room.
Sourcepub fn right_edge_exits(&self) -> Vec<RoomExit>
pub fn right_edge_exits(&self) -> Vec<RoomExit>
The exits, if any, along the right edge of the room.
Sourcepub fn bottom_edge_exits(&self) -> Vec<RoomExit>
pub fn bottom_edge_exits(&self) -> Vec<RoomExit>
The exits, if any, along the bottom edge of the room.
Sourcepub fn left_edge_exits(&self) -> Vec<RoomExit>
pub fn left_edge_exits(&self) -> Vec<RoomExit>
The exits, if any, along the left edge of the room.
Sourcepub fn num_top_exits(&self) -> usize
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.
Sourcepub fn num_right_exits(&self) -> usize
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.
Sourcepub fn num_bottom_exits(&self) -> usize
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.
Sourcepub fn num_left_exits(&self) -> usize
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.
Sourcepub fn num_exits(&self) -> usize
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.
Sourcepub fn edge_terrain_data(&self) -> &RoomEdgeTerrain
pub fn edge_terrain_data(&self) -> &RoomEdgeTerrain
A reference to the underlying edge terrain data for the room.
Sourcepub fn connected_to_top_neighbor(&self) -> bool
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.
Sourcepub fn connected_to_right_neighbor(&self) -> bool
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.
Sourcepub fn connected_to_bottom_neighbor(&self) -> bool
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.
Sourcepub fn connected_to_left_neighbor(&self) -> bool
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.
Sourcepub fn get_exit_by_index(&self, index: usize) -> Option<RoomExit>
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)
Sourcepub fn iter(&self) -> RoomExitsIter ⓘ
pub fn iter(&self) -> RoomExitsIter ⓘ
Returns an iterator over all the exits in the room.
Trait Implementations§
Source§impl Clone for RoomExitsData
impl Clone for RoomExitsData
Source§fn clone(&self) -> RoomExitsData
fn clone(&self) -> RoomExitsData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more