overmap travel - needs refactoring urgently, but it works for now

This commit is contained in:
Llywelwyn 2023-08-27 03:00:48 +01:00
parent 00dea1a55e
commit e1eae7efaf
15 changed files with 150 additions and 110 deletions

View file

@ -36,6 +36,7 @@ use common::*;
use specs::prelude::*;
use voronoi_spawning::VoronoiSpawning;
use super::config::CONFIG;
use super::data::ids::*;
//use wfc::WaveFunctionCollapseBuilder;
mod room_exploder;
use room_exploder::RoomExploder;
@ -318,7 +319,7 @@ fn random_shape_builder(rng: &mut rltk::RandomNumberGenerator, builder: &mut Bui
}
fn overmap_builder() -> BuilderChain {
let mut builder = BuilderChain::new(true, 1, 69, 41, 0, "the world", 1);
let mut builder = BuilderChain::new(true, ID_OVERMAP, 69, 41, 0, "the world", 1);
builder.start_with(PrefabBuilder::overmap());
return builder;
}
@ -385,9 +386,9 @@ pub fn level_builder(
// TODO: With difficulty and ID/depth decoupled, this can be used for branches later.
let difficulty = new_id;
match new_id {
1 => overmap_builder(),
2 => town_builder(new_id, rng, width, height, 0, initial_player_level),
3 => forest_builder(new_id, rng, width, height, 1, initial_player_level),
ID_OVERMAP => overmap_builder(),
ID_TOWN => town_builder(new_id, rng, width, height, 0, initial_player_level),
ID_TOWN2 => forest_builder(new_id, rng, width, height, 1, initial_player_level),
_ => random_builder(new_id, rng, width, height, difficulty, initial_player_level),
}
}

View file

@ -177,6 +177,9 @@ impl PrefabBuilder {
'^' => {
build_data.map.tiles[idx] = TileType::ImpassableMountain;
}
'1' => {
build_data.map.tiles[idx] = TileType::ToTown;
}
_ => {
rltk::console::log(format!("Unknown glyph '{}' when loading overmap", ch as u8 as char));
}

View file

@ -1,41 +0,0 @@
~~~~~~~~~.................~~~.......~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~...........................~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~............................~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~....~..........................~~~~~~~~~~~~~.....~~~~~~~
~~~....~...........................~..~~~~~~~~~~......~~~~~~
~~~.................~.................~~~~~~~~~........~...~
~~~.................~.......................................
~~~~........................................................
~~~~~~......................................................
~~~~~~..................................~...................
~~~~~........~~.........................~...................
~~~~~......~~~.~............................................
~~~~.......~~..~...........................................~
~~~........~...............................................~
~~~~......~...............................................~~
~~~~~......................................................~
~~~~~...~................~..................................
~~~~~~~~~~~............~~~..................................
~~~~~~~~~~...........~..~...................................
~~~~~~~~~~~............~....................................
~~~~~~~~~..............~....................................
~~~~~~~~.............~~...................................~~
~~~~~~~..............~.....................................~
~~~~~......................................................~
~~~~~.................~~...................................~
~~~~..................~.~~~.................................
~~~~..............~.......~.................................
~.................~~..................~~....................
~...............~..~..................~~~...................
..~......~~~~~~~~.....~~~.............~~....................
..~~.....~~~~~~~~~~...~~~...................................
..~~~~~~~~~~~~~~~~..~~~~~~..................................
....~~~~~~~~~~~~...~~~~~~~..............~~~~................
........~~~~~~~~..........~.~....~......~......~.......~....
~...~...~~~~~~~~...........................................~
...~~.......~~~~............................................
...............~............................................
.................................~..........................
~~...............................~~.....~...................
~~~..............................~~.........................
~~~......................................~~~.~~~~...........

View file

@ -93,7 +93,7 @@ const OVERMAP_TEMPLATE: &str =
^^^^^^^.............................
^^^^^^^^........@..................
^^^^^^^^............................
^^^^^^^^^.............>.................
^^^^^^^^^.............1.................
^^^^^^^^^.......................
^^^^^^^^^^................
^^^^^^^^^^.............

View file

@ -61,6 +61,11 @@ impl TownBuilder {
self.spawn_dockers(build_data, rng);
self.spawn_townsfolk(build_data, rng, &mut available_building_tiles);
build_data.starting_position = Some(Position {
x: build_data.width - 2,
y: wall_gap_y,
});
build_data.take_snapshot();
}
@ -186,11 +191,6 @@ impl TownBuilder {
build_data: &mut BuilderMap,
rng: &mut rltk::RandomNumberGenerator
) {
// Place player
build_data.starting_position = Some(Position {
x: building.0 + building.2 / 2,
y: building.1 + building.3 / 2,
});
let player_idx = build_data.map.xy_idx(building.0 + building.2 / 2, building.1 + building.3 / 2);
// Place other items