Added shrub density within specific regions

This commit is contained in:
DemonicOnPc 2021-10-25 16:20:49 -04:00
parent b1476071b1
commit 8f26c451ae
3 changed files with 38 additions and 17 deletions

View File

@ -3,26 +3,26 @@
[
(
specifier: "world.shrub.taiga.bush-0",
center: (4, 4, 3),
center: (4, 4, 2),
),
(
specifier: "world.shrub.taiga.bush-1",
center: (4, 4, 3),
center: (4, 4, 2),
),
(
specifier: "world.shrub.taiga.bush-2",
center: (4, 4, 3),
center: (4, 4, 2),
),
(
specifier: "world.shrub.taiga.bush-3",
center: (4, 4, 2),
center: (4, 4, 1),
),
(
specifier: "world.shrub.taiga.bush-4",
center: (3, 3, 2),
center: (3, 3, 1),
),
(
specifier: "world.shrub.taiga.bush-5",
center: (4, 4, 2),
center: (4, 4, 1),
),
]

View File

@ -82,6 +82,22 @@ impl ForestKind {
}
}
pub fn shrub_density_factor(&self) -> f32 {
match self {
ForestKind::Palm => 0.2,
ForestKind::Acacia => 0.3,
ForestKind::Baobab => 0.2,
ForestKind::Oak => 0.4,
ForestKind::Chestnut => 0.3,
ForestKind::Cedar => 0.3,
ForestKind::Pine => 0.4,
ForestKind::Birch => 0.65,
ForestKind::Mangrove => 1.0,
ForestKind::Swamp => 0.4,
_ => 0.0,
}
}
pub fn proclivity(&self, env: &Environment) -> f32 {
self.ideal_proclivity()
* close(env.humid, self.humid_range())

View File

@ -48,21 +48,26 @@ pub fn apply_shrubs_to(canvas: &mut Canvas, _dynamic_rng: &mut impl Rng) {
&& col.spawn_rate > 0.9
&& col.path.map_or(true, |(d, _, _, _)| d > 6.0)
{
Some(Shrub {
wpos: wpos.with_z(col.alt as i32),
seed,
kind: *info
.chunks()
.make_forest_lottery(wpos)
.choose_seeded(seed)
.as_ref()?,
let kind = *info
.chunks()
.make_forest_lottery(wpos)
.choose_seeded(seed)
.as_ref()?;
if rng.gen_bool(kind.shrub_density_factor() as f64) {
Some(Shrub {
wpos: wpos.with_z(col.alt as i32),
seed,
kind,
})
} else {
None
}
});
}
});
} else {
None
}
});
}
});
for shrub in shrub_cache.values().filter_map(|s| s.as_ref()) {
let mut rng = ChaChaRng::from_seed(seed_expan::rng_state(shrub.seed));