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.

75 lines
2.1 KiB

  1. //========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: These are a couple of base proxy classes to help us with
  4. // getting/setting source/result material vars
  5. //
  6. // $NoKeywords: $
  7. //=============================================================================//
  8. #ifndef FUNCTIONPROXY_H
  9. #define FUNCTIONPROXY_H
  10. #include "materialsystem/imaterialproxy.h"
  11. #include "materialsystem/imaterialvar.h"
  12. class IMaterialVar;
  13. class C_BaseEntity;
  14. //-----------------------------------------------------------------------------
  15. // Helper class to deal with floating point inputs
  16. //-----------------------------------------------------------------------------
  17. class CFloatInput
  18. {
  19. public:
  20. bool Init( IMaterial *pMaterial, KeyValues *pKeyValues, const char *pKeyName, float flDefault = 0.0f );
  21. float GetFloat() const;
  22. private:
  23. float m_flValue;
  24. IMaterialVar *m_pFloatVar;
  25. int m_FloatVecComp;
  26. };
  27. //-----------------------------------------------------------------------------
  28. // Result proxy; a result (with vector friendliness)
  29. //-----------------------------------------------------------------------------
  30. class CResultProxy : public IMaterialProxy
  31. {
  32. public:
  33. CResultProxy();
  34. virtual ~CResultProxy();
  35. virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
  36. virtual void Release( void ) { delete this; }
  37. virtual IMaterial *GetMaterial();
  38. protected:
  39. C_BaseEntity *BindArgToEntity( void *pArg );
  40. void SetFloatResult( float result );
  41. void SetVecResult( float x, float y, float z, float w );
  42. IMaterialVar* m_pResult;
  43. int m_ResultVecComp;
  44. };
  45. //-----------------------------------------------------------------------------
  46. // Base functional proxy; two sources (one is optional) and a result
  47. //-----------------------------------------------------------------------------
  48. class CFunctionProxy : public CResultProxy
  49. {
  50. public:
  51. CFunctionProxy();
  52. virtual ~CFunctionProxy();
  53. virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
  54. protected:
  55. void ComputeResultType( MaterialVarType_t& resultType, int& vecSize );
  56. IMaterialVar* m_pSrc1;
  57. IMaterialVar* m_pSrc2;
  58. };
  59. #endif // FUNCTIONPROXY_H