Counter Strike : Global Offensive Source Code
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.

51 lines
1.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "functionproxy.h"
  9. #include "imaterialproxydict.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. //-----------------------------------------------------------------------------
  13. // Returns the player health (from 0 to 1)
  14. //-----------------------------------------------------------------------------
  15. class CProxyHealth : public CResultProxy
  16. {
  17. public:
  18. bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
  19. void OnBind( void *pC_BaseEntity );
  20. private:
  21. CFloatInput m_Factor;
  22. };
  23. bool CProxyHealth::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
  24. {
  25. if (!CResultProxy::Init( pMaterial, pKeyValues ))
  26. return false;
  27. if (!m_Factor.Init( pMaterial, pKeyValues, "scale", 1 ))
  28. return false;
  29. return true;
  30. }
  31. void CProxyHealth::OnBind( void *pC_BaseEntity )
  32. {
  33. if (!pC_BaseEntity)
  34. return;
  35. C_BaseEntity *pEntity = BindArgToEntity( pC_BaseEntity );
  36. Assert( m_pResult );
  37. SetFloatResult( pEntity->HealthFraction() * m_Factor.GetFloat() );
  38. }
  39. EXPOSE_MATERIAL_PROXY( CProxyHealth, Health );