From be2f8ac6b8f393d0e60e0042ba2ed19ebf62849c Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 5 Mar 2021 18:17:08 -0500 Subject: [PATCH] Aura particles. --- .../common/abilities/sceptre/wardingaura.ron | 2 +- assets/voxygen/shaders/particle-vert.glsl | 16 +++---- voxygen/src/scene/particle.rs | 48 ++++++++++++++++++- 3 files changed, 56 insertions(+), 10 deletions(-) diff --git a/assets/common/abilities/sceptre/wardingaura.ron b/assets/common/abilities/sceptre/wardingaura.ron index cdebac58e2..e9d21c0c41 100644 --- a/assets/common/abilities/sceptre/wardingaura.ron +++ b/assets/common/abilities/sceptre/wardingaura.ron @@ -10,5 +10,5 @@ CastAura( category: Magical, ), range: 25.0, - energy_cost: 400, + energy_cost: 00, ) \ No newline at end of file diff --git a/assets/voxygen/shaders/particle-vert.glsl b/assets/voxygen/shaders/particle-vert.glsl index e3bddc5483..a7b6dfcd3a 100644 --- a/assets/voxygen/shaders/particle-vert.glsl +++ b/assets/voxygen/shaders/particle-vert.glsl @@ -342,22 +342,22 @@ void main() { spin_in_axis(inst_dir, tick.z) ); } else if (inst_mode == LIFESTEAL_BEAM) { - f_reflect = 0.01; - float green_col = 0.8 + 1.0 * sin(tick.x * 5 + lifetime * 5); - float purple_col = 1.1 + 0.15 * sin(tick.x * 3 - lifetime * 3) - max(green_col, 1) + 1; + f_reflect = 0.0; + float green_col = 0.2 + 1.4 * sin(tick.x * 5 + lifetime * 5); + float purple_col = 1.2 + 0.1 * sin(tick.x * 3 - lifetime * 3) - max(green_col, 1) + 1; attr = Attr( spiral_motion(inst_dir, 0.3 * (floor(2 * rand0 + 0.5) - 0.5) * min(linear_scale(10), 1), lifetime / inst_lifespan, 10.0, inst_time), vec3((1.7 - 0.7 * abs(floor(2 * rand0 - 0.5) + 0.5)) * (1.5 + 0.5 * sin(tick.x * 10 - lifetime * 4))), - vec4(vec3(purple_col, green_col, purple_col), 1 /*0.3*/), + vec4(vec3(purple_col, green_col, 0.75 * purple_col), 1), spin_in_axis(inst_dir, tick.z) ); } else if (inst_mode == ENERGY_NATURE) { f_reflect = 0.0; + float spiral_radius = start_end(1 - pow(abs(rand5), 5), 1) * length(inst_dir); attr = Attr( - inst_dir * slow_end(0.03) + spiral_motion(vec3(rand1, rand2, rand3), - 0.2 * (rand4 + 1.3) * slow_end(0.02), percent() * 3 * (rand4 + 4.0) + rand0, 1.0, 0.0), - vec3(1.0), - vec4(vec3(0, 2.5, 1.5 + rand7 * 0.7), 1), + spiral_motion(vec3(0, 0, rand3 + 1), spiral_radius, lifetime, abs(rand0), rand1 * 2 * PI) + vec3(0, 0, rand2), + vec3(6 * abs(rand4) * (1 - slow_start(2)) * pow(spiral_radius / length(inst_dir), 0.5)), + vec4(vec3(0, 1.7, 1.3), 1), spin_in_axis(vec3(rand6, rand7, rand8), rand9 * 3) ); } else if (inst_mode == FLAMETHROWER) { diff --git a/voxygen/src/scene/particle.rs b/voxygen/src/scene/particle.rs index 99d73c25a2..521331c2c1 100644 --- a/voxygen/src/scene/particle.rs +++ b/voxygen/src/scene/particle.rs @@ -8,7 +8,10 @@ use crate::{ }; use common::{ assets::{AssetExt, DotVoxAsset}, - comp::{beam, item::Reagent, object, BeamSegment, Body, CharacterState, Ori, Pos, Shockwave}, + comp::{ + self, aura, beam, buff, item::Reagent, object, BeamSegment, Body, CharacterState, Ori, Pos, + Shockwave, + }, figure::Segment, outcome::Outcome, resources::DeltaTime, @@ -179,6 +182,7 @@ impl ParticleMgr { self.maintain_beam_particles(scene_data, lights); self.maintain_block_particles(scene_data, terrain); self.maintain_shockwave_particles(scene_data); + self.maintain_aura_particles(scene_data); } else { // remove all particle lifespans self.particles.clear(); @@ -468,6 +472,48 @@ impl ParticleMgr { } } + fn maintain_aura_particles(&mut self, scene_data: &SceneData) { + let state = scene_data.state; + let ecs = state.ecs(); + let time = state.get_time(); + + for (pos, auras) in ( + &ecs.read_storage::(), + &ecs.read_storage::(), + ) + .join() + { + for (_, aura) in auras.auras.iter() { + #[allow(clippy::single_match)] + match aura.aura_kind { + aura::AuraKind::Buff { + kind: buff::BuffKind::ProtectingWard, + .. + } => { + let mut rng = thread_rng(); + let heartbeats = self.scheduler.heartbeats(Duration::from_millis(5)); + self.particles.resize_with( + self.particles.len() + + aura.radius.powi(2) as usize * usize::from(heartbeats) / 300, + || { + let rand_dist = aura.radius * (1.0 - rng.gen::().powi(100)); + let init_pos = Vec3::new(rand_dist, 0_f32, 0_f32); + Particle::new_directed( + aura.duration.unwrap_or_else(|| Duration::from_secs(1)), + time, + ParticleMode::EnergyNature, + pos.0, + pos.0 + init_pos, + ) + }, + ); + }, + _ => {}, + } + } + } + } + #[allow(clippy::same_item_push)] // TODO: Pending review in #587 fn maintain_block_particles( &mut self,