package projectzombie.tiles;

import gl_engine.vec.Vec2i;
import gl_engine.vec.Vec3d;
import projectzombie.entity.Entity;
import projectzombie.entity.EntityItem;
import projectzombie.init.Items;
import projectzombie.init.Models;
import projectzombie.init.Tiles;
import projectzombie.model.Model;
import projectzombie.util.ItemStack;
import projectzombie.util.TileState;
import projectzombie.world.layer.Layer;

public class TileLantern extends Tile
{

	public TileLantern() {
		
		this.emitsLight = true;
	}
	
	@Override
	public double getLightLevel(TileState state, Vec2i pos) {
		return 1;
	}
	
	@Override
	public boolean onActivated(Layer layer, Vec2i tpos, Entity entity, TileState state) {
		super.onActivated(layer, tpos, entity, state);
		
		layer.setFrontTile(Tiles.VOID.getDefaultState(), tpos);
		layer.spawnEntity(new EntityItem(tpos.toDouble().xny(), new Vec3d(0, 0, 0),
				new ItemStack(Items.LANTERN, 1)));
		
		return true;
	}
	
	@Override
	public Model getModel(byte meta) {
		return Models.TILE_LANTERN;
	}

}
