mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Refactored SoundKind and UtteranceKind
This commit is contained in:
parent
045621993a
commit
c631341da9
@ -327,8 +327,6 @@ pub enum SoundKind {
|
||||
Beam,
|
||||
Shockwave,
|
||||
Utterance(UtteranceKind, Body),
|
||||
// TODO: unify VillagerAlarm with Utterance
|
||||
VillagerAlarm,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
@ -104,6 +104,7 @@ pub enum UtteranceKind {
|
||||
Surprised,
|
||||
Hurt,
|
||||
Greeting,
|
||||
Scream,
|
||||
/* Death,
|
||||
* TODO: Wait for more post-death features (i.e. animiations) before implementing death
|
||||
* sounds */
|
||||
|
@ -716,7 +716,7 @@ impl<'a> AgentData<'a> {
|
||||
// Should the agent flee?
|
||||
if agent.action_state.timer == 0.0 && can_speak(agent) {
|
||||
self.chat_general("npc.speech.villager_under_attack", event_emitter);
|
||||
self.emit_villager_alarm(read_data.time.0, event_emitter);
|
||||
self.emit_alarm(read_data.time.0, event_emitter);
|
||||
agent.action_state.timer = 0.01;
|
||||
} else if agent.action_state.timer < FLEE_DURATION
|
||||
|| dist_sq < MAX_FLEE_DIST.powi(2)
|
||||
@ -4355,11 +4355,13 @@ impl<'a> AgentData<'a> {
|
||||
)));
|
||||
}
|
||||
|
||||
fn emit_villager_alarm(&self, time: f64, event_emitter: &mut Emitter<'_, ServerEvent>) {
|
||||
fn emit_alarm(&self, time: f64, event_emitter: &mut Emitter<'_, ServerEvent>) {
|
||||
if let Some(body) = self.body {
|
||||
event_emitter.emit(ServerEvent::Sound {
|
||||
sound: Sound::new(SoundKind::VillagerAlarm, self.pos.0, 100.0, time),
|
||||
sound: Sound::new(SoundKind::Utterance(UtteranceKind::Scream, *body), self.pos.0, 100.0, time),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn rtsim_new_enemy(target_name: &str, agent: &mut Agent, read_data: &ReadData) {
|
||||
|
Loading…
Reference in New Issue
Block a user