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.

58 lines
1.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef C_TE_EFFECT_DISPATCH_H
  8. #define C_TE_EFFECT_DISPATCH_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "effect_dispatch_data.h"
  13. #include "precache_register.h"
  14. typedef void (*ClientEffectCallback)( const CEffectData &data );
  15. class CClientEffectRegistration
  16. {
  17. public:
  18. CClientEffectRegistration( const char *pEffectName, ClientEffectCallback fn );
  19. public:
  20. const char *m_pEffectName;
  21. ClientEffectCallback m_pFunction;
  22. CClientEffectRegistration *m_pNext;
  23. static CClientEffectRegistration *s_pHead;
  24. };
  25. //
  26. // Use this macro to register a client effect callback.
  27. // If you do DECLARE_CLIENT_EFFECT( MyEffectName, MyCallback ), then MyCallback will be
  28. // called when the server does DispatchEffect( "MyEffectName", data )
  29. //
  30. #define DECLARE_CLIENT_EFFECT_INTERNAL( effectName, callbackFunction ) \
  31. static CClientEffectRegistration ClientEffectReg_##callbackFunction( #effectName, callbackFunction );
  32. #define DECLARE_CLIENT_EFFECT( effectName, callbackFunction ) \
  33. DECLARE_CLIENT_EFFECT_INTERNAL( effectName, callbackFunction ) \
  34. PRECACHE_REGISTER_BEGIN( DISPATCH_EFFECT, effectName ) \
  35. PRECACHE_REGISTER_END()
  36. #define DECLARE_CLIENT_EFFECT_BEGIN( effectName, callbackFunction ) \
  37. DECLARE_CLIENT_EFFECT_INTERNAL( effectName, callbackFunction ) \
  38. PRECACHE_REGISTER_BEGIN( DISPATCH_EFFECT, effectName )
  39. #define DECLARE_CLIENT_EFFECT_END() PRECACHE_REGISTER_END()
  40. void DispatchEffectToCallback( const char *pEffectName, const CEffectData &m_EffectData );
  41. void DispatchEffect( const char *pName, const CEffectData &data );
  42. void DispatchEffect( IRecipientFilter& filter, float flDelay, const char *pName, const CEffectData &data );
  43. void DispatchEffect( IRecipientFilter& filter, float delay, KeyValues *pKeyValues );
  44. #endif // C_TE_EFFECT_DISPATCH_H