Modified source engine (2017) developed by valve and leaked in 2020. Not for commercial purporses
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.5 KiB

5 years ago
//========= Copyright Valve Corporation, All rights reserved. ============//
#include "cbase.h"
#include "c_entity_currencypack.h"
#include "c_tf_player.h"
IMPLEMENT_CLIENTCLASS_DT( C_CurrencyPack, DT_CurrencyPack, CCurrencyPack )
RecvPropBool( RECVINFO( m_bDistributed ) ),
END_RECV_TABLE()
C_CurrencyPack::C_CurrencyPack()
{
m_bDistributed = false;
m_pGlowEffect = NULL;
m_bShouldGlowForLocalPlayer = false;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
C_CurrencyPack::~C_CurrencyPack()
{
DestroyGlowEffect();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_CurrencyPack::OnDataChanged( DataUpdateType_t updateType )
{
BaseClass::OnDataChanged( updateType );
if ( updateType == DATA_UPDATE_CREATED )
{
SetNextClientThink( CLIENT_THINK_ALWAYS );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_CurrencyPack::ClientThink()
{
#ifdef STAGING_ONLY
int iSeeCashThroughWall = 0;
C_TFPlayer *pTFPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( pTFPlayer && pTFPlayer->IsAlive() )
{
CALL_ATTRIB_HOOK_INT_ON_OTHER( pTFPlayer, iSeeCashThroughWall, mvm_see_cash_through_wall );
}
bool bShouldGlowForLocalPlayer = iSeeCashThroughWall != 0;
if ( m_bShouldGlowForLocalPlayer != bShouldGlowForLocalPlayer )
{
m_bShouldGlowForLocalPlayer = bShouldGlowForLocalPlayer;
UpdateGlowEffect();
}
#endif // STAGING_ONLY
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_CurrencyPack::UpdateGlowEffect( void )
{
// destroy the existing effect
if ( m_pGlowEffect )
{
DestroyGlowEffect();
}
// create a new effect if we have a cart
if ( m_bShouldGlowForLocalPlayer )
{
Vector color = m_bDistributed ? Vector( 150, 0, 0 ) : Vector( 0, 150, 0 );
m_pGlowEffect = new CGlowObject( this, color, 1.0, true );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_CurrencyPack::DestroyGlowEffect( void )
{
if ( m_pGlowEffect )
{
delete m_pGlowEffect;
m_pGlowEffect = NULL;
}
}