package zero1hd.polyjet.entity;

import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Pool.Poolable;

public class Entity extends Actor implements Poolable {
	private Rectangle hitbox;
	protected int hitpoints;
	
	public Entity() {
		hitbox = new Rectangle();
	}
	
	@Override
	public void setSize(float width, float height) {
		hitbox.setSize(width, height);
		super.setSize(width, height);
	}
	
	@Override
	public void act(float delta) {
		hitbox.setPosition(getX(), getY());
		super.act(delta);
	}
	
	/**
	 * @return amount of hp this entity has left.
	 */
	public int getHitPoints() {
		return hitpoints;
	}
	
	/**
	 * used as a hitbox.
	 * @return a rectangle used for hit detection
	 */
	public Rectangle getHitbox() {
		return hitbox;
	}
	
	/**
	 * Returns 0 if not overridden.
	 * @return the amount of damage dealt.
	 */
	public int getDamageDealt() {
		return 0;
	}
	
	/**
	 * Doesn't do anything if not overridden.
	 * @param damageToDeal the amount of damage to deal to this entity.
	 */
	public void dealDamage(int damageToDeal) {
	}
	/**
	 * Default value is 0 if not overridden and setup properly.
	 * Note: this method is called whether or not this entity is dead. whenever two entities cross, this will be called.
	 * @return the amount of points this entity is worth
	 */
	public int getPoints() {
		return 0;
	}
	
	@Override
	public void reset() {
		setPosition(0, 0);
		setSize(0, 0);
		hitpoints = 0;
	}
}
