package projectzombie.worker;

import java.util.Vector;

import bdf.types.BdfReader;
import gl_engine.vec.Vec2i;
import projectzombie.util.FileHelpers;
import projectzombie.world.chunk.Chunk;
import projectzombie.world.layer.Layer;

public class WorkerTaskChunkLoad extends WorkerTaskChunk
{
	String path;
	Layer layer;
	
	public WorkerTaskChunkLoad(String path, Layer layer, Vec2i pos) {
		this.path = path;
		this.layer = layer;
		this.pos = pos;
	}
	
	@Override
	public void run()
	{
		if(path == null) {
			System.out.println("ChunkLoad: Path is NULL");
			return;
		}
		
		String path = "./saves/" + this.path + "/c_" + layer.id + "_" + pos.x + "_" + pos.y + ".bdf.gz";
		
		BdfReader reader = FileHelpers.readBDF(path);
		
		Chunk chunk = new Chunk(layer, pos, reader.getObject());
		
		WorkerTasks.addChunkOut(chunk);
	}
}
