pub struct GridMap { /* private fields */ }
Expand description
A map with grid coordinates
§Examples
// Make a map that's 25x25 cells in size.
let map = GridMap::new(25, 25);
Implementations§
Source§impl GridMap
impl GridMap
Sourcepub fn new(xmax: usize, ymax: usize) -> GridMap
pub fn new(xmax: usize, ymax: usize) -> GridMap
Make a new GridMap
§Examples
// Make a map that's 25x25 cells in size.
let map = GridMap::new(25, 25);
Sourcepub fn get_limits(&self) -> (usize, usize)
pub fn get_limits(&self) -> (usize, usize)
Returns size of map in (x, y) format
§Examples
let limits = map.get_limits();
assert_eq!(limits, (25, 25));
Sourcepub fn get_cell_ref(&self, point: impl Into<Point>) -> &GridCell
pub fn get_cell_ref(&self, point: impl Into<Point>) -> &GridCell
Get a reference to a GridCell at coordinate.
Sourcepub fn get_cell_mut(&mut self, point: impl Into<Point>) -> &mut GridCell
pub fn get_cell_mut(&mut self, point: impl Into<Point>) -> &mut GridCell
Get a mutable reference to a GridCell at coordinate.
Sourcepub fn place_entrance(&mut self, point: impl Into<Point>) -> Result<()>
pub fn place_entrance(&mut self, point: impl Into<Point>) -> Result<()>
Set the entrance at a particular location. The cell at this location will be marked as having the entrance area type. Typically this will be coloured differently on a map.
Sourcepub fn place_entrance_near(&mut self, point: impl Into<Point>) -> Result<()>
pub fn place_entrance_near(&mut self, point: impl Into<Point>) -> Result<()>
Similar to place entrance, however it starts with the coordinates and finds the nearest spot that is already a “room”. This allows entrances to be placed in non-deterministic generators, such as caves.
Sourcepub fn place_room(&mut self, point0: impl Into<Point>, point1: impl Into<Point>)
pub fn place_room(&mut self, point0: impl Into<Point>, point1: impl Into<Point>)
Set a room
The room is specified by two sets of coordinates. The coordinates specify the bounds of the resulting room. The X-axis location of the room is the two specified X coordinates and all of the cells in between them. The Y-axis location of the room is the two specified Y coordinates and all of the cells in between them.
Sourcepub fn place_room_dimensions(
&mut self,
point: impl Into<Point>,
(w, h): (isize, isize),
)
pub fn place_room_dimensions( &mut self, point: impl Into<Point>, (w, h): (isize, isize), )
Place a room by setting the origin and width/height
Arguments:
- (x, y) -> The origin of the room. This will be a corner.
- (w, h) -> Width/Height of the room. Note, they’re isize because you can specify the w/h to be left OR right of the origin and up OR down, respectively.
Sourcepub fn place_hallway(
&mut self,
point0: impl Into<Point>,
point1: impl Into<Point>,
route: RouteMethod,
)
pub fn place_hallway( &mut self, point0: impl Into<Point>, point1: impl Into<Point>, route: RouteMethod, )
Place a hallway between two points
Sourcepub fn generate_random_cells(&mut self, limit: i64)
pub fn generate_random_cells(&mut self, limit: i64)
Generate random cells with a biasing towards more/less rooms. Limit is a value between 1 and 100. This limit sets the chance that the cells are a room. Higher limit means fewer rooms.
pub fn generate_annealed_random_cells(&mut self)
Sourcepub fn place_random_room(&mut self, scale: usize, connect: bool)
pub fn place_random_room(&mut self, scale: usize, connect: bool)
Place a randomly sized room of up to scale length or width.
pub fn generate_dungeon(&mut self, num_rooms: usize, room_size: usize)
pub fn generate_cave(&mut self, iter: i64, seed_limit: i64)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GridMap
impl RefUnwindSafe for GridMap
impl Send for GridMap
impl Sync for GridMap
impl Unpin for GridMap
impl UnwindSafe for GridMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more