Disabled warping in towns

This commit is contained in:
Joshua Barretto 2020-04-17 16:46:08 +01:00
parent 866fd1992e
commit 3042a09dfd
4 changed files with 11 additions and 7 deletions

View File

@ -66,13 +66,13 @@ impl Civs {
let mut ctx = GenCtx { sim, rng: &mut rng }; let mut ctx = GenCtx { sim, rng: &mut rng };
for _ in 0..INITIAL_CIV_COUNT { for _ in 0..INITIAL_CIV_COUNT {
println!("Creating civilisation..."); log::info!("Creating civilisation...");
if let None = this.birth_civ(&mut ctx) { if let None = this.birth_civ(&mut ctx) {
println!("Failed to find starting site for civilisation."); log::warn!("Failed to find starting site for civilisation.");
} }
} }
for _ in 0..256 { for _ in 0..100 {
attempt(5, || { attempt(5, || {
let loc = find_site_loc(&mut ctx, None)?; let loc = find_site_loc(&mut ctx, None)?;
this.establish_site(&mut ctx, loc, |place| Site { this.establish_site(&mut ctx, loc, |place| Site {
@ -136,6 +136,7 @@ impl Civs {
chunk.alt += diff; chunk.alt += diff;
chunk.basement += diff; chunk.basement += diff;
chunk.rockiness = 0.0; chunk.rockiness = 0.0;
chunk.warp_factor = 0.0;
}); });
} }
} }
@ -156,10 +157,10 @@ impl Civs {
.get_mut(pos) .get_mut(pos)
.map(|chunk| chunk.sites.push(world_site.clone())); .map(|chunk| chunk.sites.push(world_site.clone()));
} }
println!("Placed site at {:?}", site.center); log::info!("Placed site at {:?}", site.center);
} }
this.display_info(); //this.display_info();
this this
} }
@ -335,7 +336,6 @@ impl Civs {
} }
fn tick(&mut self, ctx: &mut GenCtx<impl Rng>, years: f32) { fn tick(&mut self, ctx: &mut GenCtx<impl Rng>, years: f32) {
println!("Tick!");
for site in self.sites.iter_mut() { for site in self.sites.iter_mut() {
site.simulate(years, &self.places.get(site.place).nat_res); site.simulate(years, &self.places.get(site.place).nat_res);
} }

View File

@ -233,6 +233,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
let tree_density = sim.get_interpolated(wpos, |chunk| chunk.tree_density)?; let tree_density = sim.get_interpolated(wpos, |chunk| chunk.tree_density)?;
let spawn_rate = sim.get_interpolated(wpos, |chunk| chunk.spawn_rate)?; let spawn_rate = sim.get_interpolated(wpos, |chunk| chunk.spawn_rate)?;
let alt = sim.get_interpolated_monotone(wpos, |chunk| chunk.alt)?; let alt = sim.get_interpolated_monotone(wpos, |chunk| chunk.alt)?;
let chunk_warp_factor = sim.get_interpolated_monotone(wpos, |chunk| chunk.warp_factor)?;
let sim_chunk = sim.get(chunk_pos)?; let sim_chunk = sim.get(chunk_pos)?;
let neighbor_coef = TerrainChunkSize::RECT_SIZE.map(|e| e as f64); let neighbor_coef = TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
let my_chunk_idx = vec2_as_uniform_idx(chunk_pos); let my_chunk_idx = vec2_as_uniform_idx(chunk_pos);
@ -831,6 +832,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
} else { } else {
(false, None, alt_for_river, downhill_water_alt, alt_for_river, 1.0) (false, None, alt_for_river, downhill_water_alt, alt_for_river, 1.0)
}; };
let warp_factor = warp_factor * chunk_warp_factor;
// NOTE: To disable warp, uncomment this line. // NOTE: To disable warp, uncomment this line.
// let warp_factor = 0.0; // let warp_factor = 0.0;

View File

@ -1789,6 +1789,7 @@ pub struct SimChunk {
pub forest_kind: ForestKind, pub forest_kind: ForestKind,
pub spawn_rate: f32, pub spawn_rate: f32,
pub river: RiverData, pub river: RiverData,
pub warp_factor: f32,
pub sites: Vec<Site>, pub sites: Vec<Site>,
pub place: Option<Id<Place>>, pub place: Option<Id<Place>>,
@ -2024,6 +2025,7 @@ impl SimChunk {
}, },
spawn_rate: 1.0, spawn_rate: 1.0,
river, river,
warp_factor: 1.0,
sites: Vec::new(), sites: Vec::new(),
place: None, place: None,

View File

@ -579,7 +579,7 @@ impl Settlement {
if let Some(color) = color { if let Some(color) = color {
if col_sample.water_dist.map(|dist| dist > 2.0).unwrap_or(true) { if col_sample.water_dist.map(|dist| dist > 2.0).unwrap_or(true) {
for z in -8..6 { for z in -8..3 {
let pos = Vec3::new(offs.x, offs.y, surface_z + z); let pos = Vec3::new(offs.x, offs.y, surface_z + z);
if let (0, Some(block)) = (z, surface_block) { if let (0, Some(block)) = (z, surface_block) {