mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
feat(bow): make arrows stick to walls
This commit is contained in:
parent
469349a426
commit
ba3db852f7
@ -11,6 +11,7 @@ pub enum Effect {
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct Projectile {
|
||||
pub hit_ground: Vec<Effect>,
|
||||
pub hit_wall: Vec<Effect>,
|
||||
pub hit_entity: Vec<Effect>,
|
||||
}
|
||||
|
||||
|
@ -145,6 +145,7 @@ impl<'a> System<'a> for Sys {
|
||||
dir: controller.look_dir,
|
||||
projectile: Projectile {
|
||||
hit_ground: vec![projectile::Effect::Stick],
|
||||
hit_wall: vec![projectile::Effect::Stick],
|
||||
hit_entity: vec![
|
||||
projectile::Effect::Damage(10),
|
||||
projectile::Effect::Vanish,
|
||||
|
@ -38,10 +38,6 @@ impl<'a> System<'a> for Sys {
|
||||
)
|
||||
.join()
|
||||
{
|
||||
if let Some(vel) = velocities.get(entity) {
|
||||
ori.0 = vel.0.normalized();
|
||||
}
|
||||
|
||||
// Hit ground
|
||||
if physics.on_ground {
|
||||
for effect in projectile.hit_ground.drain(..) {
|
||||
@ -53,6 +49,17 @@ impl<'a> System<'a> for Sys {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Hit wall
|
||||
if physics.on_wall.is_some() {
|
||||
for effect in projectile.hit_wall.drain(..) {
|
||||
match effect {
|
||||
projectile::Effect::Stick => {
|
||||
velocities.remove(entity);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Hit entity
|
||||
if let Some(other) = physics.touch_entity {
|
||||
for effect in projectile.hit_entity.drain(..) {
|
||||
@ -72,6 +79,10 @@ impl<'a> System<'a> for Sys {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(vel) = velocities.get(entity) {
|
||||
ori.0 = vel.0.normalized();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user