|
|
@ -174,6 +174,7 @@ impl CursorVfx for PointHighlight {
|
|
|
|
struct ParticleData {
|
|
|
|
struct ParticleData {
|
|
|
|
pos: Point,
|
|
|
|
pos: Point,
|
|
|
|
speed: Point,
|
|
|
|
speed: Point,
|
|
|
|
|
|
|
|
rotation_speed: f32,
|
|
|
|
lifetime: f32,
|
|
|
|
lifetime: f32,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -194,10 +195,11 @@ impl ParticleTrail {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn add_particle(&mut self, pos: Point, speed: Point, lifetime: f32) {
|
|
|
|
fn add_particle(&mut self, pos: Point, speed: Point, rotation_speed: f32, lifetime: f32) {
|
|
|
|
self.particles.push(ParticleData {
|
|
|
|
self.particles.push(ParticleData {
|
|
|
|
pos,
|
|
|
|
pos,
|
|
|
|
speed,
|
|
|
|
speed,
|
|
|
|
|
|
|
|
rotation_speed,
|
|
|
|
lifetime,
|
|
|
|
lifetime,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -215,7 +217,8 @@ impl CursorVfx for ParticleTrail {
|
|
|
|
settings: &CursorSettings,
|
|
|
|
settings: &CursorSettings,
|
|
|
|
current_cursor_dest: Point,
|
|
|
|
current_cursor_dest: Point,
|
|
|
|
font_size: (f32, f32),
|
|
|
|
font_size: (f32, f32),
|
|
|
|
dt: f32) -> bool {
|
|
|
|
dt: f32,
|
|
|
|
|
|
|
|
) -> bool {
|
|
|
|
// Update lifetimes and remove dead particles
|
|
|
|
// Update lifetimes and remove dead particles
|
|
|
|
let mut i = 0;
|
|
|
|
let mut i = 0;
|
|
|
|
while i < self.particles.len() {
|
|
|
|
while i < self.particles.len() {
|
|
|
@ -232,15 +235,18 @@ impl CursorVfx for ParticleTrail {
|
|
|
|
for i in 0..self.particles.len() {
|
|
|
|
for i in 0..self.particles.len() {
|
|
|
|
let particle = &mut self.particles[i];
|
|
|
|
let particle = &mut self.particles[i];
|
|
|
|
particle.pos += particle.speed * dt;
|
|
|
|
particle.pos += particle.speed * dt;
|
|
|
|
|
|
|
|
particle.speed = rotate_vec(particle.speed, dt * particle.rotation_speed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Spawn new particles
|
|
|
|
// Spawn new particles
|
|
|
|
if current_cursor_dest != self.previous_cursor_dest {
|
|
|
|
if current_cursor_dest != self.previous_cursor_dest {
|
|
|
|
let travel = current_cursor_dest - self.previous_cursor_dest;
|
|
|
|
let travel = current_cursor_dest - self.previous_cursor_dest;
|
|
|
|
let travel_distance = travel.length();
|
|
|
|
let travel_distance = travel.length();
|
|
|
|
|
|
|
|
|
|
|
|
// Increase amount of particles when cursor travels further
|
|
|
|
// Increase amount of particles when cursor travels further
|
|
|
|
let particle_count =
|
|
|
|
let particle_count = ((travel_distance / font_size.0).powf(1.5)
|
|
|
|
((travel_distance / font_size.0).powf(1.5) * settings.vfx_particle_density * 0.01) as usize;
|
|
|
|
* settings.vfx_particle_density
|
|
|
|
|
|
|
|
* 0.01) as usize;
|
|
|
|
|
|
|
|
|
|
|
|
let prev_p = self.previous_cursor_dest;
|
|
|
|
let prev_p = self.previous_cursor_dest;
|
|
|
|
|
|
|
|
|
|
|
@ -249,7 +255,9 @@ impl CursorVfx for ParticleTrail {
|
|
|
|
|
|
|
|
|
|
|
|
let speed = match self.trail_mode {
|
|
|
|
let speed = match self.trail_mode {
|
|
|
|
TrailMode::Railgun => {
|
|
|
|
TrailMode::Railgun => {
|
|
|
|
let phase = t / 3.141592 * settings.vfx_particle_phase * (travel_distance / font_size.0);
|
|
|
|
let phase = t / 3.141592
|
|
|
|
|
|
|
|
* settings.vfx_particle_phase
|
|
|
|
|
|
|
|
* (travel_distance / font_size.0);
|
|
|
|
Point::new(phase.sin(), phase.cos()) * 2.0 * settings.vfx_particle_speed
|
|
|
|
Point::new(phase.sin(), phase.cos()) * 2.0 * settings.vfx_particle_speed
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TrailMode::Torpedo => {
|
|
|
|
TrailMode::Torpedo => {
|
|
|
@ -274,7 +282,21 @@ impl CursorVfx for ParticleTrail {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
self.add_particle(pos, speed, t * settings.vfx_particle_lifetime);
|
|
|
|
let rotation_speed = match self.trail_mode {
|
|
|
|
|
|
|
|
TrailMode::Railgun => std::f32::consts::PI * settings.vfx_particle_curl,
|
|
|
|
|
|
|
|
TrailMode::PixieDust | TrailMode::Torpedo => {
|
|
|
|
|
|
|
|
(self.rng.next_f32() - 0.5)
|
|
|
|
|
|
|
|
* std::f32::consts::FRAC_PI_2
|
|
|
|
|
|
|
|
* settings.vfx_particle_curl
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.add_particle(
|
|
|
|
|
|
|
|
pos,
|
|
|
|
|
|
|
|
speed,
|
|
|
|
|
|
|
|
rotation_speed,
|
|
|
|
|
|
|
|
t * settings.vfx_particle_lifetime,
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
self.previous_cursor_dest = current_cursor_dest;
|
|
|
|
self.previous_cursor_dest = current_cursor_dest;
|
|
|
@ -401,3 +423,10 @@ impl RngState {
|
|
|
|
v
|
|
|
|
v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn rotate_vec(v: Point, rot: f32) -> Point {
|
|
|
|
|
|
|
|
let sin = rot.sin();
|
|
|
|
|
|
|
|
let cos = rot.cos();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Point::new(v.x * cos - v.y * sin, v.x * sin + v.y * cos)
|
|
|
|
|
|
|
|
}
|
|
|
|