/*
* file Entity.cpp
* Entity
* 
* 27/01/2006
* Copyright Piquier Production
* 
*/

#include "Entity.h"
#include "CollisionManager.h"
#include "MemoryManager/debugNew.h"

Entity::Entity(Point2D p): position(p) {
	healthPoint = 69;
	speed = 0.04f;
	position = p;
	this->orientation = 0.0f;
	radius = 0.4f;
}

Entity::Entity(){
	healthPoint = 69;
	speed = 0.04f;
	position.setCoord(0,0);
	this->orientation = 0.0f;
	radius = 0.4f;
}

Entity::~Entity(void) {}


void Entity::decreaseHealthPoint(int decreasePoint) {
	if(healthPoint > 0 ) {
		healthPoint = healthPoint - decreasePoint;
		if (!isAlive()){
			CollisionManager::getInstance().removeCollidable(this);
		}
	}
}

Point2D Entity::getPosition() {
	return position;
}

void Entity::setPosition(Point2D p) {
	position = p;
}

int Entity::getHealthPoint() {
	return healthPoint;
}

void Entity::setHealthPoint(int hp) {
	healthPoint = hp;
}

float Entity::getOrientation() {
	return orientation;
}

void Entity::setOrientation(float o) {
	orientation = o;
}

float Entity::getSpeed() {
	return speed;
}

void Entity::setSpeed(float s) {
	speed = s;
}

Point2D& Entity::getRenderableEntityPosition(){
	return this->position;
}

float Entity::getRenderableEntityAngle(){
	return -this->orientation + 90;
}

float Entity::getCollisionRadius(){
	return radius/2.0f;
}

void Entity::setCollisionRadius(float r){
	//radius = r;
}

float Entity::getRadius(){
	return radius;
}

void Entity::setRadius(float r){
	radius = r;
}

float Entity::getDirectionAngle(){
	return orientation;
}

void Entity::setPostCollisionPosition(Point2D& pos){
	if(isAlive()){
		setPosition(pos);
	}
}

float Entity::getSpeedForCollision(){
	return speed;
}

bool Entity::isMoving(){
	return false;
}

bool Entity::isAlive(){
	return (healthPoint>0);
}


void Entity::signalCollision(){
	
}

bool Entity::haveLife()
{
	return isAlive();
}

float Entity::getCurrentLife()
{
	return (float)this->healthPoint;
}


