/**
 * package for classes related to game objects
 */
package simogl.gameobjects;

import simogl.collision.CollisionFinder;
import simogl.geometry.Point3D;
import simogl.model.AbstractMD2Model;

/**
 * This class is the basic model of any other game object
 * @author Frank Bruns
 *
 */
public abstract class AbstractGameObject
{
	protected AbstractMD2Model md2Model = null;
	protected Point3D pos = null;
	protected CollisionFinder collFinder = null;
	protected String name = "";
	
	/**
	 * Creates a new game object
	 * @param x x-coordinate
	 * @param y y-coordinate
	 * @param z z-coordinate
	 */
	public AbstractGameObject(float x, float y, float z)
	{
		this.pos = new Point3D(x,y,z);
		this.collFinder = new CollisionFinder();
	}
	
	
	/**
	 * Returns the md2 model of the character
	 * @return md2 model of the character
	 */
	public AbstractMD2Model getModel()
	{
		return this.md2Model;
	}
	
	/**
	 * Returns the position of the gane object as a Point3D object
	 * @return position of the game object
	 */
	public Point3D getPosition()
	{
		return this.pos;
	}
	
	/**
	 * Sets the position of the game object
	 * @param position position to set the game object to
	 */
	public void setPosition(Point3D position)
	{
		this.pos = position;
	}
	
	/**
	 * Sets the position of the game object to the specified parameters
	 * @param x x-coordinate
	 * @param y y-coordinate
	 * @param z z-coordinate
	 */
	public void setPosition(float x, float y, float z)
	{
		this.pos.setTo(x, y, z);
	}
	
	/**
	 * Sets the x-coordinate of the game object
	 * @param x x-coordinate
	 */
	public void setX(float x)
	{
		this.pos.setX(x);
		this.md2Model.getCurrentAnim().getCurrentFrame().getMesh().setPositionX(x);
	}
	
	/**
	 * Sets the y-coordinate of the game object
	 * @param y y-coordinate
	 */
	public void setY(float y)
	{
		this.pos.setY(y);
		this.md2Model.getCurrentAnim().getCurrentFrame().getMesh().setPositionY(y);
	}
	
	/**
	 * Sets the z-coordinate of the game object
	 * @param z z-coordinate
	 */
	public void setZ(float z)
	{
		this.pos.setZ(z);
		this.md2Model.getCurrentAnim().getCurrentFrame().getMesh().setPositionZ(z);
	}
	
	/**
	 * Returns the x-position of the game object
	 * @return x-coordinate of the game object
	 */
	public float getX()
	{
		return this.pos.getX();
	}
	
	/**
	 * Returns the y-position of the game object
	 * @return y-coordinate of the game object
	 */
	public float getY()
	{
		return this.pos.getY();
	}
	
	/**
	 * Returns the z-position of the game object
	 * @return z-coordinate of the game object
	 */
	public float getZ()
	{
		return this.pos.getZ();
	}
	
	/**
	 * Returns the name of the game object
	 * @return name of the game object
	 */
	public String getName()
	{
		return this.name;
	}
	
	/**
	 * Updates a game object
	 * @param elapsedTime time between two frames
	 */
	public abstract void update(long elapsedTime);
}
