mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed crash from changes in explosion code.
This commit is contained in:
parent
a0af315930
commit
f69f494524
@ -615,12 +615,7 @@ pub fn handle_explosion(
|
||||
}
|
||||
},
|
||||
RadiusEffect::Entity(target, mut effect) => {
|
||||
for (entity_b, pos_b, health_b) in (
|
||||
&ecs.entities(),
|
||||
&ecs.read_storage::<comp::Pos>(),
|
||||
&ecs.read_storage::<comp::Health>(),
|
||||
)
|
||||
.join()
|
||||
for (entity_b, pos_b) in (&ecs.entities(), &ecs.read_storage::<comp::Pos>()).join()
|
||||
{
|
||||
// See if entities are in the same group
|
||||
let mut same_group = owner_entity
|
||||
@ -646,12 +641,19 @@ pub fn handle_explosion(
|
||||
let distance_squared = pos.distance_squared(pos_b.0);
|
||||
let strength = 1.0 - distance_squared / explosion.radius.powi(2);
|
||||
|
||||
if strength > 0.0 && !health_b.is_dead {
|
||||
if strength > 0.0 {
|
||||
let is_alive = ecs
|
||||
.read_storage::<comp::Health>()
|
||||
.get(entity_b)
|
||||
.map_or(false, |h| !h.is_dead);
|
||||
|
||||
if is_alive {
|
||||
effect.modify_strength(strength);
|
||||
server.state().apply_effect(entity_b, effect, owner);
|
||||
// Apply energy change
|
||||
if let Some(owner) = owner_entity {
|
||||
if let Some(energy) = ecs.write_storage::<comp::Energy>().get_mut(owner)
|
||||
if let Some(energy) =
|
||||
ecs.write_storage::<comp::Energy>().get_mut(owner)
|
||||
{
|
||||
energy.change_by(EnergyChange {
|
||||
amount: explosion.energy_regen as i32,
|
||||
@ -661,6 +663,7 @@ pub fn handle_explosion(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user