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

#include "cbase.h"
#include "hl2wars/rts_mouse_model.h"
#include "hl2_shareddefs.h"
#include "const.h"

LINK_ENTITY_TO_CLASS( rts_mouse_model, CMouseRTSModel );

//extern ConVar	showtriggers;

BEGIN_DATADESC( CMouseRTSModel )
	// fields
	DEFINE_FIELD( m_bDisabled, FIELD_BOOLEAN ),
	DEFINE_KEYFIELD( m_fYawSelection, FIELD_FLOAT, "yawselection" ),

	// Inputs
	DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ),
	DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ),

	// Outputs
	DEFINE_OUTPUT(m_OnClickLeft, "OnClickLeft"),
	DEFINE_OUTPUT(m_OnClickRight, "OnClickRight"),
	DEFINE_OUTPUT(m_OnClickLeftDouble, "OnClickLeftDouble"),
	DEFINE_OUTPUT(m_OnClickRightDouble, "OnClickRightDouble"),
END_DATADESC()

//server data table describing networked member variables (SendProps)
IMPLEMENT_SERVERCLASS_ST( CMouseRTSModel, DT_MouseRTSModel )
	SendPropFloat	(SENDINFO(m_fYawSelection), 6, SPROP_ROUNDUP ),
END_SEND_TABLE()

CMouseRTSModel::CMouseRTSModel()
{

}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CMouseRTSModel::Precache( void )
{
	/*if ( GetModelName() == NULL_STRING )
	{
		Msg( "%s at (%.3f, %.3f, %.3f) has no model name!\n", GetClassname(), GetAbsOrigin().x, GetAbsOrigin().y, GetAbsOrigin().z );
		SetModelName( AllocPooledString( "models/error.mdl" ) );
	}

	PrecacheModel( STRING( GetModelName() ) );*/

	BaseClass::Precache();
}

//-----------------------------------------------------------------------------
// Purpose: Called when spawning, after keyvalues have been handled.
//-----------------------------------------------------------------------------
void CMouseRTSModel::Spawn( )
{
	BaseClass::Spawn();

	/*char *szModel = (char *)STRING( GetModelName() );
	if (!szModel || !*szModel)
	{
		Warning( "prop at %.0f %.0f %0.f missing modelname\n", GetAbsOrigin().x, GetAbsOrigin().y, GetAbsOrigin().z );
		UTIL_Remove( this );
		return;
	}

	AddFlag( FL_STATICPROP );

	PrecacheModel( szModel );
	Precache();
	SetModel( szModel );*/

	//SetMoveType( MOVETYPE_PUSH );  // so it doesn't get pushed by anything
	//SetCollisionGroup( COLLISION_GROUP_NONE );

	//SetSolid( SOLID_VPHYSICS );
	//CreateVPhysics();

	//CalculateBlockLOS();

	//AddFlag( FL_STATICPROP );

	//SetCollisionGroup( COLLISION_GROUP_INTERACTIVE );
}

//-----------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
/*bool CMouseRTSModel::CreateVPhysics( void )
{
	if ( GetSolid() == SOLID_NONE || ((GetSolidFlags() & FSOLID_NOT_SOLID) && HasSpawnFlags(SF_DYNAMICPROP_NO_VPHYSICS)))
	{
		// don't create a physics object in this case - saves CPU & memory
	}
	else
 	{
		VPhysicsInitStatic();
	}
	return true;
}*/


void CMouseRTSModel::OnClickLeft( CBasePlayer *pActivator ) 
{
	m_hActivator = pActivator;

	if( !m_bDisabled ) 
        m_OnClickLeft.FireOutput(m_hActivator, this);
}

void CMouseRTSModel::OnClickRight( CBasePlayer *pActivator ) 
{
	m_hActivator = pActivator;

	if( !m_bDisabled ) 
        m_OnClickRight.FireOutput(m_hActivator, this);
}

void CMouseRTSModel::OnClickLeftDouble( CBasePlayer *pActivator ) 
{
	m_hActivator = pActivator;

	if( !m_bDisabled ) 
        m_OnClickLeftDouble.FireOutput(m_hActivator, this);
}

void CMouseRTSModel::OnClickRightDouble( CBasePlayer *pActivator ) 
{
	m_hActivator = pActivator;

	if( !m_bDisabled ) 
        m_OnClickRightDouble.FireOutput(m_hActivator, this);
}
