package de.steamwar.lobby.particle.elements;

import de.steamwar.lobby.particle.ParticleElement;
import de.steamwar.lobby.particle.ParticleTickData;
import org.bukkit.Location;
import org.bukkit.Particle;

public class DustParticle implements ParticleElement {

    private Particle particle;
    private float vx = 0.01f;
    private float vy = 0.01f;
    private float vz = 0.01f;
    private double speed = 0.01;
    private int count = 5;

    public DustParticle(Particle particle) {
        this.particle = particle;
    }

    public DustParticle(Particle particle, float vx, float vy, float vz) {
        this.particle = particle;
        this.vx = vx;
        this.vy = vy;
        this.vz = vz;
    }

    public DustParticle(Particle particle, float vx, float vy, float vz, double speed, int count) {
        this.particle = particle;
        this.vx = vx;
        this.vy = vy;
        this.vz = vz;
        this.speed = speed;
        this.count = count;
    }

    @Override
    public void tick(ParticleTickData particleTickData) {
        Location location = particleTickData.getLocation().add(0.0, 0.2, 0.0);
        display(location, particleTickData.getPlayer(), particleTickData.isOnlySelf(), particleTickData.isOnlyOthers(), player -> {
            player.spawnParticle(particle, location, count, vx, vy, vz, speed, randomParticleDust());
        });
    }
}
