#include "Salamander.h"
#include "Entity.h"

namespace Salamander
{

// Quick access to transform based on reference frame.
#define transform_ (referenceFrame_ == LOCAL ? local_ : world_)

Entity::Entity() : Node(),  
	referenceFrame_(LOCAL)
{

}

Entity::~Entity()
{
	
}

void Entity::setReferenceFrame(ReferenceFrame referenceFrame)
{
	referenceFrame_ = referenceFrame;
}

Entity::ReferenceFrame Entity::getReferenceFrame()
{
	return referenceFrame_;
}

void Entity::setTransform(const Mat2& transform)
{
	// update depending upon reference frame
	transform_ = transform;
	propogate();
}

Mat2& Entity::getTransform()
{
	// return depending upon reference frame
	return transform_;
}

void Entity::setTranslation(const Vec2& translation)
{
	// update depending upon reference frame
	transform_.setTranslation(translation);
	propogate();
}

Vec2 Entity::getTranslation() const
{
	return transform_.getTranslation();
}

void Entity::setScale(const Vec2& scale)
{
	// update depending upon reference frame
	transform_.setScale(scale);
	propogate();
}

Vec2 Entity::getScale() const
{
	return transform_.getScale();
}

void Entity::setRotation(double rotation)
{
	// update depending upon refrence frame
	transform_.setRotation(rotation);
	propogate();
}

double Entity::getRotation()
{
	return transform_.getRotation();
}

Entity* Entity::getChild(unsigned int index)
{
	return (Entity*)Node::getChild(index);
}

void Entity::propogate()
{
	// we work in either local or world co-ordinates. if we've set one, 
	// update the other accordingly


	
}

}
