package projectzombie.tiles;

import gl_engine.vec.Vec2i;
import projectzombie.init.Models;
import projectzombie.init.Tiles;
import projectzombie.model.Model;
import projectzombie.util.TileState;
import projectzombie.world.chunk.Chunk;
import projectzombie.world.layer.Layer;

public class TileGrassInfested extends Tile
{
	@Override
	public void tickRandomly(Layer layer, Chunk chunk, TileState state, Vec2i pos) {
		super.tickRandomly(layer, chunk, state, pos);
		
		if(Math.random() > 0)
		{
			Vec2i cpos = pos.add(new Vec2i((int)Math.floor(Math.random() * 3) - 1, (int)Math.floor(Math.random() * 3) - 1));
			Tile tile = layer.getBackTile(cpos).tile;
			
			if(tile == Tiles.DIRT || tile == Tiles.GRASS) {
				layer.setBackTile(Tiles.GRASS_INFESTED.getDefaultState(), cpos);
			}
		}
	}

	@Override
	public Model getModel(byte meta) {
		return Models.TILE_GRASS_INFESTED;
	}
	
}
