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

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

LINK_ENTITY_TO_CLASS( rts_mouse_brush, CMouseRTSBrush );

extern ConVar	showtriggers;

BEGIN_DATADESC( CMouseRTSBrush )
	// fields
	DEFINE_FIELD( m_bDisabled, FIELD_BOOLEAN ),
	DEFINE_KEYFIELD( m_bSolid, FIELD_BOOLEAN, "solid" ),
	DEFINE_KEYFIELD( m_bVisible, FIELD_BOOLEAN, "visible" ),
	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"),
	DEFINE_OUTPUT(m_OnCursorEntered, "OnCursorEntered"),
	DEFINE_OUTPUT(m_OnCursorExited, "OnCursorExited"),
END_DATADESC()

//server data table describing networked member variables (SendProps)
IMPLEMENT_SERVERCLASS_ST( CMouseRTSBrush, DT_MouseRTSBrush )
	SendPropFloat	(SENDINFO(m_fYawSelection), 6, SPROP_ROUNDUP ),
	SendPropBool	(SENDINFO(m_bSolid) ),
END_SEND_TABLE()

CMouseRTSBrush::CMouseRTSBrush()
{
}


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

	SetMoveType( MOVETYPE_NONE );
	SetModel( STRING( GetModelName() ) );    // set size and link into world
	
	AddEFlags( EFL_FORCE_CHECK_TRANSMIT );

	if( !m_bVisible )
		AddEffects( EF_NODRAW );
}

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

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

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

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

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

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

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

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

void CMouseRTSBrush::OnCursorEntered( CBasePlayer *pActivator )
{
	m_hActivator = pActivator;

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

void CMouseRTSBrush::OnCursorExited( CBasePlayer *pActivator )
{
	m_hActivator = pActivator;

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