#include "bulletmanager.h"

void CBulletManager::Init()
{
}

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

void CBulletManager::Cleanup()
{
}

void CBulletManager::Add( IEntity* bullet )
{
    m_BulletList.push_back( static_cast<CBullet*>(bullet) );
}
void CBulletManager::Remove( std::string UID )
{
}

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

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


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