package projectzombie.tiles;

import java.util.Random;

import gl_engine.vec.Vec2i;
import gl_engine.vec.Vec3d;
import projectzombie.entity.particle.ParticleSmoke;
import projectzombie.init.Models;
import projectzombie.model.Model;
import projectzombie.util.TileState;
import projectzombie.util.math.random.RandomHelpers;
import projectzombie.world.chunk.Chunk;
import projectzombie.world.layer.Layer;

public class TileLavaFlow extends Tile
{
	private Random rand = new Random();

	public TileLavaFlow() {
		
		this.emitsLight = true;
		this.unbreakable = true;
	}
	
	@Override
	public double getLightLevel(TileState state, Vec2i pos) {
		return 0.6;
	}
	
	@Override
	public void tickRandomly(Layer layer, Chunk chunk, TileState state, Vec2i pos) {
		super.tickRandomly(layer, chunk, state, pos);
		
		if(RandomHelpers.randrange(rand, 5) == 0) {
			chunk.spawnEntity(new ParticleSmoke(new Vec3d(
					pos.x + rand.nextDouble(), 0, pos.y + rand.nextDouble()),
					new Vec3d(0, 0, 0)));
		}
	}
	
	@Override
	public Model getModel(byte meta) {
		return Models.TILE_LAVA_FLOW;
	}

}
