mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Day period dependant wildlife spawns
This commit is contained in:
parent
fd177c9669
commit
bd84677906
@ -1,4 +1,4 @@
|
|||||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
pub enum DayPeriod {
|
pub enum DayPeriod {
|
||||||
Night,
|
Night,
|
||||||
Morning,
|
Morning,
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
use crate::metrics::ChunkGenMetrics;
|
use crate::metrics::ChunkGenMetrics;
|
||||||
#[cfg(not(feature = "worldgen"))]
|
#[cfg(not(feature = "worldgen"))]
|
||||||
use crate::test_world::{IndexOwned, World};
|
use crate::test_world::{IndexOwned, World};
|
||||||
use common::{generation::ChunkSupplement, slowjob::SlowJobPool, terrain::TerrainChunk};
|
use common::{
|
||||||
|
generation::ChunkSupplement, resources::TimeOfDay, slowjob::SlowJobPool, terrain::TerrainChunk,
|
||||||
|
};
|
||||||
use hashbrown::{hash_map::Entry, HashMap};
|
use hashbrown::{hash_map::Entry, HashMap};
|
||||||
use specs::Entity as EcsEntity;
|
use specs::Entity as EcsEntity;
|
||||||
use std::sync::{
|
use std::sync::{
|
||||||
@ -42,6 +44,7 @@ impl ChunkGenerator {
|
|||||||
slowjob_pool: &SlowJobPool,
|
slowjob_pool: &SlowJobPool,
|
||||||
world: Arc<World>,
|
world: Arc<World>,
|
||||||
index: IndexOwned,
|
index: IndexOwned,
|
||||||
|
time: TimeOfDay,
|
||||||
) {
|
) {
|
||||||
let v = if let Entry::Vacant(v) = self.pending_chunks.entry(key) {
|
let v = if let Entry::Vacant(v) = self.pending_chunks.entry(key) {
|
||||||
v
|
v
|
||||||
@ -55,7 +58,7 @@ impl ChunkGenerator {
|
|||||||
slowjob_pool.spawn("CHUNK_GENERATOR", move || {
|
slowjob_pool.spawn("CHUNK_GENERATOR", move || {
|
||||||
let index = index.as_index_ref();
|
let index = index.as_index_ref();
|
||||||
let payload = world
|
let payload = world
|
||||||
.generate_chunk(index, key, || cancel.load(Ordering::Relaxed))
|
.generate_chunk(index, key, || cancel.load(Ordering::Relaxed), Some(time))
|
||||||
.map_err(|_| entity);
|
.map_err(|_| entity);
|
||||||
let _ = chunk_tx.send((key, payload));
|
let _ = chunk_tx.send((key, payload));
|
||||||
});
|
});
|
||||||
|
@ -725,6 +725,7 @@ impl Server {
|
|||||||
&slow_jobs,
|
&slow_jobs,
|
||||||
Arc::clone(&world),
|
Arc::clone(&world),
|
||||||
index.clone(),
|
index.clone(),
|
||||||
|
*ecs.read_resource::<TimeOfDay>(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -930,6 +931,7 @@ impl Server {
|
|||||||
&slow_jobs,
|
&slow_jobs,
|
||||||
Arc::clone(&self.world),
|
Arc::clone(&self.world),
|
||||||
self.index.clone(),
|
self.index.clone(),
|
||||||
|
*ecs.read_resource::<TimeOfDay>(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ use common::{
|
|||||||
Group, Inventory,
|
Group, Inventory,
|
||||||
},
|
},
|
||||||
effect::Effect,
|
effect::Effect,
|
||||||
|
resources::TimeOfDay,
|
||||||
slowjob::SlowJobPool,
|
slowjob::SlowJobPool,
|
||||||
uid::{Uid, UidAllocator},
|
uid::{Uid, UidAllocator},
|
||||||
};
|
};
|
||||||
@ -382,7 +383,7 @@ impl StateExt for State {
|
|||||||
.for_each(|chunk_key| {
|
.for_each(|chunk_key| {
|
||||||
#[cfg(feature = "worldgen")]
|
#[cfg(feature = "worldgen")]
|
||||||
{
|
{
|
||||||
chunk_generator.generate_chunk(None, chunk_key, &slow_jobs, Arc::clone(world), index.clone());
|
chunk_generator.generate_chunk(None, chunk_key, &slow_jobs, Arc::clone(world), index.clone(), *ecs.read_resource::<TimeOfDay>());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,9 @@ use common::{
|
|||||||
quadruped_medium, quadruped_small, theropod, Alignment,
|
quadruped_medium, quadruped_small, theropod, Alignment,
|
||||||
},
|
},
|
||||||
generation::{ChunkSupplement, EntityInfo},
|
generation::{ChunkSupplement, EntityInfo},
|
||||||
|
resources::TimeOfDay,
|
||||||
terrain::Block,
|
terrain::Block,
|
||||||
|
time::DayPeriod::{self, Evening, Morning, Night, Noon},
|
||||||
vol::{BaseVol, ReadVol, RectSizedVol, WriteVol},
|
vol::{BaseVol, ReadVol, RectSizedVol, WriteVol},
|
||||||
};
|
};
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
@ -28,11 +30,13 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
_index: IndexRef,
|
_index: IndexRef,
|
||||||
chunk: &SimChunk,
|
chunk: &SimChunk,
|
||||||
supplement: &mut ChunkSupplement,
|
supplement: &mut ChunkSupplement,
|
||||||
|
time: Option<TimeOfDay>,
|
||||||
) {
|
) {
|
||||||
struct Entry<R> {
|
struct Entry<R> {
|
||||||
make_entity: fn(Vec3<f32>, &mut R) -> EntityInfo, // Entity
|
make_entity: fn(Vec3<f32>, &mut R) -> EntityInfo, // Entity
|
||||||
group_size: Range<usize>, // Group size range
|
group_size: Range<usize>, // Group size range
|
||||||
is_underwater: bool, // Underwater?
|
is_underwater: bool, // Underwater?
|
||||||
|
day_period: Vec<DayPeriod>, // Period of the day
|
||||||
get_density: fn(&SimChunk, &ColumnSample) -> f32, // Density
|
get_density: fn(&SimChunk, &ColumnSample) -> f32, // Density
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +64,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..4,
|
group_size: 1..4,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, col| {
|
get_density: |c, col| {
|
||||||
close(c.temp, CONFIG.snow_temp, 0.3)
|
close(c.temp, CONFIG.snow_temp, 0.3)
|
||||||
* BASE_DENSITY
|
* BASE_DENSITY
|
||||||
@ -91,6 +96,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, col| {
|
get_density: |c, col| {
|
||||||
close(c.temp, CONFIG.snow_temp, 0.3) * col.tree_density * BASE_DENSITY * 1.4
|
close(c.temp, CONFIG.snow_temp, 0.3) * col.tree_density * BASE_DENSITY * 1.4
|
||||||
},
|
},
|
||||||
@ -106,6 +112,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| close(c.temp, CONFIG.snow_temp, 0.15) * BASE_DENSITY * 0.5,
|
get_density: |c, _col| close(c.temp, CONFIG.snow_temp, 0.15) * BASE_DENSITY * 0.5,
|
||||||
},
|
},
|
||||||
// Tundra rarer solitary ennemies
|
// Tundra rarer solitary ennemies
|
||||||
@ -119,6 +126,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| close(c.temp, CONFIG.snow_temp, 0.15) * BASE_DENSITY * 0.1,
|
get_density: |c, _col| close(c.temp, CONFIG.snow_temp, 0.15) * BASE_DENSITY * 0.1,
|
||||||
},
|
},
|
||||||
// Tundra rock solitary ennemies
|
// Tundra rock solitary ennemies
|
||||||
@ -133,6 +141,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, col| {
|
get_density: |c, col| {
|
||||||
close(c.temp, CONFIG.snow_temp, 0.15) * BASE_DENSITY * col.rock * 1.0
|
close(c.temp, CONFIG.snow_temp, 0.15) * BASE_DENSITY * col.rock * 1.0
|
||||||
},
|
},
|
||||||
@ -154,6 +163,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, col| {
|
get_density: |c, col| {
|
||||||
close(c.temp, CONFIG.snow_temp + 0.2, 0.2) * col.tree_density * BASE_DENSITY * 0.4
|
close(c.temp, CONFIG.snow_temp + 0.2, 0.2) * col.tree_density * BASE_DENSITY * 0.4
|
||||||
},
|
},
|
||||||
@ -170,6 +180,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 3..8,
|
group_size: 3..8,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, col| {
|
get_density: |c, col| {
|
||||||
close(c.temp, CONFIG.snow_temp + 0.2, 0.6) * col.tree_density * BASE_DENSITY * 0.9
|
close(c.temp, CONFIG.snow_temp + 0.2, 0.6) * col.tree_density * BASE_DENSITY * 0.9
|
||||||
},
|
},
|
||||||
@ -199,6 +210,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..4,
|
group_size: 1..4,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| close(c.temp, CONFIG.snow_temp + 0.2, 0.2) * BASE_DENSITY * 1.0,
|
get_density: |c, _col| close(c.temp, CONFIG.snow_temp + 0.2, 0.2) * BASE_DENSITY * 1.0,
|
||||||
},
|
},
|
||||||
// Taiga solitary wild
|
// Taiga solitary wild
|
||||||
@ -237,6 +249,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| close(c.temp, CONFIG.snow_temp + 0.2, 0.6) * BASE_DENSITY * 5.0,
|
get_density: |c, _col| close(c.temp, CONFIG.snow_temp + 0.2, 0.6) * BASE_DENSITY * 5.0,
|
||||||
},
|
},
|
||||||
// Temperate solitary ennemies
|
// Temperate solitary ennemies
|
||||||
@ -271,6 +284,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, col| {
|
get_density: |c, col| {
|
||||||
close(c.temp, CONFIG.temperate_temp + 0.1, 0.5)
|
close(c.temp, CONFIG.temperate_temp + 0.1, 0.5)
|
||||||
* col.tree_density
|
* col.tree_density
|
||||||
@ -341,6 +355,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..8,
|
group_size: 1..8,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| {
|
get_density: |c, _col| {
|
||||||
close(c.temp, CONFIG.temperate_temp + 0.1, 0.6)
|
close(c.temp, CONFIG.temperate_temp + 0.1, 0.6)
|
||||||
* close(c.humidity, CONFIG.forest_hum, 0.6)
|
* close(c.humidity, CONFIG.forest_hum, 0.6)
|
||||||
@ -408,6 +423,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| {
|
get_density: |c, _col| {
|
||||||
close(c.temp, CONFIG.temperate_temp + 0.1, 0.6)
|
close(c.temp, CONFIG.temperate_temp + 0.1, 0.6)
|
||||||
* BASE_DENSITY
|
* BASE_DENSITY
|
||||||
@ -433,6 +449,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| close(c.temp, CONFIG.temperate_temp, 0.8) * BASE_DENSITY * 0.08,
|
get_density: |c, _col| close(c.temp, CONFIG.temperate_temp, 0.8) * BASE_DENSITY * 0.08,
|
||||||
},
|
},
|
||||||
// Temperate river wildlife
|
// Temperate river wildlife
|
||||||
@ -463,6 +480,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |_c, col| {
|
get_density: |_c, col| {
|
||||||
close(col.temp, CONFIG.temperate_temp, 0.6)
|
close(col.temp, CONFIG.temperate_temp, 0.6)
|
||||||
* if col.water_dist.map(|d| d < 10.0).unwrap_or(false) {
|
* if col.water_dist.map(|d| d < 10.0).unwrap_or(false) {
|
||||||
@ -487,6 +505,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |_c, col| {
|
get_density: |_c, col| {
|
||||||
close(col.temp, CONFIG.temperate_temp, 0.6)
|
close(col.temp, CONFIG.temperate_temp, 0.6)
|
||||||
* if col.water_dist.map(|d| d < 10.0).unwrap_or(false) {
|
* if col.water_dist.map(|d| d < 10.0).unwrap_or(false) {
|
||||||
@ -508,6 +527,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |_c, col| {
|
get_density: |_c, col| {
|
||||||
close(col.temp, CONFIG.temperate_temp, 0.6)
|
close(col.temp, CONFIG.temperate_temp, 0.6)
|
||||||
* if col.water_dist.map(|d| d < 10.0).unwrap_or(false) {
|
* if col.water_dist.map(|d| d < 10.0).unwrap_or(false) {
|
||||||
@ -532,6 +552,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, col| {
|
get_density: |c, col| {
|
||||||
close(c.temp, CONFIG.tropical_temp + 0.1, 0.5) * col.rock * BASE_DENSITY * 5.0
|
close(c.temp, CONFIG.tropical_temp + 0.1, 0.5) * col.rock * BASE_DENSITY * 5.0
|
||||||
},
|
},
|
||||||
@ -557,6 +578,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| {
|
get_density: |c, _col| {
|
||||||
close(c.temp, CONFIG.tropical_temp + 0.2, 0.2)
|
close(c.temp, CONFIG.tropical_temp + 0.2, 0.2)
|
||||||
* close(c.humidity, CONFIG.jungle_hum, 0.2)
|
* close(c.humidity, CONFIG.jungle_hum, 0.2)
|
||||||
@ -585,6 +607,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| {
|
get_density: |c, _col| {
|
||||||
close(c.temp, CONFIG.tropical_temp + 0.2, 0.2)
|
close(c.temp, CONFIG.tropical_temp + 0.2, 0.2)
|
||||||
* close(c.humidity, CONFIG.jungle_hum, 0.2)
|
* close(c.humidity, CONFIG.jungle_hum, 0.2)
|
||||||
@ -619,6 +642,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| {
|
get_density: |c, _col| {
|
||||||
close(c.temp, CONFIG.tropical_temp + 0.2, 0.3)
|
close(c.temp, CONFIG.tropical_temp + 0.2, 0.3)
|
||||||
* close(c.humidity, CONFIG.jungle_hum, 0.2)
|
* close(c.humidity, CONFIG.jungle_hum, 0.2)
|
||||||
@ -638,6 +662,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..3,
|
group_size: 1..3,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |_c, col| {
|
get_density: |_c, col| {
|
||||||
close(col.temp, CONFIG.tropical_temp + 0.2, 0.5)
|
close(col.temp, CONFIG.tropical_temp + 0.2, 0.5)
|
||||||
* if col.water_dist.map(|d| d < 10.0).unwrap_or(false) {
|
* if col.water_dist.map(|d| d < 10.0).unwrap_or(false) {
|
||||||
@ -671,6 +696,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..3,
|
group_size: 1..3,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |_c, col| {
|
get_density: |_c, col| {
|
||||||
close(col.temp, CONFIG.tropical_temp, 0.5)
|
close(col.temp, CONFIG.tropical_temp, 0.5)
|
||||||
* if col.water_dist.map(|d| d < 10.0).unwrap_or(false) {
|
* if col.water_dist.map(|d| d < 10.0).unwrap_or(false) {
|
||||||
@ -700,6 +726,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..3,
|
group_size: 1..3,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| {
|
get_density: |c, _col| {
|
||||||
close(c.temp, CONFIG.tropical_temp + 0.1, 0.4)
|
close(c.temp, CONFIG.tropical_temp + 0.1, 0.4)
|
||||||
* close(c.humidity, CONFIG.desert_hum, 0.4)
|
* close(c.humidity, CONFIG.desert_hum, 0.4)
|
||||||
@ -727,6 +754,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 3..7,
|
group_size: 3..7,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| {
|
get_density: |c, _col| {
|
||||||
close(c.temp, CONFIG.tropical_temp + 0.1, 0.4)
|
close(c.temp, CONFIG.tropical_temp + 0.1, 0.4)
|
||||||
* close(c.humidity, CONFIG.desert_hum, 0.4)
|
* close(c.humidity, CONFIG.desert_hum, 0.4)
|
||||||
@ -757,6 +785,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| {
|
get_density: |c, _col| {
|
||||||
close(c.temp, CONFIG.desert_temp + 0.2, 0.3)
|
close(c.temp, CONFIG.desert_temp + 0.2, 0.3)
|
||||||
* close(c.humidity, CONFIG.desert_hum, 0.5)
|
* close(c.humidity, CONFIG.desert_hum, 0.5)
|
||||||
@ -781,6 +810,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| {
|
get_density: |c, _col| {
|
||||||
close(c.temp, CONFIG.desert_temp + 0.2, 0.3)
|
close(c.temp, CONFIG.desert_temp + 0.2, 0.3)
|
||||||
* close(c.humidity, CONFIG.desert_hum, 0.5)
|
* close(c.humidity, CONFIG.desert_hum, 0.5)
|
||||||
@ -800,6 +830,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..3,
|
group_size: 1..3,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |_c, col| {
|
get_density: |_c, col| {
|
||||||
close(col.temp, CONFIG.desert_temp + 0.2, 0.3)
|
close(col.temp, CONFIG.desert_temp + 0.2, 0.3)
|
||||||
* if col.water_dist.map(|d| d < 10.0).unwrap_or(false) {
|
* if col.water_dist.map(|d| d < 10.0).unwrap_or(false) {
|
||||||
@ -824,6 +855,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..3,
|
group_size: 1..3,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| {
|
get_density: |c, _col| {
|
||||||
close(c.temp, CONFIG.desert_temp + 0.2, 0.3)
|
close(c.temp, CONFIG.desert_temp + 0.2, 0.3)
|
||||||
* close(c.humidity, CONFIG.desert_hum, 0.5)
|
* close(c.humidity, CONFIG.desert_hum, 0.5)
|
||||||
@ -875,6 +907,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..2,
|
group_size: 1..2,
|
||||||
is_underwater: false,
|
is_underwater: false,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, _col| {
|
get_density: |c, _col| {
|
||||||
close(c.temp, CONFIG.desert_temp + 0.2, 0.3) * BASE_DENSITY * 5.0
|
close(c.temp, CONFIG.desert_temp + 0.2, 0.3) * BASE_DENSITY * 5.0
|
||||||
},
|
},
|
||||||
@ -896,6 +929,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 3..5,
|
group_size: 3..5,
|
||||||
is_underwater: true,
|
is_underwater: true,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, col| {
|
get_density: |c, col| {
|
||||||
close(c.temp, CONFIG.temperate_temp, 1.0) * col.tree_density * BASE_DENSITY * 5.0
|
close(c.temp, CONFIG.temperate_temp, 1.0) * col.tree_density * BASE_DENSITY * 5.0
|
||||||
},
|
},
|
||||||
@ -911,6 +945,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
},
|
},
|
||||||
group_size: 1..3,
|
group_size: 1..3,
|
||||||
is_underwater: true,
|
is_underwater: true,
|
||||||
|
day_period: vec![Night, Morning, Noon, Evening],
|
||||||
get_density: |c, col| {
|
get_density: |c, col| {
|
||||||
close(c.temp, CONFIG.snow_temp, 0.15) * col.tree_density * BASE_DENSITY * 5.0
|
close(c.temp, CONFIG.snow_temp, 0.15) * col.tree_density * BASE_DENSITY * 5.0
|
||||||
},
|
},
|
||||||
@ -931,6 +966,12 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let underwater = col_sample.water_level > col_sample.alt;
|
let underwater = col_sample.water_level > col_sample.alt;
|
||||||
|
let current_day_period;
|
||||||
|
if let Some(time) = time {
|
||||||
|
current_day_period = DayPeriod::from(time.0)
|
||||||
|
} else {
|
||||||
|
current_day_period = Noon
|
||||||
|
}
|
||||||
|
|
||||||
let entity_group = scatter.iter().enumerate().find_map(
|
let entity_group = scatter.iter().enumerate().find_map(
|
||||||
|(
|
|(
|
||||||
@ -939,6 +980,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
make_entity,
|
make_entity,
|
||||||
group_size,
|
group_size,
|
||||||
is_underwater,
|
is_underwater,
|
||||||
|
day_period,
|
||||||
get_density,
|
get_density,
|
||||||
},
|
},
|
||||||
)| {
|
)| {
|
||||||
@ -946,6 +988,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
|
|||||||
if density > 0.0
|
if density > 0.0
|
||||||
&& dynamic_rng.gen::<f32>() < density * col_sample.spawn_rate
|
&& dynamic_rng.gen::<f32>() < density * col_sample.spawn_rate
|
||||||
&& underwater == *is_underwater
|
&& underwater == *is_underwater
|
||||||
|
&& day_period.contains(¤t_day_period)
|
||||||
&& col_sample.gradient < Some(1.3)
|
&& col_sample.gradient < Some(1.3)
|
||||||
{
|
{
|
||||||
Some((make_entity, group_size.clone()))
|
Some((make_entity, group_size.clone()))
|
||||||
|
@ -50,6 +50,7 @@ use crate::{
|
|||||||
use common::{
|
use common::{
|
||||||
assets,
|
assets,
|
||||||
generation::{ChunkSupplement, EntityInfo},
|
generation::{ChunkSupplement, EntityInfo},
|
||||||
|
resources::TimeOfDay,
|
||||||
terrain::{Block, BlockKind, SpriteKind, TerrainChunk, TerrainChunkMeta, TerrainChunkSize},
|
terrain::{Block, BlockKind, SpriteKind, TerrainChunk, TerrainChunkMeta, TerrainChunkSize},
|
||||||
vol::{ReadVol, RectVolSize, WriteVol},
|
vol::{ReadVol, RectVolSize, WriteVol},
|
||||||
};
|
};
|
||||||
@ -171,7 +172,9 @@ impl World {
|
|||||||
|
|
||||||
// Unwrapping because generate_chunk only returns err when should_continue evals
|
// Unwrapping because generate_chunk only returns err when should_continue evals
|
||||||
// to true
|
// to true
|
||||||
let (tc, _cs) = self.generate_chunk(index, chunk_pos, || false).unwrap();
|
let (tc, _cs) = self
|
||||||
|
.generate_chunk(index, chunk_pos, || false, None)
|
||||||
|
.unwrap();
|
||||||
let min_z = tc.get_min_z();
|
let min_z = tc.get_min_z();
|
||||||
let max_z = tc.get_max_z();
|
let max_z = tc.get_max_z();
|
||||||
|
|
||||||
@ -209,6 +212,7 @@ impl World {
|
|||||||
chunk_pos: Vec2<i32>,
|
chunk_pos: Vec2<i32>,
|
||||||
// TODO: misleading name
|
// TODO: misleading name
|
||||||
mut should_continue: impl FnMut() -> bool,
|
mut should_continue: impl FnMut() -> bool,
|
||||||
|
time: Option<TimeOfDay>,
|
||||||
) -> Result<(TerrainChunk, ChunkSupplement), ()> {
|
) -> Result<(TerrainChunk, ChunkSupplement), ()> {
|
||||||
let mut sampler = self.sample_blocks();
|
let mut sampler = self.sample_blocks();
|
||||||
|
|
||||||
@ -390,6 +394,7 @@ impl World {
|
|||||||
index,
|
index,
|
||||||
sim_chunk,
|
sim_chunk,
|
||||||
&mut supplement,
|
&mut supplement,
|
||||||
|
time,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Apply site supplementary information
|
// Apply site supplementary information
|
||||||
|
Loading…
Reference in New Issue
Block a user