Variable town sizes

This commit is contained in:
Joshua Barretto 2023-04-13 12:05:16 +01:00
parent 2a1ea63910
commit d8702f128b
2 changed files with 15 additions and 8 deletions

View File

@ -359,11 +359,15 @@ impl Civs {
SiteKind::Castle => { SiteKind::Castle => {
WorldSite::castle(Castle::generate(wpos, Some(ctx.sim), &mut rng)) WorldSite::castle(Castle::generate(wpos, Some(ctx.sim), &mut rng))
}, },
SiteKind::Refactor => WorldSite::refactor(site2::Site::generate_city( SiteKind::Refactor => {
let size = Lerp::lerp(0.03, 1.0, rng.gen_range(0.0..1f32).powi(5));
WorldSite::refactor(site2::Site::generate_city(
&Land::from_sim(ctx.sim), &Land::from_sim(ctx.sim),
&mut rng, &mut rng,
wpos, wpos,
)), size,
))
},
SiteKind::CliffTown => WorldSite::cliff_town(site2::Site::generate_cliff_town( SiteKind::CliffTown => WorldSite::cliff_town(site2::Site::generate_cliff_town(
&Land::from_sim(ctx.sim), &Land::from_sim(ctx.sim),
&mut rng, &mut rng,

View File

@ -493,7 +493,8 @@ impl Site {
site site
} }
pub fn generate_city(land: &Land, rng: &mut impl Rng, origin: Vec2<i32>) -> Self { // Size is 0..1
pub fn generate_city(land: &Land, rng: &mut impl Rng, origin: Vec2<i32>, size: f32) -> Self {
let mut rng = reseed(rng); let mut rng = reseed(rng);
let mut site = Site { let mut site = Site {
@ -510,7 +511,7 @@ impl Site {
let mut castles = 0; let mut castles = 0;
for _ in 0..120 { for _ in 0..(size * 200.0) as i32 {
match *build_chance.choose_seeded(rng.gen()) { match *build_chance.choose_seeded(rng.gen()) {
// House // House
1 => { 1 => {
@ -1417,7 +1418,9 @@ impl Site {
} }
} }
pub fn test_site() -> Site { Site::generate_city(&Land::empty(), &mut thread_rng(), Vec2::zero()) } pub fn test_site() -> Site {
Site::generate_city(&Land::empty(), &mut thread_rng(), Vec2::zero(), 0.5)
}
fn wpos_is_hazard(land: &Land, wpos: Vec2<i32>) -> Option<HazardKind> { fn wpos_is_hazard(land: &Land, wpos: Vec2<i32>) -> Option<HazardKind> {
if land if land