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.

82 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. #include "cbase.h"
  3. #include "c_monster_resource.h"
  4. #include "tf_hud_boss_health.h"
  5. // memdbgon must be the last include file in a .cpp file!!!
  6. #include "tier0/memdbgon.h"
  7. void RecvProxy_UpdateBossHud( const CRecvProxyData *pData, void *pStruct, void *pOut );
  8. IMPLEMENT_CLIENTCLASS_DT_NOBASE( C_MonsterResource, DT_MonsterResource, CMonsterResource )
  9. RecvPropInt( RECVINFO( m_iBossHealthPercentageByte ), 0, RecvProxy_UpdateBossHud ),
  10. RecvPropInt( RECVINFO( m_iBossStunPercentageByte ), 0, RecvProxy_UpdateBossHud ),
  11. RecvPropInt( RECVINFO( m_iSkillShotCompleteCount ) ),
  12. RecvPropTime( RECVINFO( m_fSkillShotComboEndTime ) ),
  13. RecvPropInt( RECVINFO( m_iBossState ), 0, RecvProxy_UpdateBossHud ),
  14. END_RECV_TABLE()
  15. C_MonsterResource *g_pMonsterResource = NULL;
  16. //-----------------------------------------------------------------------------
  17. // Update the HUD meter when the Boss' data changes
  18. void RecvProxy_UpdateBossHud( const CRecvProxyData *pData, void *pStruct, void *pOut )
  19. {
  20. int *out = (int *)pOut;
  21. *out = pData->m_Value.m_Int;
  22. CHudBossHealthMeter *meter = GET_HUDELEMENT( CHudBossHealthMeter );
  23. if ( meter )
  24. {
  25. meter->Update();
  26. }
  27. }
  28. //-----------------------------------------------------------------------------
  29. C_MonsterResource::C_MonsterResource()
  30. {
  31. m_iBossHealthPercentageByte = 0;
  32. m_iBossStunPercentageByte = 0;
  33. m_iSkillShotCompleteCount = 0;
  34. m_fSkillShotComboEndTime = 0;
  35. m_iBossState = 0;
  36. // do this here because entity is created via network messages from the server entity's creation
  37. Assert( g_pMonsterResource == NULL );
  38. g_pMonsterResource = this;
  39. }
  40. //-----------------------------------------------------------------------------
  41. C_MonsterResource::~C_MonsterResource()
  42. {
  43. Assert( g_pMonsterResource == this );
  44. g_pMonsterResource = NULL;
  45. }
  46. //-----------------------------------------------------------------------------
  47. float C_MonsterResource::GetBossHealthPercentage( void )
  48. {
  49. return (float)m_iBossHealthPercentageByte / 255.0f;
  50. }
  51. //-----------------------------------------------------------------------------
  52. float C_MonsterResource::GetBossStunPercentage( void )
  53. {
  54. return (float)m_iBossStunPercentageByte / 255.0f;
  55. }