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.

63 lines
1.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "functionproxy.h"
  9. #include "toolframework_client.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. // forward declarations
  13. void ToolFramework_RecordMaterialParams( IMaterial *pMaterial );
  14. //-----------------------------------------------------------------------------
  15. // Returns the player health (from 0 to 1)
  16. //-----------------------------------------------------------------------------
  17. class CProxyIsNPC : public CResultProxy
  18. {
  19. public:
  20. bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
  21. void OnBind( void *pC_BaseEntity );
  22. private:
  23. CFloatInput m_Factor;
  24. };
  25. bool CProxyIsNPC::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
  26. {
  27. if (!CResultProxy::Init( pMaterial, pKeyValues ))
  28. return false;
  29. if (!m_Factor.Init( pMaterial, pKeyValues, "scale", 1 ))
  30. return false;
  31. return true;
  32. }
  33. void CProxyIsNPC::OnBind( void *pC_BaseEntity )
  34. {
  35. if ( !pC_BaseEntity )
  36. return;
  37. C_BaseEntity *pEntity = BindArgToEntity( pC_BaseEntity );
  38. if ( pEntity && pEntity->IsNPC() )
  39. {
  40. SetFloatResult( m_Factor.GetFloat() );
  41. }
  42. else
  43. {
  44. SetFloatResult( 0.0f );
  45. }
  46. if ( ToolsEnabled() )
  47. {
  48. ToolFramework_RecordMaterialParams( GetMaterial() );
  49. }
  50. }
  51. EXPOSE_INTERFACE( CProxyIsNPC, IMaterialProxy, "IsNPC" IMATERIAL_PROXY_INTERFACE_VERSION );