package projectzombie.entity.particle;

import gl_engine.vec.Vec3d;
import projectzombie.entity.EntityParticle;
import projectzombie.entity.EntityParticlePart;
import projectzombie.init.Models;
import projectzombie.model.Model;
import projectzombie.util.math.random.RandomHelpers;
import projectzombie.world.chunk.Chunk;
import projectzombie.world.layer.Layer;

public class ParticleSmoke extends EntityParticle
{
	private Model model;

	public ParticleSmoke(Vec3d pos, Vec3d velocity) {
		super(pos.add(new Vec3d(
				RandomHelpers.randrange(rand, 1000)/1000.0 - 0.5, 0,
				RandomHelpers.randrange(rand, 1000)/1000.0 - 0.5)),
				velocity.add(new Vec3d(0, (rand.nextDouble() + 0.5) / 100, 0)));
		
		hasGravity = false;
		model = Models.PARTICLE_SMOKE_RANDOM.getModel();
	}
	
	@Override
	public void tick(Chunk chunk, Layer layer) {
		super.tick(chunk, layer);
		
		setVelocity(getVelocity().multiply(new Vec3d(0.995, 1, 0.995)));
	}

	@Override
	public int getParticleCount() {
		return 1;
	}

	@Override
	public EntityParticlePart getParticleAt(int id) {
		return new EntityParticlePart(model.getTextures()[0], getPos(), 1, 0b1000);
	}

}
