mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'slipped/lavanoise' into 'master'
lava noise See merge request veloren/veloren!4147
This commit is contained in:
commit
c422616f70
@ -129,6 +129,18 @@
|
|||||||
threshold: 5.0,
|
threshold: 5.0,
|
||||||
subtitle: "subtitle-running_water",
|
subtitle: "subtitle-running_water",
|
||||||
),
|
),
|
||||||
|
Lavapool: (
|
||||||
|
files: [
|
||||||
|
"voxygen.audio.sfx.ambient.river_sounds.running_water-003",
|
||||||
|
"voxygen.audio.sfx.ambient.river_sounds.running_water-004",
|
||||||
|
"voxygen.audio.sfx.ambient.river_sounds.running_water-005",
|
||||||
|
"voxygen.audio.sfx.ambient.river_sounds.running_water-006",
|
||||||
|
"voxygen.audio.sfx.ambient.river_sounds.running_water-012",
|
||||||
|
"voxygen.audio.sfx.ambient.river_sounds.running_water-013",
|
||||||
|
],
|
||||||
|
threshold: 7.0,
|
||||||
|
subtitle: "subtitle-lavapool",
|
||||||
|
),
|
||||||
//
|
//
|
||||||
// Character States
|
// Character States
|
||||||
//
|
//
|
||||||
|
@ -16,7 +16,8 @@ use common::{
|
|||||||
};
|
};
|
||||||
use common_state::State;
|
use common_state::State;
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use rand::{seq::SliceRandom, thread_rng, Rng};
|
use rand::{prelude::*, seq::SliceRandom, thread_rng, Rng};
|
||||||
|
use rand_chacha::ChaCha8Rng;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
@ -55,13 +56,15 @@ impl EventMapper for BlockEventMapper {
|
|||||||
let focus_off = camera.get_focus_pos().map(f32::trunc);
|
let focus_off = camera.get_focus_pos().map(f32::trunc);
|
||||||
let cam_pos = camera.dependents().cam_pos + focus_off;
|
let cam_pos = camera.dependents().cam_pos + focus_off;
|
||||||
|
|
||||||
|
let mut rng = ChaCha8Rng::from_seed(thread_rng().gen());
|
||||||
|
|
||||||
// Get the player position and chunk
|
// Get the player position and chunk
|
||||||
if let Some(player_pos) = state.read_component_copied::<Pos>(player_entity) {
|
if let Some(player_pos) = state.read_component_copied::<Pos>(player_entity) {
|
||||||
let player_chunk = player_pos.0.xy().map2(TerrainChunk::RECT_SIZE, |e, sz| {
|
let player_chunk = player_pos.0.xy().map2(TerrainChunk::RECT_SIZE, |e, sz| {
|
||||||
(e.floor() as i32).div_euclid(sz as i32)
|
(e.floor() as i32).div_euclid(sz as i32)
|
||||||
});
|
});
|
||||||
|
|
||||||
// For determining if underground/crickets should chirp
|
// For determining if crickets should chirp
|
||||||
let (terrain_alt, temp) = match client.current_chunk() {
|
let (terrain_alt, temp) = match client.current_chunk() {
|
||||||
Some(chunk) => (chunk.meta().alt(), chunk.meta().temp()),
|
Some(chunk) => (chunk.meta().alt(), chunk.meta().temp()),
|
||||||
None => (0.0, 0.0),
|
None => (0.0, 0.0),
|
||||||
@ -109,6 +112,13 @@ impl EventMapper for BlockEventMapper {
|
|||||||
volume: 1.5,
|
volume: 1.5,
|
||||||
cond: |_| true,
|
cond: |_| true,
|
||||||
},
|
},
|
||||||
|
BlockSounds {
|
||||||
|
blocks: |boi| &boi.lavapool,
|
||||||
|
range: 1,
|
||||||
|
sfx: SfxEvent::Lavapool,
|
||||||
|
volume: 1.8,
|
||||||
|
cond: |_| true,
|
||||||
|
},
|
||||||
//BlockSounds {
|
//BlockSounds {
|
||||||
// blocks: |boi| &boi.embers,
|
// blocks: |boi| &boi.embers,
|
||||||
// range: 1,
|
// range: 1,
|
||||||
@ -161,17 +171,15 @@ impl EventMapper for BlockEventMapper {
|
|||||||
cond: |st| st.get_day_period().is_light(),
|
cond: |st| st.get_day_period().is_light(),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// Iterate through each kind of block of interest
|
// Iterate through each kind of block of interest
|
||||||
for sounds in sounds.iter() {
|
for sounds in sounds.iter() {
|
||||||
// If the timing condition is false, continue
|
// If the timing condition is false, continue
|
||||||
// or if the player is far enough underground, continue
|
// TODO Address bird hack properly. See TODO below
|
||||||
// TODO Address bird hack properly. See TODO on line 190
|
|
||||||
if !(sounds.cond)(state)
|
if !(sounds.cond)(state)
|
||||||
|| player_pos.0.z < (terrain_alt - 30.0)
|
|| (!(sounds.sfx == SfxEvent::Lavapool) && player_pos.0.z < (terrain_alt - 30.0))
|
||||||
|| (sounds.sfx == SfxEvent::Birdcall && thread_rng().gen_bool(0.995))
|
|| (sounds.sfx == SfxEvent::Birdcall && rng.gen_bool(0.995))
|
||||||
|| (sounds.sfx == SfxEvent::Owl && thread_rng().gen_bool(0.998))
|
|| (sounds.sfx == SfxEvent::Owl && rng.gen_bool(0.998))
|
||||||
|| (sounds.sfx == SfxEvent::Frog && thread_rng().gen_bool(0.95))
|
|| (sounds.sfx == SfxEvent::Frog && rng.gen_bool(0.95))
|
||||||
//Crickets will not chirp below 5 Celsius
|
//Crickets will not chirp below 5 Celsius
|
||||||
|| (sounds.sfx == SfxEvent::Cricket1 && (temp < -0.33))
|
|| (sounds.sfx == SfxEvent::Cricket1 && (temp < -0.33))
|
||||||
|| (sounds.sfx == SfxEvent::Cricket2 && (temp < -0.33))
|
|| (sounds.sfx == SfxEvent::Cricket2 && (temp < -0.33))
|
||||||
@ -195,9 +203,10 @@ impl EventMapper for BlockEventMapper {
|
|||||||
// Replace all RunningWater blocks with just one random one per tick
|
// Replace all RunningWater blocks with just one random one per tick
|
||||||
let blocks = if sounds.sfx == SfxEvent::RunningWaterSlow
|
let blocks = if sounds.sfx == SfxEvent::RunningWaterSlow
|
||||||
|| sounds.sfx == SfxEvent::RunningWaterFast
|
|| sounds.sfx == SfxEvent::RunningWaterFast
|
||||||
|
|| sounds.sfx == SfxEvent::Lavapool
|
||||||
{
|
{
|
||||||
blocks
|
blocks
|
||||||
.choose(&mut thread_rng())
|
.choose(&mut rng)
|
||||||
.map(std::slice::from_ref)
|
.map(std::slice::from_ref)
|
||||||
.unwrap_or(&[])
|
.unwrap_or(&[])
|
||||||
} else {
|
} else {
|
||||||
@ -210,10 +219,10 @@ impl EventMapper for BlockEventMapper {
|
|||||||
// block of interest type which picks fewer leaf blocks
|
// block of interest type which picks fewer leaf blocks
|
||||||
// Hack to reduce the number of bird, frog, and water sounds
|
// Hack to reduce the number of bird, frog, and water sounds
|
||||||
if ((sounds.sfx == SfxEvent::Birdcall || sounds.sfx == SfxEvent::Owl)
|
if ((sounds.sfx == SfxEvent::Birdcall || sounds.sfx == SfxEvent::Owl)
|
||||||
&& thread_rng().gen_bool(0.9995))
|
&& rng.gen_bool(0.9995))
|
||||||
|| (sounds.sfx == SfxEvent::Frog && thread_rng().gen_bool(0.75))
|
|| (sounds.sfx == SfxEvent::Frog && rng.gen_bool(0.75))
|
||||||
|| (sounds.sfx == SfxEvent::RunningWaterSlow
|
|| (sounds.sfx == SfxEvent::RunningWaterSlow && rng.gen_bool(0.5))
|
||||||
&& thread_rng().gen_bool(0.5))
|
|| (sounds.sfx == SfxEvent::Lavapool && rng.gen_bool(0.99))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -284,6 +293,8 @@ impl BlockEventMapper {
|
|||||||
sfx_trigger_item: Option<(&SfxEvent, &SfxTriggerItem)>,
|
sfx_trigger_item: Option<(&SfxEvent, &SfxTriggerItem)>,
|
||||||
temp: f32,
|
temp: f32,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
let mut rng = ChaCha8Rng::from_seed(thread_rng().gen());
|
||||||
|
|
||||||
if let Some((event, item)) = sfx_trigger_item {
|
if let Some((event, item)) = sfx_trigger_item {
|
||||||
//The interval between cricket chirps calculated by converting chunk
|
//The interval between cricket chirps calculated by converting chunk
|
||||||
// temperature to centigrade (we should create a function for this) and applying
|
// temperature to centigrade (we should create a function for this) and applying
|
||||||
@ -295,7 +306,7 @@ impl BlockEventMapper {
|
|||||||
match event {
|
match event {
|
||||||
SfxEvent::Cricket1 => {
|
SfxEvent::Cricket1 => {
|
||||||
previous_state.time.elapsed().as_secs_f32()
|
previous_state.time.elapsed().as_secs_f32()
|
||||||
>= cricket_interval + thread_rng().gen_range(-0.1..0.1)
|
>= cricket_interval + rng.gen_range(-0.1..0.1)
|
||||||
},
|
},
|
||||||
SfxEvent::Cricket2 => {
|
SfxEvent::Cricket2 => {
|
||||||
//the length and manner of this sound is quite different
|
//the length and manner of this sound is quite different
|
||||||
@ -303,17 +314,16 @@ impl BlockEventMapper {
|
|||||||
previous_state.time.elapsed().as_secs_f32() >= 0.75
|
previous_state.time.elapsed().as_secs_f32() >= 0.75
|
||||||
} else {
|
} else {
|
||||||
previous_state.time.elapsed().as_secs_f32()
|
previous_state.time.elapsed().as_secs_f32()
|
||||||
>= cricket_interval + thread_rng().gen_range(-0.1..0.1)
|
>= cricket_interval + rng.gen_range(-0.1..0.1)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SfxEvent::Cricket3 => {
|
SfxEvent::Cricket3 => {
|
||||||
previous_state.time.elapsed().as_secs_f32()
|
previous_state.time.elapsed().as_secs_f32()
|
||||||
>= cricket_interval + thread_rng().gen_range(-0.1..0.1)
|
>= cricket_interval + rng.gen_range(-0.1..0.1)
|
||||||
},
|
},
|
||||||
//Adds random factor to frogs (probably doesn't do anything most of the time)
|
//Adds random factor to frogs (probably doesn't do anything most of the time)
|
||||||
SfxEvent::Frog => {
|
SfxEvent::Frog => {
|
||||||
previous_state.time.elapsed().as_secs_f32()
|
previous_state.time.elapsed().as_secs_f32() >= rng.gen_range(-2.0..2.0)
|
||||||
>= thread_rng().gen_range(-2.0..2.0)
|
|
||||||
},
|
},
|
||||||
_ => previous_state.time.elapsed().as_secs_f32() >= item.threshold,
|
_ => previous_state.time.elapsed().as_secs_f32() >= item.threshold,
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,7 @@ pub enum SfxEvent {
|
|||||||
Bees,
|
Bees,
|
||||||
RunningWaterSlow,
|
RunningWaterSlow,
|
||||||
RunningWaterFast,
|
RunningWaterFast,
|
||||||
|
Lavapool,
|
||||||
Idle,
|
Idle,
|
||||||
Swim,
|
Swim,
|
||||||
Run(BlockKind),
|
Run(BlockKind),
|
||||||
|
@ -39,6 +39,7 @@ pub struct BlocksOfInterest {
|
|||||||
pub grass: Vec<Vec3<i32>>,
|
pub grass: Vec<Vec3<i32>>,
|
||||||
pub slow_river: Vec<Vec3<i32>>,
|
pub slow_river: Vec<Vec3<i32>>,
|
||||||
pub fast_river: Vec<Vec3<i32>>,
|
pub fast_river: Vec<Vec3<i32>>,
|
||||||
|
pub lavapool: Vec<Vec3<i32>>,
|
||||||
pub fires: Vec<Vec3<i32>>,
|
pub fires: Vec<Vec3<i32>>,
|
||||||
pub smokers: Vec<SmokerProperties>,
|
pub smokers: Vec<SmokerProperties>,
|
||||||
pub beehives: Vec<Vec3<i32>>,
|
pub beehives: Vec<Vec3<i32>>,
|
||||||
@ -76,6 +77,7 @@ impl BlocksOfInterest {
|
|||||||
let mut grass = Vec::new();
|
let mut grass = Vec::new();
|
||||||
let mut slow_river = Vec::new();
|
let mut slow_river = Vec::new();
|
||||||
let mut fast_river = Vec::new();
|
let mut fast_river = Vec::new();
|
||||||
|
let mut lavapool = Vec::new();
|
||||||
let mut fires = Vec::new();
|
let mut fires = Vec::new();
|
||||||
let mut smokers = Vec::new();
|
let mut smokers = Vec::new();
|
||||||
let mut beehives = Vec::new();
|
let mut beehives = Vec::new();
|
||||||
@ -124,12 +126,16 @@ impl BlocksOfInterest {
|
|||||||
BlockKind::Water if river_speed_sq > 0.3_f32.powi(2) => slow_river.push(pos),
|
BlockKind::Water if river_speed_sq > 0.3_f32.powi(2) => slow_river.push(pos),
|
||||||
BlockKind::Snow if rng.gen_range(0..16) == 0 => snow.push(pos),
|
BlockKind::Snow if rng.gen_range(0..16) == 0 => snow.push(pos),
|
||||||
BlockKind::Lava
|
BlockKind::Lava
|
||||||
if rng.gen_range(0..5) == 0
|
if chunk
|
||||||
&& chunk
|
.get(pos + Vec3::unit_z())
|
||||||
.get(pos + Vec3::unit_z())
|
.map_or(true, |b| !b.is_filled()) =>
|
||||||
.map_or(true, |b| !b.is_filled()) =>
|
|
||||||
{
|
{
|
||||||
fires.push(pos + Vec3::unit_z())
|
if rng.gen_range(0..5) == 0 {
|
||||||
|
fires.push(pos + Vec3::unit_z())
|
||||||
|
}
|
||||||
|
if rng.gen_range(0..16) == 0 {
|
||||||
|
lavapool.push(pos)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
BlockKind::Snow | BlockKind::Ice if rng.gen_range(0..16) == 0 => snow.push(pos),
|
BlockKind::Snow | BlockKind::Ice if rng.gen_range(0..16) == 0 => snow.push(pos),
|
||||||
_ => match block.get_sprite() {
|
_ => match block.get_sprite() {
|
||||||
@ -235,6 +241,7 @@ impl BlocksOfInterest {
|
|||||||
grass,
|
grass,
|
||||||
slow_river,
|
slow_river,
|
||||||
fast_river,
|
fast_river,
|
||||||
|
lavapool,
|
||||||
fires,
|
fires,
|
||||||
smokers,
|
smokers,
|
||||||
beehives,
|
beehives,
|
||||||
|
Loading…
Reference in New Issue
Block a user