#include "explosionmanager.h"

void CExplosionManager::Init()
{
}

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

void CExplosionManager::Cleanup()
{
}

void CExplosionManager::Add( IEntity* explosion )
{
    m_ExplosionList.push_back( static_cast<CExplosion*>(explosion) );
}
void CExplosionManager::Remove( std::string UID )
{
}

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

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


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