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)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct Projectile {
|
pub struct Projectile {
|
||||||
pub hit_ground: Vec<Effect>,
|
pub hit_ground: Vec<Effect>,
|
||||||
|
pub hit_wall: Vec<Effect>,
|
||||||
pub hit_entity: Vec<Effect>,
|
pub hit_entity: Vec<Effect>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +145,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
dir: controller.look_dir,
|
dir: controller.look_dir,
|
||||||
projectile: Projectile {
|
projectile: Projectile {
|
||||||
hit_ground: vec![projectile::Effect::Stick],
|
hit_ground: vec![projectile::Effect::Stick],
|
||||||
|
hit_wall: vec![projectile::Effect::Stick],
|
||||||
hit_entity: vec![
|
hit_entity: vec![
|
||||||
projectile::Effect::Damage(10),
|
projectile::Effect::Damage(10),
|
||||||
projectile::Effect::Vanish,
|
projectile::Effect::Vanish,
|
||||||
|
@ -38,10 +38,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
)
|
)
|
||||||
.join()
|
.join()
|
||||||
{
|
{
|
||||||
if let Some(vel) = velocities.get(entity) {
|
|
||||||
ori.0 = vel.0.normalized();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hit ground
|
// Hit ground
|
||||||
if physics.on_ground {
|
if physics.on_ground {
|
||||||
for effect in projectile.hit_ground.drain(..) {
|
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
|
// Hit entity
|
||||||
if let Some(other) = physics.touch_entity {
|
if let Some(other) = physics.touch_entity {
|
||||||
for effect in projectile.hit_entity.drain(..) {
|
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