Merge branch 'master' into 'master'

Fixes #819 - Prevent lantern from turning off on death

Closes #819

See merge request veloren/veloren!2955
This commit is contained in:
Forest Anderson 2021-10-24 21:16:34 +00:00
commit 15185ef55e
2 changed files with 4 additions and 6 deletions

View File

@ -322,10 +322,6 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, last_change: Healt
.insert(entity, comp::ForceUpdate)
.err()
.map(|e| error!(?e, ?entity, "Failed to insert ForceUpdate on dead client"));
state
.ecs()
.write_storage::<comp::LightEmitter>()
.remove(entity);
state
.ecs()
.write_storage::<comp::Energy>()

View File

@ -560,15 +560,17 @@ impl Scene {
.state
.ecs()
.read_storage::<comp::LightAnimation>(),
&scene_data.state.ecs().read_storage::<comp::Health>(),
)
.join()
.filter(|(pos, _, light_anim)| {
.filter(|(pos, _, light_anim, h)| {
light_anim.col != Rgb::zero()
&& light_anim.strength > 0.0
&& (pos.0.distance_squared(player_pos) as f32)
< loaded_distance.powi(2) + LIGHT_DIST_RADIUS
&& !h.is_dead
})
.map(|(pos, interpolated, light_anim)| {
.map(|(pos, interpolated, light_anim, _)| {
// Use interpolated values if they are available
let pos = interpolated.map_or(pos.0, |i| i.pos);
Light::new(pos + light_anim.offset, light_anim.col, light_anim.strength)