#include "baseentity.h"
#include "baseplayer.h"
#include "engine.h"
#include "tier1/utlvector.h"


CUtlVector<CPlayerStart*> g_PlayerStarts;

void CPlayerStart::Precache()
{
}

void CPlayerStart::Spawn()
{
	g_PlayerStarts.AppendTail(this);
};

void CPlayerStart::ReadParameter( const char *szName, const char *szValue )
{
	CBaseEntity::ReadParameter(szName, szValue);
}

void CPlayerStart::Destroy()
{
}

void CPlayerStart::Think( float fDelta )
{
}
	
void CPlayerStart::RoundEnd( void )
{
	m_bIsRunning = false;
}

void CPlayerStart::RoundStart(IIClient *pClient)
{
	IIEngine::DestroyEntity(pOwningPlayer);
	if (!pClient)
		return;
	m_bIsRunning = true;
	pOwningPlayer = (CBasePlayer*)IIEngine::SpawnEntity("player");
	if (pOwningPlayer)
	{
		pOwningPlayer->pOwningSpawn = this;
		pOwningPlayer->SetPosition(m_position);
	}
	else 
		V_printf("Failed to spawn player\n");
	IIEngine::InitEntity(pOwningPlayer);
	pClient->pBasePlayer = pOwningPlayer;
};

DECLARE_ENTITY(info_player_start, CPlayerStart);
