Ground shockwave particle tweaks.

This commit is contained in:
Sam 2022-02-10 22:40:26 -05:00
parent 95ea7a47e0
commit 377906dfa0
2 changed files with 31 additions and 10 deletions

View File

@ -109,7 +109,7 @@ pub trait ReadVol: BaseVol {
where where
Self: Sized, Self: Sized,
{ {
Ray::new(self, from, to, |_| true) Ray::new(self, from, to, |_| false)
} }
/// Call provided closure with each block in the supplied Aabb /// Call provided closure with each block in the supplied Aabb

View File

@ -17,8 +17,8 @@ use common::{
resources::DeltaTime, resources::DeltaTime,
spiral::Spiral2d, spiral::Spiral2d,
states::{self, utils::StageSection}, states::{self, utils::StageSection},
terrain::TerrainChunk, terrain::{Block, TerrainChunk, TerrainGrid},
vol::{RectRasterableVol, SizedVol}, vol::{ReadVol, RectRasterableVol, SizedVol},
}; };
use common_base::span; use common_base::span;
use hashbrown::HashMap; use hashbrown::HashMap;
@ -1262,6 +1262,7 @@ impl ParticleMgr {
let ecs = state.ecs(); let ecs = state.ecs();
let time = state.get_time(); let time = state.get_time();
let dt = scene_data.state.ecs().fetch::<DeltaTime>().0; let dt = scene_data.state.ecs().fetch::<DeltaTime>().0;
let terrain = scene_data.state.ecs().fetch::<TerrainGrid>();
for (_entity, pos, ori, shockwave) in ( for (_entity, pos, ori, shockwave) in (
&ecs.entities(), &ecs.entities(),
@ -1312,14 +1313,34 @@ impl ParticleMgr {
let position = pos.0 let position = pos.0
+ distance * Vec3::new(arc_position.cos(), arc_position.sin(), 0.0); + distance * Vec3::new(arc_position.cos(), arc_position.sin(), 0.0);
let position_snapped = ((position / scale).floor() + 0.5) * scale; let ray_length = 10.0;
let mut last_air = false;
let _ = terrain
.ray(
position + Vec3::unit_z() * ray_length,
position - Vec3::unit_z() * ray_length,
)
.for_each(|block: &Block, pos: Vec3<i32>| {
if block.is_solid() && block.get_sprite().is_none() {
if last_air {
let position = position.xy().with_z(pos.z as f32 + 1.0);
self.particles.push(Particle::new( let position_snapped =
Duration::from_millis(250), ((position / scale).floor() + 0.5) * scale;
time,
ParticleMode::GroundShockwave, self.particles.push(Particle::new(
position_snapped, Duration::from_millis(250),
)); time,
ParticleMode::GroundShockwave,
position_snapped,
));
last_air = false;
}
} else {
last_air = true;
}
})
.cast();
} }
} }
}, },