map shortnames/identifiers
This commit is contained in:
parent
849a554055
commit
9fb791039f
12 changed files with 80 additions and 26 deletions
|
|
@ -22,6 +22,7 @@ pub fn get_local_desc(id: i32) -> String {
|
|||
pub fn get_local_col(id: i32) -> RGB {
|
||||
let col = match id {
|
||||
ID_TOWN => TO_TOWN_COLOUR,
|
||||
ID_TOWN2 => GRASS_COLOUR,
|
||||
ID_OVERMAP => TO_OVERMAP_COLOUR,
|
||||
_ => (255, 255, 255),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
pub const NAME_OVERMAP: &str = "WORLD MAP";
|
||||
pub const NAME_OVERMAP: &str = "the travel map";
|
||||
pub const SHORTNAME_OVERMAP: &str = "Travel";
|
||||
pub const NAME_DUNGEON_RANDOM: &str = "the dungeon";
|
||||
pub const NAME_STARTER_TOWN: &str = "TOWN NAME";
|
||||
pub const SHORTNAME_DUNGEON_RANDOM: &str = "D";
|
||||
pub const NAME_STARTER_TOWN: &str = "the town of Saff";
|
||||
pub const SHORTNAME_STARTER_TOWN: &str = "Saff";
|
||||
pub const NAME_FOREST_BUILDER: &str = "the woods outside of town";
|
||||
pub const SHORTNAME_FOREST_BUILDER: &str = "Woods";
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ pub enum FarlookResult {
|
|||
|
||||
pub fn show_farlook(gs: &mut State, ctx: &mut Rltk) -> FarlookResult {
|
||||
let runstate = gs.ecs.fetch::<RunState>();
|
||||
let (min_x, _max_x, min_y, _max_y, x_offset, y_offset) = get_screen_bounds(&gs.ecs, ctx);
|
||||
let (_min_x, _max_x, _min_y, _max_y, x_offset, y_offset) = get_screen_bounds(&gs.ecs, ctx);
|
||||
|
||||
ctx.print_color(
|
||||
1 + x_offset,
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ use super::{
|
|||
State,
|
||||
Viewshed,
|
||||
BUC,
|
||||
get_local_col,
|
||||
};
|
||||
use crate::data::entity::CARRY_CAPACITY_PER_STRENGTH;
|
||||
use rltk::prelude::*;
|
||||
|
|
@ -323,17 +324,12 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||
|
||||
// Render id
|
||||
let map = ecs.fetch::<Map>();
|
||||
let id = format!("D{}", map.id);
|
||||
ctx.print_color_right(70, 54, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), &id);
|
||||
let id = if map.depth > 0 { format!("{}{}", map.short_name, map.depth) } else { format!("{}", map.short_name) };
|
||||
ctx.print_color_right(70, 54, get_local_col(map.id), RGB::named(rltk::BLACK), &id);
|
||||
|
||||
// Render turn
|
||||
ctx.print_color_right(
|
||||
64,
|
||||
54,
|
||||
RGB::named(rltk::YELLOW),
|
||||
RGB::named(rltk::BLACK),
|
||||
&format!("T{}", crate::gamelog::get_event_count(EVENT::COUNT_TURN))
|
||||
);
|
||||
let turns = crate::gamelog::get_event_count(EVENT::COUNT_TURN);
|
||||
ctx.print_color_right(69 - id.len(), 54, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), &format!("T{}", turns));
|
||||
|
||||
// Boxes and tooltips last, so they draw over everything else.
|
||||
ctx.draw_hollow_box(0, 0, 70, 8, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK)); // Log box
|
||||
|
|
|
|||
|
|
@ -743,7 +743,7 @@ fn main() -> rltk::BError {
|
|||
// Insert calls
|
||||
gs.ecs.insert(rltk::RandomNumberGenerator::new());
|
||||
gs.ecs.insert(map::MasterDungeonMap::new()); // Master map list
|
||||
gs.ecs.insert(Map::new(true, 1, 64, 64, 0, "New Map")); // Map
|
||||
gs.ecs.insert(Map::new(true, 1, 64, 64, 0, "New Map", "N", 0)); // Map
|
||||
gs.ecs.insert(Point::new(0, 0)); // Player pos
|
||||
gs.ecs.insert(gui::Ancestry::Dwarf); // ancestry
|
||||
let player_entity = spawner::player(&mut gs.ecs, 0, 0);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ pub struct Map {
|
|||
pub additional_fg_offset: rltk::RGB,
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub short_name: String,
|
||||
pub depth: i32,
|
||||
pub difficulty: i32,
|
||||
pub bloodstains: HashSet<usize>,
|
||||
pub view_blocked: HashSet<usize>,
|
||||
|
|
@ -38,7 +40,16 @@ impl Map {
|
|||
(y as usize) * (self.width as usize) + (x as usize)
|
||||
}
|
||||
|
||||
pub fn new<S: ToString>(overmap: bool, new_id: i32, width: i32, height: i32, difficulty: i32, name: S) -> Map {
|
||||
pub fn new<S: ToString>(
|
||||
overmap: bool,
|
||||
new_id: i32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
difficulty: i32,
|
||||
name: S,
|
||||
short_name: S,
|
||||
depth: i32
|
||||
) -> Map {
|
||||
let map_tile_count = (width * height) as usize;
|
||||
crate::spatial::set_size(map_tile_count);
|
||||
let mut map = Map {
|
||||
|
|
@ -58,6 +69,8 @@ impl Map {
|
|||
),
|
||||
id: new_id,
|
||||
name: name.to_string(),
|
||||
short_name: short_name.to_string(),
|
||||
depth: depth,
|
||||
difficulty: difficulty,
|
||||
bloodstains: HashSet::new(),
|
||||
view_blocked: HashSet::new(),
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ pub fn tile_opaque(tt: TileType) -> bool {
|
|||
}
|
||||
pub fn tile_cost(tt: TileType) -> f32 {
|
||||
match tt {
|
||||
TileType::Road => 0.5,
|
||||
TileType::Grass => 1.1,
|
||||
TileType::ShallowWater => 1.3,
|
||||
TileType::Road => 0.75,
|
||||
TileType::Grass => 1.2,
|
||||
TileType::ShallowWater => 1.5,
|
||||
_ => 1.0,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ pub fn forest_builder(
|
|||
height,
|
||||
difficulty,
|
||||
NAME_FOREST_BUILDER,
|
||||
SHORTNAME_FOREST_BUILDER,
|
||||
0,
|
||||
initial_player_level
|
||||
);
|
||||
chain.start_with(CellularAutomataBuilder::floor(TileType::Grass));
|
||||
|
|
|
|||
|
|
@ -107,6 +107,8 @@ impl BuilderChain {
|
|||
height: i32,
|
||||
difficulty: i32,
|
||||
name: S,
|
||||
short_name: S,
|
||||
depth: i32,
|
||||
initial_player_level: i32
|
||||
) -> BuilderChain {
|
||||
BuilderChain {
|
||||
|
|
@ -114,7 +116,7 @@ impl BuilderChain {
|
|||
builders: Vec::new(),
|
||||
build_data: BuilderMap {
|
||||
spawn_list: Vec::new(),
|
||||
map: Map::new(overmap, new_id, width, height, difficulty, name),
|
||||
map: Map::new(overmap, new_id, width, height, difficulty, name, short_name, depth),
|
||||
starting_position: None,
|
||||
rooms: None,
|
||||
corridors: None,
|
||||
|
|
@ -326,7 +328,7 @@ fn random_shape_builder(rng: &mut rltk::RandomNumberGenerator, builder: &mut Bui
|
|||
}
|
||||
|
||||
fn overmap_builder() -> BuilderChain {
|
||||
let mut builder = BuilderChain::new(true, ID_OVERMAP, 69, 41, 0, NAME_OVERMAP, 1);
|
||||
let mut builder = BuilderChain::new(true, ID_OVERMAP, 69, 41, 0, NAME_OVERMAP, SHORTNAME_OVERMAP, 0, 1);
|
||||
builder.start_with(PrefabBuilder::overmap());
|
||||
builder.with(Foliage::percent(TileType::Grass, 30));
|
||||
return builder;
|
||||
|
|
@ -344,6 +346,7 @@ pub fn random_builder(
|
|||
width: i32,
|
||||
height: i32,
|
||||
difficulty: i32,
|
||||
depth: i32,
|
||||
initial_player_level: i32,
|
||||
end: bool,
|
||||
build_type: BuildType
|
||||
|
|
@ -356,6 +359,8 @@ pub fn random_builder(
|
|||
height,
|
||||
difficulty,
|
||||
NAME_DUNGEON_RANDOM,
|
||||
SHORTNAME_DUNGEON_RANDOM,
|
||||
depth,
|
||||
initial_player_level
|
||||
);
|
||||
let mut want_doors = true;
|
||||
|
|
@ -421,8 +426,19 @@ pub fn level_builder(
|
|||
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),
|
||||
ID_TOWN3 => random_builder(new_id, rng, width, height, 2, initial_player_level, true, BuildType::Room),
|
||||
ID_INFINITE => random_builder(new_id, rng, width, height, 3, initial_player_level, false, BuildType::Room),
|
||||
_ => random_builder(new_id, rng, width, height, difficulty, initial_player_level, false, BuildType::Any),
|
||||
ID_TOWN3 => random_builder(new_id, rng, width, height, 2, 1, initial_player_level, true, BuildType::Room),
|
||||
_ if new_id >= ID_INFINITE =>
|
||||
random_builder(
|
||||
new_id,
|
||||
rng,
|
||||
width,
|
||||
height,
|
||||
difficulty,
|
||||
new_id - ID_INFINITE + 1,
|
||||
initial_player_level,
|
||||
false,
|
||||
BuildType::Room
|
||||
),
|
||||
_ => random_builder(new_id, rng, width, height, difficulty, 404, initial_player_level, false, BuildType::Room),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ const OVERMAP_TEMPLATE: &str =
|
|||
^^^^^^^........................≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈.....≈
|
||||
^^^^^^^^........@..............≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈....≈
|
||||
^^^^^^^^..................≈...≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈...≈≈≈...≈≈≈≈≈≈≈≈.≈≈
|
||||
^^^^^^^^^.............1...≈≈....≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈....≈≈......≈≈≈≈≈≈≈≈≈
|
||||
^^^^^^^^^.................≈≈1...≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈....≈≈......≈≈≈≈≈≈≈≈≈
|
||||
^^^^^^^^^........≈≈≈≈...≈≈≈≈....≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈..≈≈≈......≈≈≈≈≈≈≈≈≈
|
||||
^^^^^^^^^^......≈≈≈≈≈≈≈≈≈≈≈≈≈..≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈........≈≈≈≈≈≈≈≈
|
||||
^^^^^^^^^^.....≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈........≈≈≈≈≈≈≈≈≈
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ pub fn town_builder(
|
|||
height,
|
||||
difficulty,
|
||||
NAME_STARTER_TOWN,
|
||||
SHORTNAME_STARTER_TOWN,
|
||||
0,
|
||||
initial_player_level
|
||||
);
|
||||
chain.start_with(TownBuilder::new());
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@ impl WaveFunctionCollapseBuilder {
|
|||
build_data.map.width,
|
||||
build_data.map.height,
|
||||
build_data.map.difficulty,
|
||||
&build_data.map.name
|
||||
&build_data.map.name,
|
||||
&build_data.map.short_name,
|
||||
build_data.map.depth
|
||||
);
|
||||
loop {
|
||||
let mut solver = Solver::new(constraints.clone(), CHUNK_SIZE, &build_data.map);
|
||||
|
|
@ -53,7 +55,16 @@ impl WaveFunctionCollapseBuilder {
|
|||
}
|
||||
|
||||
fn render_tile_gallery(&mut self, constraints: &[MapChunk], chunk_size: i32, build_data: &mut BuilderMap) {
|
||||
build_data.map = Map::new(false, 0, build_data.width, build_data.height, 0, &build_data.map.name);
|
||||
build_data.map = Map::new(
|
||||
false,
|
||||
0,
|
||||
build_data.width,
|
||||
build_data.height,
|
||||
0,
|
||||
&build_data.map.name,
|
||||
&build_data.map.short_name,
|
||||
build_data.map.depth
|
||||
);
|
||||
let mut counter = 0;
|
||||
let mut x = 1;
|
||||
let mut y = 1;
|
||||
|
|
@ -69,7 +80,16 @@ impl WaveFunctionCollapseBuilder {
|
|||
if y + chunk_size > build_data.map.height {
|
||||
// Move to the next page
|
||||
build_data.take_snapshot();
|
||||
build_data.map = Map::new(false, 0, build_data.width, build_data.height, 0, &build_data.map.name);
|
||||
build_data.map = Map::new(
|
||||
false,
|
||||
0,
|
||||
build_data.width,
|
||||
build_data.height,
|
||||
0,
|
||||
&build_data.map.name,
|
||||
&build_data.map.short_name,
|
||||
build_data.map.depth
|
||||
);
|
||||
|
||||
x = 1;
|
||||
y = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue