This commit is contained in:
parent
d56c6cc5c7
commit
cc4b8751f4
|
@ -33,7 +33,7 @@ derive_more = "0.99"
|
||||||
futures-lite = "1"
|
futures-lite = "1"
|
||||||
gilrs = "0.8"
|
gilrs = "0.8"
|
||||||
here_be_dragons = "0.1"
|
here_be_dragons = "0.1"
|
||||||
maze_generator = "1"
|
maze_generator = "2"
|
||||||
once_cell = "1"
|
once_cell = "1"
|
||||||
pathfinding = "3"
|
pathfinding = "3"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
|
|
94
src/map.rs
94
src/map.rs
|
@ -174,55 +174,59 @@ impl<D: Clone + Default> MapFilter<D> for GridBuilder {
|
||||||
fn modify_map(&self, _rng: &mut StdRng, map: &MapgenMap<D>) -> MapgenMap<D> {
|
fn modify_map(&self, _rng: &mut StdRng, map: &MapgenMap<D>) -> MapgenMap<D> {
|
||||||
let mut map = map.clone();
|
let mut map = map.clone();
|
||||||
let mut generator = RbGenerator::new(None);
|
let mut generator = RbGenerator::new(None);
|
||||||
let maze = generator.generate(self.width_in_rooms as i32, self.height_in_rooms as i32);
|
if let Ok(maze) =
|
||||||
let total_height = (self.room_height + 1) * self.height_in_rooms + 1;
|
generator.generate(self.width_in_rooms as i32, self.height_in_rooms as i32)
|
||||||
let half_width = self.room_width / 2;
|
{
|
||||||
let half_height = self.room_height / 2;
|
let total_height = (self.room_height + 1) * self.height_in_rooms + 1;
|
||||||
for y in 0..self.height_in_rooms {
|
let half_width = self.room_width / 2;
|
||||||
for x in 0..self.width_in_rooms {
|
let half_height = self.room_height / 2;
|
||||||
let x_offset = x * (self.room_width + 1);
|
for y in 0..self.height_in_rooms {
|
||||||
let y_offset = total_height - (y * (self.room_height + 1)) - self.room_height - 2;
|
for x in 0..self.width_in_rooms {
|
||||||
let room = MRect::new_i32(
|
let x_offset = x * (self.room_width + 1);
|
||||||
x_offset as i32 + 1,
|
let y_offset =
|
||||||
y_offset as i32 + 1,
|
total_height - (y * (self.room_height + 1)) - self.room_height - 2;
|
||||||
self.room_width as i32,
|
let room = MRect::new_i32(
|
||||||
self.room_height as i32,
|
x_offset as i32 + 1,
|
||||||
);
|
y_offset as i32 + 1,
|
||||||
map.add_room(room);
|
self.room_width as i32,
|
||||||
let coords = maze_generator::prelude::Coordinates::new(x as i32, y as i32);
|
self.room_height as i32,
|
||||||
if let Some(field) = maze.get_field(&coords) {
|
);
|
||||||
use maze_generator::prelude::Direction::*;
|
map.add_room(room);
|
||||||
if field.has_passage(&North) {
|
let coords = maze_generator::prelude::Coordinates::new(x as i32, y as i32);
|
||||||
let x = x_offset + half_width;
|
if let Some(field) = maze.get_field(&coords) {
|
||||||
let y = y_offset + self.room_height;
|
use maze_generator::prelude::Direction::*;
|
||||||
map.set_tile(x as usize, y as usize, Tile::floor());
|
if field.has_passage(&North) {
|
||||||
}
|
let x = x_offset + half_width;
|
||||||
if field.has_passage(&South) {
|
let y = y_offset + self.room_height;
|
||||||
let x = x_offset + half_width;
|
map.set_tile(x as usize, y as usize, Tile::floor());
|
||||||
let y = y_offset;
|
}
|
||||||
map.set_tile(x as usize, y as usize, Tile::floor());
|
if field.has_passage(&South) {
|
||||||
}
|
let x = x_offset + half_width;
|
||||||
if field.has_passage(&East) {
|
let y = y_offset;
|
||||||
let x = x_offset + self.room_width;
|
map.set_tile(x as usize, y as usize, Tile::floor());
|
||||||
let y = y_offset + half_height;
|
}
|
||||||
map.set_tile(x as usize, y as usize, Tile::floor());
|
if field.has_passage(&East) {
|
||||||
}
|
let x = x_offset + self.room_width;
|
||||||
if field.has_passage(&West) {
|
let y = y_offset + half_height;
|
||||||
let x = x_offset;
|
map.set_tile(x as usize, y as usize, Tile::floor());
|
||||||
let y = y_offset + half_height;
|
}
|
||||||
map.set_tile(x as usize, y as usize, Tile::floor());
|
if field.has_passage(&West) {
|
||||||
|
let x = x_offset;
|
||||||
|
let y = y_offset + half_height;
|
||||||
|
map.set_tile(x as usize, y as usize, Tile::floor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
map.starting_point = Some(here_be_dragons::geometry::Point::new(
|
||||||
|
maze.start.x as usize + 1,
|
||||||
|
maze.start.y as usize + 1,
|
||||||
|
));
|
||||||
|
map.exit_point = Some(here_be_dragons::geometry::Point::new(
|
||||||
|
(maze.goal.x as usize) * self.room_width + half_width,
|
||||||
|
(maze.goal.y as usize) * self.room_height + half_height,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
map.starting_point = Some(here_be_dragons::geometry::Point::new(
|
|
||||||
maze.start.x as usize + 1,
|
|
||||||
maze.start.y as usize + 1,
|
|
||||||
));
|
|
||||||
map.exit_point = Some(here_be_dragons::geometry::Point::new(
|
|
||||||
(maze.goal.x as usize) * self.room_width + half_width,
|
|
||||||
(maze.goal.y as usize) * self.room_height + half_height,
|
|
||||||
));
|
|
||||||
map
|
map
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user