mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-04-15 05:52:32 +03:00
Fix and optimize custom CBaseCombatCharacter glow effects in TF2
This commit is contained in:
parent
72a204ea31
commit
4849c2adc1
@ -35,7 +35,7 @@ C_BaseCombatCharacter::C_BaseCombatCharacter()
|
||||
m_bGlowEnabled = false;
|
||||
m_bOldGlowEnabled = false;
|
||||
m_bClientSideGlowEnabled = false;
|
||||
m_GlowColor.Init( 0.76f, 0.76f, 0.76f );
|
||||
m_GlowColor.Init( 0.0f, 0.0f, 0.0f );
|
||||
m_OldGlowColor = m_GlowColor;
|
||||
m_GlowAlpha = 1.0f;
|
||||
m_OldGlowAlpha = 1.0f;
|
||||
@ -113,13 +113,22 @@ void C_BaseCombatCharacter::DoMuzzleFlash()
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatCharacter::GetGlowEffectColor( float *r, float *g, float *b, float *a )
|
||||
void C_BaseCombatCharacter::GetGlowEffectColor( float *r, float *g, float *b )
|
||||
{
|
||||
*r = 0.76f;
|
||||
*g = 0.76f;
|
||||
*b = 0.76f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatCharacter::GetCustomGlowEffectColor( float *r, float *g, float *b, float *a )
|
||||
{
|
||||
*r = m_GlowColor.x;
|
||||
*g = m_GlowColor.y;
|
||||
*b = m_GlowColor.z;
|
||||
if (a)
|
||||
*a = m_GlowAlpha;
|
||||
*a = m_GlowAlpha;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -153,7 +162,16 @@ void C_BaseCombatCharacter::UpdateGlowEffect( void )
|
||||
if ( m_bGlowEnabled || m_bClientSideGlowEnabled )
|
||||
{
|
||||
float r, g, b, a;
|
||||
GetGlowEffectColor( &r, &g, &b, &a );
|
||||
|
||||
if ( IsServerSideGlowEnabled() && IsCustomGlowColor() )
|
||||
{
|
||||
GetCustomGlowEffectColor( &r, &g, &b, &a );
|
||||
}
|
||||
else
|
||||
{
|
||||
GetGlowEffectColor( &r, &g, &b );
|
||||
a = 1.0f;
|
||||
}
|
||||
|
||||
m_pGlowEffect = new CGlowObject( this, Vector( r, g, b ), a, true );
|
||||
}
|
||||
@ -179,6 +197,12 @@ BEGIN_RECV_TABLE_NOBASE( C_BaseCombatCharacter, DT_BCCLocalPlayerExclusive )
|
||||
RecvPropTime( RECVINFO( m_flNextAttack ) ),
|
||||
END_RECV_TABLE();
|
||||
|
||||
#ifdef GLOWS_ENABLE
|
||||
BEGIN_RECV_TABLE_NOBASE( C_BaseCombatCharacter, DT_BCCGlowData )
|
||||
RecvPropVector( RECVINFO( m_GlowColor ) ),
|
||||
RecvPropFloat( RECVINFO( m_GlowAlpha ) ),
|
||||
END_RECV_TABLE();
|
||||
#endif
|
||||
|
||||
BEGIN_RECV_TABLE(C_BaseCombatCharacter, DT_BaseCombatCharacter)
|
||||
RecvPropDataTable( "bcc_localdata", 0, 0, &REFERENCE_RECV_TABLE(DT_BCCLocalPlayerExclusive) ),
|
||||
@ -186,8 +210,7 @@ BEGIN_RECV_TABLE(C_BaseCombatCharacter, DT_BaseCombatCharacter)
|
||||
RecvPropArray3( RECVINFO_ARRAY(m_hMyWeapons), RecvPropEHandle( RECVINFO( m_hMyWeapons[0] ) ) ),
|
||||
#ifdef GLOWS_ENABLE
|
||||
RecvPropBool( RECVINFO( m_bGlowEnabled ) ),
|
||||
RecvPropVector( RECVINFO( m_GlowColor ) ),
|
||||
RecvPropFloat( RECVINFO( m_GlowAlpha ) ),
|
||||
RecvPropDataTable( "bcc_glowdata", 0, 0, &REFERENCE_RECV_TABLE( DT_BCCGlowData ) ),
|
||||
#endif // GLOWS_ENABLE
|
||||
|
||||
#ifdef INVASION_CLIENT_DLL
|
||||
|
@ -99,12 +99,15 @@ public:
|
||||
|
||||
#ifdef GLOWS_ENABLE
|
||||
CGlowObject *GetGlowObject( void ){ return m_pGlowEffect; }
|
||||
virtual void GetGlowEffectColor( float *r, float *g, float *b, float *a );
|
||||
virtual void GetGlowEffectColor( float *r, float *g, float *b ) { GetGlowEffectColor( r, g, b, NULL ); }
|
||||
virtual void GetGlowEffectColor( float *r, float *g, float *b );
|
||||
void GetCustomGlowEffectColor( float *r, float *g, float *b, float *a );
|
||||
// void EnableGlowEffect( float r, float g, float b );
|
||||
|
||||
void SetClientSideGlowEnabled( bool bEnabled ){ m_bClientSideGlowEnabled = bEnabled; UpdateGlowEffect(); }
|
||||
bool IsClientSideGlowEnabled( void ){ return m_bClientSideGlowEnabled; }
|
||||
|
||||
bool IsServerSideGlowEnabled( void ){ return m_bGlowEnabled; }
|
||||
bool IsCustomGlowColor() { return !m_GlowColor.IsZero(); }
|
||||
#endif // GLOWS_ENABLE
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
|
@ -3741,7 +3741,9 @@ IMPLEMENT_CLIENTCLASS_DT( C_TFPlayer, DT_TFPlayer, CTFPlayer )
|
||||
RecvPropBool( RECVINFO( m_bForcedSkin ) ),
|
||||
RecvPropInt( RECVINFO( m_nForcedSkin ) ),
|
||||
|
||||
#ifndef MAPBASE // Already received by C_BaseCombatCharacter
|
||||
RecvPropBool( RECVINFO( m_bGlowEnabled ) ),
|
||||
#endif
|
||||
|
||||
RecvPropDataTable("TFSendHealersDataTable", 0, 0, &REFERENCE_RECV_TABLE( DT_TFSendHealersDataTable ) ),
|
||||
RecvPropFloat( RECVINFO( m_flKartNextAvailableBoost ) ),
|
||||
|
@ -300,14 +300,35 @@ BEGIN_SEND_TABLE_NOBASE( CBaseCombatCharacter, DT_BCCLocalPlayerExclusive )
|
||||
SendPropTime( SENDINFO( m_flNextAttack ) ),
|
||||
END_SEND_TABLE();
|
||||
|
||||
#ifdef GLOWS_ENABLE
|
||||
void *SendProxy_SendBaseCombatCharacterGlowDataTable( const SendProp *pProp, const void *pStruct, const void *pVarData, CSendProxyRecipients *pRecipients, int objectID )
|
||||
{
|
||||
// Only send if our glow is active
|
||||
CBaseCombatCharacter *pBCC = ( CBaseCombatCharacter * )pStruct;
|
||||
if ( pBCC != NULL)
|
||||
{
|
||||
if ( pBCC->IsGlowEffectActive() )
|
||||
{
|
||||
return (void *)pVarData;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
REGISTER_SEND_PROXY_NON_MODIFIED_POINTER( SendProxy_SendBaseCombatCharacterGlowDataTable );
|
||||
|
||||
BEGIN_SEND_TABLE_NOBASE( CBaseCombatCharacter, DT_BCCGlowData )
|
||||
SendPropVector( SENDINFO( m_GlowColor ), 8, 0, 0, 1 ),
|
||||
SendPropFloat( SENDINFO( m_GlowAlpha ) ),
|
||||
END_SEND_TABLE();
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This table encodes the CBaseCombatCharacter
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_SERVERCLASS_ST(CBaseCombatCharacter, DT_BaseCombatCharacter)
|
||||
#ifdef GLOWS_ENABLE
|
||||
SendPropBool( SENDINFO( m_bGlowEnabled ) ),
|
||||
SendPropVector( SENDINFO( m_GlowColor ), 8, 0, 0, 1 ),
|
||||
SendPropFloat( SENDINFO( m_GlowAlpha ) ),
|
||||
SendPropDataTable( "bcc_glowdata", 0, &REFERENCE_SEND_TABLE( DT_BCCGlowData ), SendProxy_SendBaseCombatCharacterGlowDataTable ),
|
||||
#endif // GLOWS_ENABLE
|
||||
// Data that only gets sent to the local player.
|
||||
SendPropDataTable( "bcc_localdata", 0, &REFERENCE_SEND_TABLE(DT_BCCLocalPlayerExclusive), SendProxy_SendBaseCombatCharacterLocalDataTable ),
|
||||
@ -893,7 +914,7 @@ CBaseCombatCharacter::CBaseCombatCharacter( void )
|
||||
|
||||
#ifdef GLOWS_ENABLE
|
||||
m_bGlowEnabled.Set( false );
|
||||
m_GlowColor.GetForModify().Init( 0.76f, 0.76f, 0.76f );
|
||||
m_GlowColor.GetForModify().Init( 0.0f, 0.0f, 0.0f );
|
||||
m_GlowAlpha.Set(1.0f);
|
||||
#endif // GLOWS_ENABLE
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user