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;
|
2020-05-11 13:04:11 -06:00
|
|
|
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
|
2020-01-14 13:47:01 -07:00
|
|
|
import dev.esophose.playerparticles.util.MathL;
|
2018-09-23 20:42:52 -06:00
|
|
|
import java.util.ArrayList;
|
2020-06-13 13:07:47 -06:00
|
|
|
import java.util.Arrays;
|
2018-09-23 20:42:52 -06:00
|
|
|
import java.util.List;
|
2016-09-10 21:13:13 -07:00
|
|
|
import org.bukkit.Location;
|
|
|
|
|
2020-01-10 05:05:22 -07:00
|
|
|
public class ParticleStyleQuadhelix extends DefaultParticleStyle {
|
2016-09-10 21:13:13 -07:00
|
|
|
|
2018-09-27 02:42:41 -06:00
|
|
|
private int stepX = 0;
|
|
|
|
private int stepY = 0;
|
2018-02-25 21:24:22 -07:00
|
|
|
private boolean reverse = false;
|
|
|
|
|
2020-01-16 19:09:11 -07:00
|
|
|
private int orbs;
|
|
|
|
private int maxStepX;
|
|
|
|
private int maxStepY;
|
|
|
|
|
2020-01-10 05:05:22 -07:00
|
|
|
public ParticleStyleQuadhelix() {
|
|
|
|
super("quadhelix", true, true, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
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<>();
|
2020-01-16 19:09:11 -07:00
|
|
|
for (int i = 0; i < this.orbs; i++) {
|
|
|
|
double dx = -(MathL.cos((this.stepX / (double) this.maxStepX) * (Math.PI * 2) + (((Math.PI * 2) / this.orbs) * i))) * ((this.maxStepY - Math.abs(this.stepY)) / (double) this.maxStepY);
|
|
|
|
double dy = (this.stepY / (double) this.maxStepY) * 1.5;
|
|
|
|
double dz = -(MathL.sin((this.stepX / (double) this.maxStepX) * (Math.PI * 2) + (((Math.PI * 2) / this.orbs) * i))) * ((this.maxStepY - Math.abs(this.stepY)) / (double) this.maxStepY);
|
2018-10-06 21:41:39 -06:00
|
|
|
particles.add(new PParticle(location.clone().add(dx, dy, dz)));
|
2018-02-25 21:24:22 -07:00
|
|
|
}
|
|
|
|
return particles;
|
|
|
|
}
|
|
|
|
|
2020-01-10 05:05:22 -07:00
|
|
|
@Override
|
2018-02-25 21:24:22 -07:00
|
|
|
public void updateTimers() {
|
2020-01-14 13:37:22 -07:00
|
|
|
this.stepX++;
|
2020-01-16 19:09:11 -07:00
|
|
|
if (this.stepX > this.maxStepX) {
|
2020-01-14 13:37:22 -07:00
|
|
|
this.stepX = 0;
|
2018-02-25 21:24:22 -07:00
|
|
|
}
|
2020-01-14 13:37:22 -07:00
|
|
|
if (this.reverse) {
|
|
|
|
this.stepY++;
|
2020-01-16 19:09:11 -07:00
|
|
|
if (this.stepY > this.maxStepY)
|
2020-01-14 13:37:22 -07:00
|
|
|
this.reverse = false;
|
2018-02-25 21:24:22 -07:00
|
|
|
} else {
|
2020-01-14 13:37:22 -07:00
|
|
|
this.stepY--;
|
2020-01-16 19:09:11 -07:00
|
|
|
if (this.stepY < -this.maxStepY)
|
2020-01-14 13:37:22 -07:00
|
|
|
this.reverse = true;
|
2018-02-25 21:24:22 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-13 13:07:47 -06:00
|
|
|
@Override
|
|
|
|
protected List<String> getGuiIconMaterialNames() {
|
|
|
|
return Arrays.asList("NAUTILUS_SHELL", "ACTIVATOR_RAIL");
|
|
|
|
}
|
|
|
|
|
2020-01-10 05:05:22 -07:00
|
|
|
@Override
|
|
|
|
protected void setDefaultSettings(CommentedFileConfiguration config) {
|
2020-01-16 19:09:11 -07:00
|
|
|
this.setIfNotExists("orbs", 4, "The number of orbs to spawn");
|
|
|
|
this.setIfNotExists("steps-x", 80, "The number of steps for the x-axis");
|
|
|
|
this.setIfNotExists("steps-y", 60, "The number of steps for the y-axis");
|
2018-11-16 03:26:08 -07:00
|
|
|
}
|
2020-01-10 05:05:22 -07:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void loadSettings(CommentedFileConfiguration config) {
|
2020-01-16 19:09:11 -07:00
|
|
|
this.orbs = config.getInt("orbs");
|
|
|
|
this.maxStepX = config.getInt("steps-x");
|
|
|
|
this.maxStepY = config.getInt("steps-y");
|
2018-12-01 19:34:01 -07:00
|
|
|
}
|
2016-09-10 21:13:13 -07:00
|
|
|
|
|
|
|
}
|