#include <Entities/Entity.h>
#include <Entities/Components.h>
#include <Entities/EntityMemoryPool.h>

#include <utility.h>

Entity::Entity(EntityIndex index_in)
	: m_index(index_in)
{

}

template<typename T>
bool Entity::hasComponent() const 
{
	return EntityMemoryPool::instance().hasComponent<T>(m_index);
}

template<typename T>
T& Entity::getComponent() const
{
	return EntityMemoryPool::instance().getComponent<T>(m_index);
}

template<typename T>
T& Entity::getComponent()
{
	return EntityMemoryPool::instance().getComponent<T>(m_index);
}

template<typename T>
void Entity::addComponent(const T&& data)
{
	T& component = EntityMemoryPool::instance().getComponent<T>(m_index);
	component = data;
	component.active = true;
}

EntityIndex Entity::id() const
{
	return EntityMemoryPool::instance().getId(m_index);
}

EntityTag Entity::tag() const
{
	return EntityMemoryPool::instance().getTag(m_index);
}

bool Entity::isAlive() const
{
	return EntityMemoryPool::instance().getAlive(m_index);
}