mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix warnings
This commit is contained in:
@ -13,9 +13,9 @@ pub enum AudioType {
|
|||||||
|
|
||||||
#[derive(PartialEq, Clone, Copy)]
|
#[derive(PartialEq, Clone, Copy)]
|
||||||
enum ChannelState {
|
enum ChannelState {
|
||||||
Init,
|
// Init,
|
||||||
ToPlay,
|
// ToPlay,
|
||||||
Loading,
|
// Loading,
|
||||||
Playing,
|
Playing,
|
||||||
Stopping,
|
Stopping,
|
||||||
Stopped,
|
Stopped,
|
||||||
@ -121,7 +121,7 @@ impl Channel {
|
|||||||
|
|
||||||
pub fn update(&mut self, dt: f32) {
|
pub fn update(&mut self, dt: f32) {
|
||||||
match self.state {
|
match self.state {
|
||||||
ChannelState::Init | ChannelState::ToPlay | ChannelState::Loading => {}
|
// ChannelState::Init | ChannelState::ToPlay | ChannelState::Loading => {}
|
||||||
ChannelState::Playing => {}
|
ChannelState::Playing => {}
|
||||||
ChannelState::Stopping => {
|
ChannelState::Stopping => {
|
||||||
self.fader.update(dt);
|
self.fader.update(dt);
|
||||||
|
@ -6,7 +6,7 @@ use fader::Fader;
|
|||||||
use soundcache::SoundCache;
|
use soundcache::SoundCache;
|
||||||
|
|
||||||
use common::assets;
|
use common::assets;
|
||||||
use rodio::{Decoder, Device, SpatialSink};
|
use rodio::{Decoder, Device};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
const FALLOFF: f32 = 0.13;
|
const FALLOFF: f32 = 0.13;
|
||||||
@ -36,7 +36,7 @@ impl AudioFrontend {
|
|||||||
let mut channels = Vec::with_capacity(channel_num);
|
let mut channels = Vec::with_capacity(channel_num);
|
||||||
let audio_device = get_device_raw(&device);
|
let audio_device = get_device_raw(&device);
|
||||||
if let Some(audio_device) = &audio_device {
|
if let Some(audio_device) = &audio_device {
|
||||||
for i in (0..channel_num) {
|
for _i in 0..channel_num {
|
||||||
channels.push(Channel::new(&audio_device));
|
channels.push(Channel::new(&audio_device));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ impl AudioFrontend {
|
|||||||
|
|
||||||
/// Maintain audio
|
/// Maintain audio
|
||||||
pub fn maintain(&mut self, dt: f32) {
|
pub fn maintain(&mut self, dt: f32) {
|
||||||
for (i, channel) in self.channels.iter_mut().enumerate() {
|
for channel in self.channels.iter_mut() {
|
||||||
channel.update(dt);
|
channel.update(dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ impl AudioFrontend {
|
|||||||
let id = self.next_channel_id;
|
let id = self.next_channel_id;
|
||||||
self.next_channel_id += 1;
|
self.next_channel_id += 1;
|
||||||
|
|
||||||
if let Some(device) = &self.audio_device {
|
if let Some(_) = &self.audio_device {
|
||||||
let calc_pos = [
|
let calc_pos = [
|
||||||
(pos.x - self.listener_pos.x) * FALLOFF,
|
(pos.x - self.listener_pos.x) * FALLOFF,
|
||||||
(pos.y - self.listener_pos.y) * FALLOFF,
|
(pos.y - self.listener_pos.y) * FALLOFF,
|
||||||
@ -148,7 +148,7 @@ impl AudioFrontend {
|
|||||||
let id = self.next_channel_id;
|
let id = self.next_channel_id;
|
||||||
self.next_channel_id += 1;
|
self.next_channel_id += 1;
|
||||||
|
|
||||||
if let Some(device) = &self.audio_device {
|
if let Some(_) = &self.audio_device {
|
||||||
let file = assets::load_file(&sound, &["ogg"]).unwrap();
|
let file = assets::load_file(&sound, &["ogg"]).unwrap();
|
||||||
let sound = Decoder::new(file).unwrap();
|
let sound = Decoder::new(file).unwrap();
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ mod start_singleplayer;
|
|||||||
mod ui;
|
mod ui;
|
||||||
|
|
||||||
use super::char_selection::CharSelectionState;
|
use super::char_selection::CharSelectionState;
|
||||||
use crate::{audio::fader::Fader, window::Event, Direction, GlobalState, PlayState, PlayStateResult};
|
use crate::{window::Event, Direction, GlobalState, PlayState, PlayStateResult};
|
||||||
use client_init::{ClientInit, Error as InitError};
|
use client_init::{ClientInit, Error as InitError};
|
||||||
use common::{clock::Clock, comp};
|
use common::{clock::Clock, comp};
|
||||||
use log::warn;
|
use log::warn;
|
||||||
|
@ -1,31 +1,23 @@
|
|||||||
use crate::{
|
use crate::audio::AudioFrontend;
|
||||||
audio::AudioFrontend,
|
|
||||||
};
|
|
||||||
use common::comp::{
|
|
||||||
Pos,
|
|
||||||
Ori,
|
|
||||||
Body,
|
|
||||||
CharacterState,
|
|
||||||
MovementState::*,
|
|
||||||
};
|
|
||||||
use client::Client;
|
use client::Client;
|
||||||
use vek::*;
|
use common::comp::{Body, CharacterState, MovementState::*, Ori, Pos};
|
||||||
use specs::{Entity as EcsEntity, Join};
|
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use std::{f32, time::Instant};
|
use specs::{Entity as EcsEntity, Join};
|
||||||
|
use std::time::Instant;
|
||||||
|
use vek::*;
|
||||||
|
|
||||||
pub struct AnimState {
|
pub struct AnimState {
|
||||||
last_step_sound: Instant,
|
last_step_sound: Instant,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SoundMgr {
|
pub struct SoundMgr {
|
||||||
character_states: HashMap<EcsEntity, AnimState>
|
character_states: HashMap<EcsEntity, AnimState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SoundMgr {
|
impl SoundMgr {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
character_states: HashMap::new(),
|
character_states: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,12 +52,17 @@ impl SoundMgr {
|
|||||||
let state = self
|
let state = self
|
||||||
.character_states
|
.character_states
|
||||||
.entry(entity)
|
.entry(entity)
|
||||||
.or_insert_with(|| AnimState {last_step_sound: Instant::now()});
|
.or_insert_with(|| AnimState {
|
||||||
|
last_step_sound: Instant::now(),
|
||||||
|
});
|
||||||
|
|
||||||
if let Run = &character.movement {
|
if let Run = &character.movement {
|
||||||
if state.last_step_sound.elapsed().as_secs_f64() > 0.25 {
|
if state.last_step_sound.elapsed().as_secs_f64() > 0.25 {
|
||||||
let rand_step = (rand::random::<usize>() % 7) + 1;
|
let rand_step = (rand::random::<usize>() % 7) + 1;
|
||||||
audio.play_sound(format!("voxygen.audio.footsteps.stepdirt_{}", rand_step), pos.0);
|
audio.play_sound(
|
||||||
|
format!("voxygen.audio.footsteps.stepdirt_{}", rand_step),
|
||||||
|
pos.0,
|
||||||
|
);
|
||||||
state.last_step_sound = Instant::now();
|
state.last_step_sound = Instant::now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user