1use core::hash::BuildHasherDefault;
2use fxhash::FxHasher64;
3use hashbrown::HashSet;
4use rand::{Rng, seq::SliceRandom};
5use vek::*;
6
7#[derive(Clone, Debug)]
8pub struct Location {
9 pub(crate) name: String,
10 pub(crate) center: Vec2<i32>,
11 pub(crate) kingdom: Option<Kingdom>,
12 pub(crate) neighbours: HashSet<u64, BuildHasherDefault<FxHasher64>>,
17}
18
19impl Location {
20 pub fn generate(center: Vec2<i32>, rng: &mut impl Rng) -> Self {
21 Self {
22 name: generate_name(rng),
23 center,
24 kingdom: None,
25 neighbours: HashSet::default(),
26 }
27 }
28
29 pub fn name(&self) -> &str { &self.name }
30
31 pub fn kingdom(&self) -> Option<&Kingdom> { self.kingdom.as_ref() }
32}
33
34#[derive(Clone, Debug)]
35pub struct Kingdom {
36 #[expect(dead_code)]
37 region_name: String,
38}
39
40fn generate_name(rng: &mut impl Rng) -> String {
41 let firstsyl = [
42 "Eri", "Val", "Gla", "Wilde", "Cold", "Deep", "Dura", "Ester", "Fay", "Dark", "West",
43 "East", "North", "South", "Ray", "Eri", "Dal", "Som", "Sommer", "Black", "Iron", "Grey",
44 "Hel", "Gal", "Mor", "Lo", "Nil", "Bel", "Lor", "Gold", "Red", "Marble", "Mana", "Gar",
45 "Mountain", "Red", "Cheo", "Far", "High",
46 ];
47 let mid = ["ka", "se", "au", "da", "di"];
48 let tails = [
49 "ben", "sel", "dori", "theas", "dar", "bur", "to", "vis", "ten",
50 "stone", "tiva", "id", "and", "or", "el", "ond", "ia", "eld", "ald", "aft", "ift", "ity",
51 "well", "oll", "ill", "all", "wyn", "light", " Hill", "lin", "mont", "mor", "cliff", "rok",
52 "den", "mi", "rock", "glenn", "rovi", "lea", "gate", "view", "ley", "wood", "ovia",
53 "cliff", "marsh", "kor", "ice", "acre", "venn", "crest", "field",
54 "vale", "spring", " Vale", "grasp", "fel", "fall", "grove", "wyn", "edge",
55 ];
56
57 let mut name = String::new();
58 if rng.gen() {
59 name += firstsyl.choose(rng).unwrap();
60 name += mid.choose(rng).unwrap();
61 name += tails.choose(rng).unwrap();
62 name
63 } else {
64 name += firstsyl.choose(rng).unwrap();
65 name += tails.choose(rng).unwrap();
66 name
67 }
68}