Team Fortress 2 Source Code as on 22/4/2020
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.

93 lines
2.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. #include "cbase.h"
  3. #include "c_entity_currencypack.h"
  4. #include "c_tf_player.h"
  5. IMPLEMENT_CLIENTCLASS_DT( C_CurrencyPack, DT_CurrencyPack, CCurrencyPack )
  6. RecvPropBool( RECVINFO( m_bDistributed ) ),
  7. END_RECV_TABLE()
  8. C_CurrencyPack::C_CurrencyPack()
  9. {
  10. m_bDistributed = false;
  11. m_pGlowEffect = NULL;
  12. m_bShouldGlowForLocalPlayer = false;
  13. }
  14. //-----------------------------------------------------------------------------
  15. // Purpose:
  16. //-----------------------------------------------------------------------------
  17. C_CurrencyPack::~C_CurrencyPack()
  18. {
  19. DestroyGlowEffect();
  20. }
  21. //-----------------------------------------------------------------------------
  22. // Purpose:
  23. //-----------------------------------------------------------------------------
  24. void C_CurrencyPack::OnDataChanged( DataUpdateType_t updateType )
  25. {
  26. BaseClass::OnDataChanged( updateType );
  27. if ( updateType == DATA_UPDATE_CREATED )
  28. {
  29. SetNextClientThink( CLIENT_THINK_ALWAYS );
  30. }
  31. }
  32. //-----------------------------------------------------------------------------
  33. // Purpose:
  34. //-----------------------------------------------------------------------------
  35. void C_CurrencyPack::ClientThink()
  36. {
  37. #ifdef STAGING_ONLY
  38. int iSeeCashThroughWall = 0;
  39. C_TFPlayer *pTFPlayer = C_TFPlayer::GetLocalTFPlayer();
  40. if ( pTFPlayer && pTFPlayer->IsAlive() )
  41. {
  42. CALL_ATTRIB_HOOK_INT_ON_OTHER( pTFPlayer, iSeeCashThroughWall, mvm_see_cash_through_wall );
  43. }
  44. bool bShouldGlowForLocalPlayer = iSeeCashThroughWall != 0;
  45. if ( m_bShouldGlowForLocalPlayer != bShouldGlowForLocalPlayer )
  46. {
  47. m_bShouldGlowForLocalPlayer = bShouldGlowForLocalPlayer;
  48. UpdateGlowEffect();
  49. }
  50. #endif // STAGING_ONLY
  51. }
  52. //-----------------------------------------------------------------------------
  53. // Purpose:
  54. //-----------------------------------------------------------------------------
  55. void C_CurrencyPack::UpdateGlowEffect( void )
  56. {
  57. // destroy the existing effect
  58. if ( m_pGlowEffect )
  59. {
  60. DestroyGlowEffect();
  61. }
  62. // create a new effect if we have a cart
  63. if ( m_bShouldGlowForLocalPlayer )
  64. {
  65. Vector color = m_bDistributed ? Vector( 150, 0, 0 ) : Vector( 0, 150, 0 );
  66. m_pGlowEffect = new CGlowObject( this, color, 1.0, true );
  67. }
  68. }
  69. //-----------------------------------------------------------------------------
  70. // Purpose:
  71. //-----------------------------------------------------------------------------
  72. void C_CurrencyPack::DestroyGlowEffect( void )
  73. {
  74. if ( m_pGlowEffect )
  75. {
  76. delete m_pGlowEffect;
  77. m_pGlowEffect = NULL;
  78. }
  79. }