Remove player shadow on death

This commit is contained in:
Vechro 2019-09-25 18:17:54 +03:00 committed by Joshua Barretto
parent f57c2ec453
commit deec1e6bca

View File

@ -219,13 +219,16 @@ impl Scene {
let mut shadows = ( let mut shadows = (
&client.state().ecs().read_storage::<comp::Pos>(), &client.state().ecs().read_storage::<comp::Pos>(),
client.state().ecs().read_storage::<comp::Scale>().maybe(), client.state().ecs().read_storage::<comp::Scale>().maybe(),
&client.state().ecs().read_storage::<comp::Body>(),
&client.state().ecs().read_storage::<comp::Stats>(),
) )
.join() .join()
.filter(|(pos, _)| { .filter(|(_, _, _, stats)| !stats.is_dead)
.filter(|(pos, _, _, _)| {
(pos.0.distance_squared(player_pos) as f32) (pos.0.distance_squared(player_pos) as f32)
< (self.loaded_distance.min(SHADOW_MAX_DIST) + SHADOW_DIST_RADIUS).powf(2.0) < (self.loaded_distance.min(SHADOW_MAX_DIST) + SHADOW_DIST_RADIUS).powf(2.0)
}) })
.map(|(pos, scale)| Shadow::new(pos.0, scale.map(|s| s.0).unwrap_or(1.0))) .map(|(pos, scale, _, _)| Shadow::new(pos.0, scale.map(|s| s.0).unwrap_or(1.0)))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
shadows.sort_by_key(|shadow| shadow.get_pos().distance_squared(player_pos) as i32); shadows.sort_by_key(|shadow| shadow.get_pos().distance_squared(player_pos) as i32);
shadows.truncate(MAX_SHADOW_COUNT); shadows.truncate(MAX_SHADOW_COUNT);