mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Moved functions to client out of audio and generalized non-positional ambient sfx
This commit is contained in:
parent
a9711eea01
commit
9c87345135
@ -34,7 +34,7 @@ use common::{
|
||||
recipe::RecipeBook,
|
||||
state::State,
|
||||
sync::{Uid, UidAllocator, WorldSyncExt},
|
||||
terrain::{block::Block, neighbors, TerrainChunk, TerrainChunkSize},
|
||||
terrain::{block::Block, neighbors, BiomeKind, SitesKind, TerrainChunk, TerrainChunkSize},
|
||||
vol::RectVolSize,
|
||||
};
|
||||
use comp::BuffKind;
|
||||
@ -869,6 +869,33 @@ impl Client {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn current_biome(&self) -> BiomeKind {
|
||||
match self.current_chunk() {
|
||||
Some(chunk) => chunk.meta().biome(),
|
||||
_ => BiomeKind::Void,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn current_site(&self) -> SitesKind {
|
||||
let mut player_alt = 0.0;
|
||||
if let Some(position) = self.current::<comp::Pos>() {
|
||||
player_alt = position.0.z;
|
||||
}
|
||||
let mut contains_cave = false;
|
||||
let mut terrain_alt = 0.0;
|
||||
if let Some(chunk) = self.current_chunk() {
|
||||
terrain_alt = chunk.meta().alt();
|
||||
contains_cave = chunk.meta().contains_cave();
|
||||
}
|
||||
if player_alt < (terrain_alt - 15.0) && contains_cave {
|
||||
SitesKind::Cave
|
||||
} else if player_alt < (terrain_alt - 15.0) {
|
||||
SitesKind::Dungeon
|
||||
} else {
|
||||
SitesKind::Void
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inventories(&self) -> ReadStorage<comp::Inventory> { self.state.read_storage() }
|
||||
|
||||
pub fn loadouts(&self) -> ReadStorage<comp::Loadout> { self.state.read_storage() }
|
||||
|
@ -32,13 +32,6 @@ enum ChannelState {
|
||||
Stopped,
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub enum ChannelKind {
|
||||
Music(MusicChannelTag),
|
||||
Sfx,
|
||||
Ambient(AmbientChannelTag),
|
||||
}
|
||||
|
||||
/// Each `MusicChannel` has a `MusicChannelTag` which help us determine when we
|
||||
/// should transition between two types of in-game music. For example, we
|
||||
/// transition between `TitleMusic` and `Exploration` when a player enters the
|
||||
|
@ -45,7 +45,7 @@
|
||||
use crate::audio::{AudioFrontend, MusicChannelTag};
|
||||
use client::Client;
|
||||
use common::{
|
||||
assets, comp,
|
||||
assets,
|
||||
state::State,
|
||||
terrain::{BiomeKind, SitesKind},
|
||||
};
|
||||
@ -154,8 +154,8 @@ impl MusicMgr {
|
||||
|
||||
let game_time = (state.get_time_of_day() as u64 % 86400) as u32;
|
||||
let current_period_of_day = Self::get_current_day_period(game_time);
|
||||
let current_biome = Self::get_current_biome(client);
|
||||
let current_site = Self::get_current_site(client);
|
||||
let current_biome = client.current_biome();
|
||||
let current_site = client.current_site();
|
||||
|
||||
// Filters out tracks not matching the timing, site, and biome
|
||||
let maybe_tracks = self
|
||||
@ -225,33 +225,6 @@ impl MusicMgr {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_current_biome(client: &Client) -> BiomeKind {
|
||||
match client.current_chunk() {
|
||||
Some(chunk) => chunk.meta().biome(),
|
||||
_ => BiomeKind::Void,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_current_site(client: &Client) -> SitesKind {
|
||||
let mut player_alt = 0.0;
|
||||
if let Some(position) = client.current::<comp::Pos>() {
|
||||
player_alt = position.0.z;
|
||||
}
|
||||
let mut contains_cave = false;
|
||||
let mut terrain_alt = 0.0;
|
||||
if let Some(chunk) = client.current_chunk() {
|
||||
terrain_alt = chunk.meta().alt();
|
||||
contains_cave = chunk.meta().contains_cave();
|
||||
}
|
||||
if player_alt < (terrain_alt - 20.0) && contains_cave {
|
||||
SitesKind::Cave
|
||||
} else if player_alt < (terrain_alt - 20.0) {
|
||||
SitesKind::Dungeon
|
||||
} else {
|
||||
SitesKind::Void
|
||||
}
|
||||
}
|
||||
|
||||
fn load_soundtrack_items() -> SoundtrackCollection {
|
||||
match assets::load_file("voxygen.audio.soundtrack", &["ron"]) {
|
||||
Ok(file) => match ron::de::from_reader(file) {
|
||||
|
Loading…
Reference in New Issue
Block a user