package holo.bolt.render;

import holo.bolt.entity.Entity;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;

public class RenderEntity extends Render
{
	Entity entity;
	Image texture;
	public int hitTimer;
	
	public RenderEntity(Entity ent)
	{
		entity = ent;
		hitTimer = 0;
		try
		{
			texture = new Image(entity.getTextureLoc());
		} catch (SlickException e)
		{
			e.printStackTrace();
		}
	}
	
	@Override
	public void doDraw(GameContainer gc, StateBasedGame game, Graphics g,
			int[] cameraPos)
	{
		Image i = this.getTexture();
		int[] pos = this.getLoc();
		if(hitTimer > 0)
			i.draw(pos[0], pos[1], Color.red);
		else
			i.draw(pos[0], pos[1]);
			
	}

	@Override
	public int[] getLoc()
	{
		return new int[]{(int)entity.pos[0], (int)entity.pos[1]};
	}

	@Override
	public Image getTexture()
	{
		return texture;
	}
	
	public void updateHit(int delta)
	{
		hitTimer -= delta;
	}
	
	public void onHit(int time)
	{
		hitTimer = time;
	}
}
