mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Correct the usage of owners in sound emissions
This commit is contained in:
parent
9828043a84
commit
cf25955eb3
@ -91,10 +91,14 @@ impl<'a> System<'a> for Sys {
|
|||||||
};
|
};
|
||||||
let end_time = creation_time + beam_segment.duration.as_secs_f64();
|
let end_time = creation_time + beam_segment.duration.as_secs_f64();
|
||||||
|
|
||||||
|
let beam_owner = beam_segment
|
||||||
|
.owner
|
||||||
|
.and_then(|uid| read_data.uid_allocator.retrieve_entity_internal(uid.into()));
|
||||||
|
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
if rng.gen_bool(0.005) {
|
if rng.gen_bool(0.005) {
|
||||||
server_events.push(ServerEvent::Sound {
|
server_events.push(ServerEvent::Sound {
|
||||||
sound: Sound::new(SoundKind::Beam, pos.0, 7.0, time, Some(entity)),
|
sound: Sound::new(SoundKind::Beam, pos.0, 7.0, time, beam_owner),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,10 +123,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
(beam_segment.speed * (time_since_creation - frame_time)).max(0.0);
|
(beam_segment.speed * (time_since_creation - frame_time)).max(0.0);
|
||||||
let frame_end_dist = (beam_segment.speed * time_since_creation).max(frame_start_dist);
|
let frame_end_dist = (beam_segment.speed * time_since_creation).max(frame_start_dist);
|
||||||
|
|
||||||
let beam_owner = beam_segment
|
|
||||||
.owner
|
|
||||||
.and_then(|uid| read_data.uid_allocator.retrieve_entity_internal(uid.into()));
|
|
||||||
|
|
||||||
// Group to ignore collisions with
|
// Group to ignore collisions with
|
||||||
// Might make this more nuanced if beams are used for non damage effects
|
// Might make this more nuanced if beams are used for non damage effects
|
||||||
let group = beam_owner.and_then(|e| read_data.groups.get(e));
|
let group = beam_owner.and_then(|e| read_data.groups.get(e));
|
||||||
|
@ -72,6 +72,10 @@ impl<'a> System<'a> for Sys {
|
|||||||
)
|
)
|
||||||
.join()
|
.join()
|
||||||
{
|
{
|
||||||
|
let projectile_owner = projectile
|
||||||
|
.owner
|
||||||
|
.and_then(|uid| read_data.uid_allocator.retrieve_entity_internal(uid.into()));
|
||||||
|
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
if physics.on_surface().is_none() && rng.gen_bool(0.05) {
|
if physics.on_surface().is_none() && rng.gen_bool(0.05) {
|
||||||
server_emitter.emit(ServerEvent::Sound {
|
server_emitter.emit(ServerEvent::Sound {
|
||||||
@ -89,12 +93,10 @@ impl<'a> System<'a> for Sys {
|
|||||||
|
|
||||||
// Hit entity
|
// Hit entity
|
||||||
for other in physics.touch_entities.iter().copied() {
|
for other in physics.touch_entities.iter().copied() {
|
||||||
let same_group = projectile
|
let same_group = projectile_owner
|
||||||
.owner
|
|
||||||
// Note: somewhat inefficient since we do the lookup for every touching
|
// Note: somewhat inefficient since we do the lookup for every touching
|
||||||
// entity, but if we pull this out of the loop we would want to do it only
|
// entity, but if we pull this out of the loop we would want to do it only
|
||||||
// if there is at least one touching entity
|
// if there is at least one touching entity
|
||||||
.and_then(|uid| read_data.uid_allocator.retrieve_entity_internal(uid.into()))
|
|
||||||
.and_then(|e| read_data.groups.get(e))
|
.and_then(|e| read_data.groups.get(e))
|
||||||
.map_or(false, |owner_group|
|
.map_or(false, |owner_group|
|
||||||
Some(owner_group) == read_data.uid_allocator
|
Some(owner_group) == read_data.uid_allocator
|
||||||
|
@ -85,10 +85,14 @@ impl<'a> System<'a> for Sys {
|
|||||||
|
|
||||||
let end_time = creation_time + shockwave.duration.as_secs_f64();
|
let end_time = creation_time + shockwave.duration.as_secs_f64();
|
||||||
|
|
||||||
|
let shockwave_owner = shockwave
|
||||||
|
.owner
|
||||||
|
.and_then(|uid| read_data.uid_allocator.retrieve_entity_internal(uid.into()));
|
||||||
|
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
if rng.gen_bool(0.05) {
|
if rng.gen_bool(0.05) {
|
||||||
server_emitter.emit(ServerEvent::Sound {
|
server_emitter.emit(ServerEvent::Sound {
|
||||||
sound: Sound::new(SoundKind::Shockwave, pos.0, 16.0, time, Some(entity)),
|
sound: Sound::new(SoundKind::Shockwave, pos.0, 16.0, time, shockwave_owner),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,10 +124,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
end: frame_end_dist,
|
end: frame_end_dist,
|
||||||
};
|
};
|
||||||
|
|
||||||
let shockwave_owner = shockwave
|
|
||||||
.owner
|
|
||||||
.and_then(|uid| read_data.uid_allocator.retrieve_entity_internal(uid.into()));
|
|
||||||
|
|
||||||
// Group to ignore collisions with
|
// Group to ignore collisions with
|
||||||
// Might make this more nuanced if shockwaves are used for non damage effects
|
// Might make this more nuanced if shockwaves are used for non damage effects
|
||||||
let group = shockwave_owner.and_then(|e| read_data.groups.get(e));
|
let group = shockwave_owner.and_then(|e| read_data.groups.get(e));
|
||||||
|
Loading…
Reference in New Issue
Block a user