- add size threshold for biomes to name, to exclude mini-biomes from clogging the map.

- fmt, clippy
This commit is contained in:
floppy 2022-01-17 11:19:34 +01:00
parent 18c434c613
commit ced1a82824
2 changed files with 39 additions and 27 deletions

View File

@ -523,27 +523,37 @@ impl Civs {
.iter() .iter()
.min_by_key(|&b| center.distance_squared(uniform_idx_as_vec2(map_size_lg, *b))) .min_by_key(|&b| center.distance_squared(uniform_idx_as_vec2(map_size_lg, *b)))
.unwrap(); .unwrap();
let name = match biome.0 { if biome.1.len() as u32 > 750 {
common::terrain::BiomeKind::Forest => format!("{}\n{:?}", NameGen::location(&mut ctx.rng).generate_forest(), biome.0), let name = match biome.0 {
common::terrain::BiomeKind::Grassland common::terrain::BiomeKind::Forest => format!(
|common::terrain::BiomeKind::Lake "{}\n{:?}",
| common::terrain::BiomeKind::Ocean NameGen::location(&mut ctx.rng).generate_forest(),
| common::terrain::BiomeKind::Mountain biome.0
| common::terrain::BiomeKind::Snowland ),
| common::terrain::BiomeKind::Desert common::terrain::BiomeKind::Grassland
| common::terrain::BiomeKind::Swamp | common::terrain::BiomeKind::Lake
| common::terrain::BiomeKind::Jungle | common::terrain::BiomeKind::Ocean
| common::terrain::BiomeKind::Savannah | common::terrain::BiomeKind::Mountain
| common::terrain::BiomeKind::Taiga => format!("{}\n{:?}", NameGen::location(&mut ctx.rng).generate_biome(), biome.0), | common::terrain::BiomeKind::Snowland
_ => String::new() | common::terrain::BiomeKind::Desert
}; | common::terrain::BiomeKind::Swamp
let id = self.pois.insert(PointOfInterest { | common::terrain::BiomeKind::Jungle
name, | common::terrain::BiomeKind::Savannah
loc: uniform_idx_as_vec2(map_size_lg, idx), | common::terrain::BiomeKind::Taiga => format!(
kind: PoiKind::Biome(biome.1.len() as u32), "{}\n{:?}",
}); NameGen::location(&mut ctx.rng).generate_biome(),
for chunk in biome.1 { biome.0
ctx.sim.chunks[chunk].poi = Some(id); ),
_ => String::new(),
};
let id = self.pois.insert(PointOfInterest {
name,
loc: uniform_idx_as_vec2(map_size_lg, idx),
kind: PoiKind::Biome(biome.1.len() as u32),
});
for chunk in biome.1 {
ctx.sim.chunks[chunk].poi = Some(id);
}
} }
} }

View File

@ -89,15 +89,17 @@ impl<'a, R: Rng> NameGen<'a, R> {
pub fn generate_forest(self) -> String { pub fn generate_forest(self) -> String {
let cons = vec![ let cons = vec![
"green", "moss", "ever", "briar", "thorn", "oak", "deep", "moon", "star", "sun", "bright", "glare", "green", "moss", "ever", "briar", "thorn", "oak", "deep", "moon", "star", "sun",
"fair", "calm", "mistral", "whisper", "clover", "hollow", "spring", "morrow", "dim", "dusk", "dawn", "night", "bright", "glare", "fair", "calm", "mistral", "whisper", "clover", "hollow", "spring",
"shimmer", "silver", "gold", "whisper", "fern", "quiet", "still", "gleam", "wild", "blind", "swift", "morrow", "dim", "dusk", "dawn", "night", "shimmer", "silver", "gold", "whisper",
"fern", "quiet", "still", "gleam", "wild", "blind", "swift",
]; ];
let start = cons.clone(); let start = cons.clone();
let end = vec![ let end = vec![
"root", "bark", "log", "brook", "well", "shire", "leaf", "more", "bole", "heart", "song", "dew", "root", "bark", "log", "brook", "well", "shire", "leaf", "more", "bole", "heart",
"bough", "path", "wind", "breeze", "light", "branch", "bloom", "vale", "glen", "rest", "shade", "song", "dew", "bough", "path", "wind", "breeze", "light", "branch", "bloom", "vale",
"fall", "sward", "thicket", "shrub", "bush", "grasp", "grip", "gale", "crawl", "run", "shadow", "glen", "rest", "shade", "fall", "sward", "thicket", "shrub", "bush", "grasp", "grip",
"gale", "crawl", "run", "shadow",
]; ];
let mut name = String::new(); let mut name = String::new();
name += start.choose(self.rng).unwrap(); name += start.choose(self.rng).unwrap();