diff --git a/client/src/lib.rs b/client/src/lib.rs index 73e1fab9ea..f923961be4 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -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::() { + 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 { self.state.read_storage() } pub fn loadouts(&self) -> ReadStorage { self.state.read_storage() } diff --git a/voxygen/src/audio/channel.rs b/voxygen/src/audio/channel.rs index f7496a9bec..7400c32538 100644 --- a/voxygen/src/audio/channel.rs +++ b/voxygen/src/audio/channel.rs @@ -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 diff --git a/voxygen/src/audio/music.rs b/voxygen/src/audio/music.rs index 4552555f16..7d0e94b2c8 100644 --- a/voxygen/src/audio/music.rs +++ b/voxygen/src/audio/music.rs @@ -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::() { - 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) {