mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix projectile explosion being triggered twice.
This commit is contained in:
parent
bf07947a6d
commit
5c8fc4f378
@ -58,7 +58,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
let mut server_emitter = server_bus.emitter();
|
let mut server_emitter = server_bus.emitter();
|
||||||
|
|
||||||
// Attacks
|
// Attacks
|
||||||
for (entity, pos, physics, ori, mut projectile) in (
|
'projectile_loop: for (entity, pos, physics, ori, mut projectile) in (
|
||||||
&entities,
|
&entities,
|
||||||
&positions,
|
&positions,
|
||||||
&physics_states,
|
&physics_states,
|
||||||
@ -67,6 +67,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
)
|
)
|
||||||
.join()
|
.join()
|
||||||
{
|
{
|
||||||
|
let mut projectile_vanished: bool = false;
|
||||||
// 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
|
||||||
@ -160,10 +161,13 @@ impl<'a> System<'a> for Sys {
|
|||||||
reagent: None,
|
reagent: None,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
projectile::Effect::Vanish => server_emitter.emit(ServerEvent::Destroy {
|
projectile::Effect::Vanish => {
|
||||||
entity,
|
server_emitter.emit(ServerEvent::Destroy {
|
||||||
cause: HealthSource::World,
|
entity,
|
||||||
}),
|
cause: HealthSource::World,
|
||||||
|
});
|
||||||
|
projectile_vanished = true;
|
||||||
|
},
|
||||||
projectile::Effect::Possess => {
|
projectile::Effect::Possess => {
|
||||||
if other != projectile.owner.unwrap() {
|
if other != projectile.owner.unwrap() {
|
||||||
if let Some(owner) = projectile.owner {
|
if let Some(owner) = projectile.owner {
|
||||||
@ -194,6 +198,10 @@ impl<'a> System<'a> for Sys {
|
|||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if projectile_vanished {
|
||||||
|
continue 'projectile_loop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hit something solid
|
// Hit something solid
|
||||||
@ -209,13 +217,20 @@ impl<'a> System<'a> for Sys {
|
|||||||
reagent: None,
|
reagent: None,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
projectile::Effect::Vanish => server_emitter.emit(ServerEvent::Destroy {
|
projectile::Effect::Vanish => {
|
||||||
entity,
|
server_emitter.emit(ServerEvent::Destroy {
|
||||||
cause: HealthSource::World,
|
entity,
|
||||||
}),
|
cause: HealthSource::World,
|
||||||
|
});
|
||||||
|
projectile_vanished = true;
|
||||||
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if projectile_vanished {
|
||||||
|
continue 'projectile_loop;
|
||||||
|
}
|
||||||
} else if let Some(dir) = velocities
|
} else if let Some(dir) = velocities
|
||||||
.get(entity)
|
.get(entity)
|
||||||
.and_then(|vel| vel.0.try_normalized())
|
.and_then(|vel| vel.0.try_normalized())
|
||||||
|
Loading…
Reference in New Issue
Block a user