2019-10-17 16:04:43 -06:00
|
|
|
package dev.esophose.playerparticles.styles;
|
2016-09-10 21:13:13 -07:00
|
|
|
|
2019-12-12 19:32:53 -07:00
|
|
|
import dev.esophose.playerparticles.particles.PParticle;
|
2020-01-05 17:26:45 -07:00
|
|
|
import dev.esophose.playerparticles.particles.ParticlePair;
|
2018-09-23 20:42:52 -06:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2016-09-10 21:13:13 -07:00
|
|
|
import org.bukkit.Location;
|
|
|
|
|
|
|
|
public class ParticleStyleOrbit implements ParticleStyle {
|
|
|
|
|
2018-10-13 16:38:01 -06:00
|
|
|
private static double[] cos, sin;
|
|
|
|
private static final int orbs = 3;
|
|
|
|
private static final int numSteps = 120;
|
2018-09-27 02:42:41 -06:00
|
|
|
private int step = 0;
|
2018-10-13 16:38:01 -06:00
|
|
|
|
|
|
|
static {
|
|
|
|
cos = new double[120];
|
|
|
|
sin = new double[120];
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
for (double n = 0; n < numSteps; n++) {
|
|
|
|
cos[i] = -Math.cos(n / numSteps * Math.PI * 2);
|
|
|
|
sin[i] = -Math.sin(n / numSteps * Math.PI * 2);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2018-02-25 21:24:22 -07:00
|
|
|
|
2018-09-23 20:42:52 -06:00
|
|
|
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
2019-12-12 19:32:53 -07:00
|
|
|
List<PParticle> particles = new ArrayList<>();
|
2018-02-25 21:24:22 -07:00
|
|
|
for (int i = 0; i < orbs; i++) {
|
2018-10-13 16:38:01 -06:00
|
|
|
double dx = cos[(step + (numSteps / orbs * i)) % numSteps];
|
|
|
|
double dz = sin[(step + (numSteps / orbs * i)) % numSteps];
|
|
|
|
particles.add(new PParticle(location.clone().add(dx, 0, dz)));
|
2018-02-25 21:24:22 -07:00
|
|
|
}
|
|
|
|
return particles;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateTimers() {
|
|
|
|
step++;
|
2018-10-13 16:38:01 -06:00
|
|
|
if (step > numSteps) {
|
2018-02-25 21:24:22 -07:00
|
|
|
step = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
return "orbit";
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canBeFixed() {
|
|
|
|
return true;
|
|
|
|
}
|
2018-11-16 03:26:08 -07:00
|
|
|
|
|
|
|
public boolean canToggleWithMovement() {
|
|
|
|
return true;
|
|
|
|
}
|
2018-12-01 19:34:01 -07:00
|
|
|
|
|
|
|
public double getFixedEffectOffset() {
|
|
|
|
return 0;
|
|
|
|
}
|
2016-09-10 21:13:13 -07:00
|
|
|
|
|
|
|
}
|