mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix warnings
This commit is contained in:
parent
3fe12ee85f
commit
57fe89e5c8
@ -13,9 +13,9 @@ pub enum AudioType {
|
||||
|
||||
#[derive(PartialEq, Clone, Copy)]
|
||||
enum ChannelState {
|
||||
Init,
|
||||
ToPlay,
|
||||
Loading,
|
||||
// Init,
|
||||
// ToPlay,
|
||||
// Loading,
|
||||
Playing,
|
||||
Stopping,
|
||||
Stopped,
|
||||
@ -121,7 +121,7 @@ impl Channel {
|
||||
|
||||
pub fn update(&mut self, dt: f32) {
|
||||
match self.state {
|
||||
ChannelState::Init | ChannelState::ToPlay | ChannelState::Loading => {}
|
||||
// ChannelState::Init | ChannelState::ToPlay | ChannelState::Loading => {}
|
||||
ChannelState::Playing => {}
|
||||
ChannelState::Stopping => {
|
||||
self.fader.update(dt);
|
||||
|
@ -6,7 +6,7 @@ use fader::Fader;
|
||||
use soundcache::SoundCache;
|
||||
|
||||
use common::assets;
|
||||
use rodio::{Decoder, Device, SpatialSink};
|
||||
use rodio::{Decoder, Device};
|
||||
use vek::*;
|
||||
|
||||
const FALLOFF: f32 = 0.13;
|
||||
@ -36,7 +36,7 @@ impl AudioFrontend {
|
||||
let mut channels = Vec::with_capacity(channel_num);
|
||||
let audio_device = get_device_raw(&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));
|
||||
}
|
||||
}
|
||||
@ -76,7 +76,7 @@ impl AudioFrontend {
|
||||
|
||||
/// Maintain audio
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -93,7 +93,7 @@ impl AudioFrontend {
|
||||
let id = self.next_channel_id;
|
||||
self.next_channel_id += 1;
|
||||
|
||||
if let Some(device) = &self.audio_device {
|
||||
if let Some(_) = &self.audio_device {
|
||||
let calc_pos = [
|
||||
(pos.x - self.listener_pos.x) * FALLOFF,
|
||||
(pos.y - self.listener_pos.y) * FALLOFF,
|
||||
@ -148,7 +148,7 @@ impl AudioFrontend {
|
||||
let id = self.next_channel_id;
|
||||
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 sound = Decoder::new(file).unwrap();
|
||||
|
||||
|
@ -3,7 +3,7 @@ mod start_singleplayer;
|
||||
mod ui;
|
||||
|
||||
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 common::{clock::Clock, comp};
|
||||
use log::warn;
|
||||
|
@ -1,31 +1,23 @@
|
||||
use crate::{
|
||||
audio::AudioFrontend,
|
||||
};
|
||||
use common::comp::{
|
||||
Pos,
|
||||
Ori,
|
||||
Body,
|
||||
CharacterState,
|
||||
MovementState::*,
|
||||
};
|
||||
use crate::audio::AudioFrontend;
|
||||
use client::Client;
|
||||
use vek::*;
|
||||
use specs::{Entity as EcsEntity, Join};
|
||||
use common::comp::{Body, CharacterState, MovementState::*, Ori, Pos};
|
||||
use hashbrown::HashMap;
|
||||
use std::{f32, time::Instant};
|
||||
use specs::{Entity as EcsEntity, Join};
|
||||
use std::time::Instant;
|
||||
use vek::*;
|
||||
|
||||
pub struct AnimState {
|
||||
last_step_sound: Instant,
|
||||
}
|
||||
|
||||
pub struct SoundMgr {
|
||||
character_states: HashMap<EcsEntity, AnimState>
|
||||
character_states: HashMap<EcsEntity, AnimState>,
|
||||
}
|
||||
|
||||
impl SoundMgr {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
character_states: HashMap::new(),
|
||||
character_states: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,12 +52,17 @@ impl SoundMgr {
|
||||
let state = self
|
||||
.character_states
|
||||
.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 state.last_step_sound.elapsed().as_secs_f64() > 0.25 {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user