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.

56 lines
1.3 KiB

  1. //========= Copyright � 1996-2007, 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 CProxyIsNPC : 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 CProxyIsNPC::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 CProxyIsNPC::OnBind( void *pC_BaseEntity )
  32. {
  33. if ( !pC_BaseEntity )
  34. return;
  35. C_BaseEntity *pEntity = BindArgToEntity( pC_BaseEntity );
  36. if ( pEntity && pEntity->IsNPC() )
  37. {
  38. SetFloatResult( m_Factor.GetFloat() );
  39. }
  40. else
  41. {
  42. SetFloatResult( 0.0f );
  43. }
  44. }
  45. EXPOSE_MATERIAL_PROXY( CProxyIsNPC, IsNPC );