Move local hit sound from kill to take_damage
This commit is contained in:
parent
927a904c72
commit
bea1b29bc7
@ -1125,14 +1125,6 @@ impl Game {
|
||||
.record_event(ReplayEvent::Death(source, player_id));
|
||||
}
|
||||
|
||||
if let DamageSource::Player(source_player_id) = source
|
||||
&& let Some(player) = self.find_player(source_player_id)
|
||||
&& let Some(character) = player.character.clone()
|
||||
&& let Ok(mut local_player) = character.try_cast::<LocalPlayer>()
|
||||
{
|
||||
local_player.bind_mut().play_local_hit_sound();
|
||||
}
|
||||
|
||||
let total_prev_kills: u16 = self.players.iter().map(|p| p.data.kills).sum();
|
||||
|
||||
if let Some(chat) = &mut Chat::singleton() {
|
||||
@ -1221,6 +1213,14 @@ impl Game {
|
||||
.record_event(ReplayEvent::TakeDamage(player_id, source, damage));
|
||||
}
|
||||
|
||||
if let DamageSource::Player(source_player_id) = source
|
||||
&& let Some(player) = self.find_player(source_player_id)
|
||||
&& let Some(character) = player.character.clone()
|
||||
&& let Ok(mut local_player) = character.try_cast::<LocalPlayer>()
|
||||
{
|
||||
local_player.bind_mut().play_local_hit_sound();
|
||||
}
|
||||
|
||||
if let Some(player) = self.find_player_mut(player_id) {
|
||||
if let Some(character) = &mut player.character {
|
||||
character.dyn_bind_mut().take_damage(source, damage, false);
|
||||
@ -1248,6 +1248,14 @@ impl Game {
|
||||
));
|
||||
}
|
||||
|
||||
if let DamageSource::Player(source_player_id) = source
|
||||
&& let Some(player) = self.find_player(source_player_id)
|
||||
&& let Some(character) = player.character.clone()
|
||||
&& let Ok(mut local_player) = character.try_cast::<LocalPlayer>()
|
||||
{
|
||||
local_player.bind_mut().play_local_hit_sound();
|
||||
}
|
||||
|
||||
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer {
|
||||
if let PeerKind::Server(peer, _) = peer {
|
||||
peer.broadcast_reliable(TakeDamage(source, target_player_id, damage));
|
||||
|
||||
@ -37,6 +37,12 @@ impl PlayerEffects {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hit(&mut self) {
|
||||
if let Some(sfx) = &mut self.hit_sound {
|
||||
sfx.play();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk(&mut self) {
|
||||
if self.walk_sfx_cd_remaining > 0. {
|
||||
return;
|
||||
|
||||
@ -238,6 +238,10 @@ impl IPlayer for LocalPlayer {
|
||||
s.health -= damage;
|
||||
if kill && s.health <= 0 {
|
||||
s.kill(source);
|
||||
} else {
|
||||
if let Some(effects) = &mut s.effects {
|
||||
effects.bind_mut().hit();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -180,6 +180,10 @@ impl IPlayer for RemotePlayer {
|
||||
s.health -= damage;
|
||||
if kill && s.health <= 0 {
|
||||
s.kill(source);
|
||||
} else {
|
||||
if let Some(effects) = &mut s.effects {
|
||||
effects.bind_mut().hit();
|
||||
}
|
||||
}
|
||||
}
|
||||
s.update_health_bar();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user