//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#include "cbase.h"
#include "hl2wars/combine_mine_rts.h"
#include "hl2wars/rts_shareddefs.h"
//#include "ai_basenpc.h"
#include "BaseCombatCharacter.h"
#include "player.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

BEGIN_DATADESC( CBounceBombRTS )
	DEFINE_FIELD( m_iTeamID, FIELD_INTEGER ),
END_DATADESC()

void CBounceBombRTS::SetTeamRTSID( int teamid )
{
	m_iTeamID = teamid;
}

//---------------------------------------------------------
//---------------------------------------------------------
bool CBounceBombRTS::IsFriend( CBaseEntity *pEntity )
{
	if( pEntity->IsPlayer() )
	{
		CBasePlayer *pPlayer = ToBasePlayer( pEntity );
		if( pPlayer->IsPlayerInRTSMode() )
			return true;
	}

	if( m_iTeamID == TEAMRTS_DEFAULT || !pEntity->IsNPC() )
		BaseClass::IsFriend( pEntity );

	CBaseCombatCharacter *pCC = assert_cast<CBaseCombatCharacter *>(pEntity); 
	if( !pCC )
		return BaseClass::IsFriend( pEntity );

	if( pCC->GetTeamRTSID() == m_iTeamID )
		return true;
	else if( pCC->GetTeamRTSID() == TEAMRTS_NEUTRAL )
		return true;
	else
		return false;
}

LINK_ENTITY_TO_CLASS( combine_mine_rts, CBounceBombRTS );
