#include "enemymanager.h"

void CEnemyManager::Init()
{
}

void CEnemyManager::Init(CFactory* factory)
{
	m_Factory = factory;
}

void CEnemyManager::Cleanup()
{
}

void CEnemyManager::Add( IEntity* enemy )
{
    m_EnemyList.push_back( static_cast<CEnemy*>(enemy) );
}
void CEnemyManager::Remove( std::string UID )
{
}

int CEnemyManager::NumOfEntities()
{
    return m_EnemyList.size();
}
void CEnemyManager::GetEntity( std::string UID )
{
}

void CEnemyManager::Update( int deltaT )
{
    for (m_Itor = m_EnemyList.begin(); m_Itor != m_EnemyList.end(); )
    {
        (*m_Itor)->Update(deltaT);
        if (!(*m_Itor)->m_Alive)
        {
            m_Factory->Recycle("Enemy", (*m_Itor));
            m_Itor = m_EnemyList.erase(m_Itor);
        }
        else
            ++m_Itor;
    }


}
void CEnemyManager::Draw( SDL_Surface* screen )
{
    for (m_Itor=m_EnemyList.begin(); m_Itor != m_EnemyList.end(); ++m_Itor)
        (*m_Itor)->Draw( screen );
}
