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.

115 lines
3.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef IMOVEHELPER_H
  8. #define IMOVEHELPER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. //-----------------------------------------------------------------------------
  13. // Forward declarations
  14. //-----------------------------------------------------------------------------
  15. enum PLAYER_ANIM;
  16. class IPhysicsSurfaceProps;
  17. class Vector;
  18. struct model_t;
  19. struct cmodel_t;
  20. struct vcollide_t;
  21. class CGameTrace;
  22. enum soundlevel_t;
  23. //-----------------------------------------------------------------------------
  24. // Purpose: Identifies how submerged in water a player is.
  25. //-----------------------------------------------------------------------------
  26. enum
  27. {
  28. WL_NotInWater=0,
  29. WL_Feet,
  30. WL_Waist,
  31. WL_Eyes
  32. };
  33. //-----------------------------------------------------------------------------
  34. // An entity identifier that works in both game + client dlls
  35. //-----------------------------------------------------------------------------
  36. typedef CBaseHandle EntityHandle_t;
  37. #define INVALID_ENTITY_HANDLE INVALID_EHANDLE_INDEX
  38. //-----------------------------------------------------------------------------
  39. // Functions the engine provides to IGameMovement to assist in its movement.
  40. //-----------------------------------------------------------------------------
  41. abstract_class IMoveHelper
  42. {
  43. public:
  44. // Call this to set the singleton
  45. static IMoveHelper* GetSingleton( ) { return sm_pSingleton; }
  46. // Methods associated with a particular entity
  47. virtual char const* GetName( EntityHandle_t handle ) const = 0;
  48. // Adds the trace result to touch list, if contact is not already in list.
  49. virtual void ResetTouchList( void ) = 0;
  50. virtual bool AddToTouched( const CGameTrace& tr, const Vector& impactvelocity ) = 0;
  51. virtual void ProcessImpacts( void ) = 0;
  52. // Numbered line printf
  53. virtual void Con_NPrintf( int idx, PRINTF_FORMAT_STRING char const* fmt, ... ) = 0;
  54. // These have separate server vs client impementations
  55. virtual void StartSound( const Vector& origin, int channel, char const* sample, float volume, soundlevel_t soundlevel, int fFlags, int pitch ) = 0;
  56. virtual void StartSound( const Vector& origin, const char *soundname ) = 0;
  57. virtual void PlaybackEventFull( int flags, int clientindex, unsigned short eventindex, float delay, Vector& origin, Vector& angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ) = 0;
  58. // Apply falling damage to m_pHostPlayer based on m_pHostPlayer->m_flFallVelocity.
  59. virtual bool PlayerFallingDamage( void ) = 0;
  60. // Apply falling damage to m_pHostPlayer based on m_pHostPlayer->m_flFallVelocity.
  61. virtual void PlayerSetAnimation( PLAYER_ANIM playerAnim ) = 0;
  62. virtual IPhysicsSurfaceProps *GetSurfaceProps( void ) = 0;
  63. virtual bool IsWorldEntity( const CBaseHandle &handle ) = 0;
  64. protected:
  65. // Inherited classes can call this to set the singleton
  66. static void SetSingleton( IMoveHelper* pMoveHelper ) { sm_pSingleton = pMoveHelper; }
  67. // Clients shouldn't call delete directly
  68. virtual ~IMoveHelper() {}
  69. // The global instance
  70. static IMoveHelper* sm_pSingleton;
  71. };
  72. //-----------------------------------------------------------------------------
  73. // Add this to the CPP file that implements the IMoveHelper
  74. //-----------------------------------------------------------------------------
  75. #define IMPLEMENT_MOVEHELPER() \
  76. IMoveHelper* IMoveHelper::sm_pSingleton = 0
  77. //-----------------------------------------------------------------------------
  78. // Call this to set the singleton
  79. //-----------------------------------------------------------------------------
  80. inline IMoveHelper* MoveHelper( )
  81. {
  82. return IMoveHelper::GetSingleton();
  83. }
  84. #endif // IMOVEHELPER_H