|
|
|
@ -106,6 +106,19 @@ void WorldBuilder::tunnel_doors(PointList &holes, Room &src, Room &target) { |
|
|
|
|
$map.clear_target(target.entry); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WorldBuilder::stylize_room(int room, string tile_name, float size) { |
|
|
|
|
Point center = $map.place_entity(room); |
|
|
|
|
|
|
|
|
|
for(matrix::circle it{$map.$walls, center, size}; it.next();) { |
|
|
|
|
for(int x = it.left; x < it.right; x++) { |
|
|
|
|
if(!$map.iswall(x, it.y)) { |
|
|
|
|
$map.$tiles.set_tile(x, it.y, tile_name); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WorldBuilder::generate() { |
|
|
|
|
PointList holes; |
|
|
|
|
Room root{ |
|
|
|
@ -140,15 +153,10 @@ void WorldBuilder::generate() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$map.load_tiles(); |
|
|
|
|
|
|
|
|
|
Point center = $map.place_entity(1); |
|
|
|
|
for(matrix::circle it{$map.$walls, center, 3}; it.next();) { |
|
|
|
|
for(int x = it.left; x < it.right; x++) { |
|
|
|
|
if(!$map.iswall(x, it.y)) { |
|
|
|
|
$map.$tiles.set_tile(x, it.y, "WATER_TILE"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
stylize_room(3, "WATER_TILE", 2.5); |
|
|
|
|
stylize_room(2, "SAND_TILE", 4.5); |
|
|
|
|
stylize_room(4, "MOSAIC_TILE_2", 7.0); |
|
|
|
|
stylize_room(1, "GRASS_TILE", 3.4); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WorldBuilder::make_room(size_t origin_x, size_t origin_y, size_t w, size_t h) { |
|
|
|
@ -176,20 +184,14 @@ void WorldBuilder::place_rooms() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool WorldBuilder::dig_tunnel(PointList &holes, Point &src, Point &target) { |
|
|
|
|
Matrix &paths = $map.paths(); |
|
|
|
|
|
|
|
|
|
dbc::check(paths[src.y][src.x] != WALL_PATH_LIMIT, |
|
|
|
|
"source room has path as a wall"); |
|
|
|
|
dbc::check(paths[target.y][target.x] != WALL_PATH_LIMIT, |
|
|
|
|
"target room has path as a wall"); |
|
|
|
|
|
|
|
|
|
inline bool random_path(Map &map, PointList &holes, Point src, Point target) { |
|
|
|
|
bool found = false; |
|
|
|
|
Matrix &paths = map.paths(); |
|
|
|
|
Point out{src.x, src.y}; |
|
|
|
|
int count = 0; |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
found = $map.neighbors(out, true); |
|
|
|
|
found = map.neighbors(out, true); |
|
|
|
|
holes.push_back(out); |
|
|
|
|
|
|
|
|
|
if(paths[out.y][out.x] == 0) { |
|
|
|
@ -197,5 +199,27 @@ bool WorldBuilder::dig_tunnel(PointList &holes, Point &src, Point &target) { |
|
|
|
|
} |
|
|
|
|
} while(found && ++count < WORLDBUILD_MAX_PATH); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
return found; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline void straight_path(PointList &holes, Point src, Point target) { |
|
|
|
|
for(matrix::line dig{src, target}; dig.next();) { |
|
|
|
|
holes.push_back({size_t(dig.x), size_t(dig.y)}); |
|
|
|
|
holes.push_back({size_t(dig.x+1), size_t(dig.y)}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool WorldBuilder::dig_tunnel(PointList &holes, Point &src, Point &target) { |
|
|
|
|
Matrix &paths = $map.paths(); |
|
|
|
|
|
|
|
|
|
dbc::check(paths[src.y][src.x] != WALL_PATH_LIMIT, |
|
|
|
|
"source room has path as a wall"); |
|
|
|
|
dbc::check(paths[target.y][target.x] != WALL_PATH_LIMIT, |
|
|
|
|
"target room has path as a wall"); |
|
|
|
|
|
|
|
|
|
if(!random_path($map, holes, src, target)) { |
|
|
|
|
straight_path(holes, src, target); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|