text: #include "MyEntityManager.h"
  using namespace Simplex;
  //  MyEntityManager
  MyEntityManager* MyEntityManager::m_pInstance = nullptr;
  void MyEntityManager::Init(void)
  {
  	m_uEntityCount = 0;
  	m_entityList.clear();
  }
  void MyEntityManager::Release(void)
  {
  	for (uint uEntity = 0; uEntity < m_uEntityCount; ++uEntity)
  	{
  		MyEntity* pEntity = m_entityList[uEntity];
  		SafeDelete(pEntity);
  	}
  	Init();
  }
  MyEntityManager* MyEntityManager::GetInstance()
  {
  	m_pInstance = new MyEntityManager();
  	return m_pInstance;
  }
  void MyEntityManager::ReleaseInstance()
  {
  	if (m_pInstance != nullptr)
  	{
  		delete m_pInstance;
  		m_pInstance = nullptr;
  	}
  }
  int Simplex::MyEntityManager::GetEntityIndex(String a_sUniqueID)
  {
  	for (uint uIndex = 0; uIndex < m_uEntityCount; ++uIndex)
  	{
  		if (a_sUniqueID == m_entityList[uIndex]->GetUniqueID())
  			return uIndex;
  	}
  	return -1;
  }
  //Accessors
  Model* Simplex::MyEntityManager::GetModel(uint a_uIndex)
  {
  	return m_entityList[a_uIndex]->GetModel();
  }
  Model* Simplex::MyEntityManager::GetModel(String a_sUniqueID)
  {
  	MyEntity* pTemp = MyEntity::GetEntity(a_sUniqueID);
  	return pTemp->GetModel();
  }
  RigidBody* Simplex::MyEntityManager::GetRigidBody(uint a_uIndex)
  {
  	return m_entityList[a_uIndex]->GetRigidBody();
  }
  RigidBody* Simplex::MyEntityManager::GetRigidBody(String a_sUniqueID)
  {
  	MyEntity* pTemp = MyEntity::GetEntity(a_sUniqueID);
  	return pTemp->GetRigidBody();
  
  }
  matrix4 Simplex::MyEntityManager::GetModelMatrix(uint a_uIndex)
  {
  	if (a_uIndex >= m_uEntityCount)
  		a_uIndex = m_uEntityCount - 1;
  
  	return m_entityList[a_uIndex]->GetModelMatrix();
  }
  matrix4 Simplex::MyEntityManager::GetModelMatrix(String a_sUniqueID)
  {
  	MyEntity* pTemp = MyEntity::GetEntity(a_sUniqueID);
  	return pTemp->GetModelMatrix();
  }
  void Simplex::MyEntityManager::SetModelMatrix(matrix4 a_m4ToWorld, String a_sUniqueID)
  {
  	MyEntity* pTemp = MyEntity::GetEntity(a_sUniqueID);
  	pTemp->SetModelMatrix(a_m4ToWorld);	
  }
  
  void Simplex::MyEntityManager::SetModelMatrix(matrix4 a_m4ToWorld, uint a_uIndex)
  {
  	if (a_uIndex >= m_uEntityCount)
  		a_uIndex = m_uEntityCount - 1;
  
  	m_entityList[a_uIndex]->SetModelMatrix(a_m4ToWorld);
  }
  //The big 3
  MyEntityManager::MyEntityManager() { Init(); }
  MyEntityManager::MyEntityManager(MyEntityManager const& other) { }
  MyEntityManager& MyEntityManager::operator=(MyEntityManager const& other) { return *this; }
  MyEntityManager::~MyEntityManager() { Release(); };
  // other methods
  void Simplex::MyEntityManager::Update(void)
  {
  	for (uint i = 0; i < m_uEntityCount - 1; i++)
  	{
  		for (uint j = i + 1; j < m_uEntityCount; j++)
  		{
  			m_entityList[i]->IsColliding(m_entityList[j]);
  		}
  	}
  }
  void Simplex::MyEntityManager::AddEntity(String a_sFileName, String a_sUniqueID)
  {
  	MyEntity* pTemp = new MyEntity(a_sFileName, a_sUniqueID);
  
  	m_entityList.push_back(pTemp);
  	m_uEntityCount = m_entityList.size();	
  }
  void Simplex::MyEntityManager::RemoveEntity(uint a_uIndex)
  {
  	if (a_uIndex != m_uEntityCount - 1)
  	{
  		std::swap(m_entityList[a_uIndex], m_entityList[m_uEntityCount - 1]);
  	}
  
  	m_entityList.pop_back();
  	--m_uEntityCount;
  	return;
  }
  void Simplex::MyEntityManager::RemoveEntity(String a_sUniqueID)
  {
  	int nIndex = GetEntityIndex(a_sUniqueID);
  	RemoveEntity((uint)nIndex);
  }
  String Simplex::MyEntityManager::GetUniqueID(uint a_uIndex)
  {
  	return m_entityList[a_uIndex]->GetUniqueID();
  }
  MyEntity* Simplex::MyEntityManager::GetEntity(uint a_uIndex)
  {
  	return m_entityList[a_uIndex];
  }
  void Simplex::MyEntityManager::AddEntityToRenderList(uint a_uIndex, bool a_bRigidBody)
  {
  	if (a_uIndex >= m_uEntityCount)
  	{
  		for (a_uIndex = 0; a_uIndex < m_uEntityCount; ++a_uIndex)
  		{
  			m_entityList[a_uIndex]->AddToRenderList(a_bRigidBody);
  		}
  	}
  	else
  	{
  		m_entityList[a_uIndex]->AddToRenderList(a_bRigidBody);
  	}
  	
  }
  void Simplex::MyEntityManager::AddEntityToRenderList(String a_sUniqueID, bool a_bRigidBody)
  {
  	MyEntity* pTemp = MyEntity::GetEntity(a_sUniqueID);
  	pTemp->AddToRenderList(a_bRigidBody);
  }