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.

139 lines
4.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #if !defined( IGAMEMOVEMENT_H )
  10. #define IGAMEMOVEMENT_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "mathlib/vector.h"
  15. #include "interface.h"
  16. #include "imovehelper.h"
  17. #include "const.h"
  18. //-----------------------------------------------------------------------------
  19. // Name of the class implementing the game movement.
  20. //-----------------------------------------------------------------------------
  21. #define INTERFACENAME_GAMEMOVEMENT "GameMovement001"
  22. //-----------------------------------------------------------------------------
  23. // Forward declarations.
  24. //-----------------------------------------------------------------------------
  25. class IMoveHelper;
  26. //-----------------------------------------------------------------------------
  27. // Purpose: Encapsulated input parameters to player movement.
  28. //-----------------------------------------------------------------------------
  29. class CMoveData
  30. {
  31. public:
  32. bool m_bFirstRunOfFunctions : 1;
  33. bool m_bGameCodeMovedPlayer : 1;
  34. bool m_bNoAirControl : 1;
  35. EntityHandle_t m_nPlayerHandle; // edict index on server, client entity handle on client
  36. int m_nImpulseCommand; // Impulse command issued.
  37. QAngle m_vecViewAngles; // Command view angles (local space)
  38. QAngle m_vecAbsViewAngles; // Command view angles (world space)
  39. int m_nButtons; // Attack buttons.
  40. int m_nOldButtons; // From host_client->oldbuttons;
  41. float m_flForwardMove;
  42. float m_flSideMove;
  43. float m_flUpMove;
  44. float m_flMaxSpeed;
  45. float m_flClientMaxSpeed;
  46. // Variables from the player edict (sv_player) or entvars on the client.
  47. // These are copied in here before calling and copied out after calling.
  48. Vector m_vecVelocity; // edict::velocity // Current movement direction.
  49. Vector m_vecTrailingVelocity;
  50. float m_flTrailingVelocityTime;
  51. QAngle m_vecAngles; // edict::angles
  52. QAngle m_vecOldAngles;
  53. // Output only
  54. float m_outStepHeight; // how much you climbed this move
  55. Vector m_outWishVel; // This is where you tried
  56. Vector m_outJumpVel; // This is your jump velocity
  57. // Movement constraints (radius 0 means no constraint)
  58. Vector m_vecConstraintCenter;
  59. float m_flConstraintRadius;
  60. float m_flConstraintWidth;
  61. float m_flConstraintSpeedFactor;
  62. bool m_bConstraintPastRadius; ///< If no, do no constraining past Radius. If yes, cap them to SpeedFactor past radius
  63. void SetAbsOrigin( const Vector &vec );
  64. const Vector &GetAbsOrigin() const;
  65. private:
  66. Vector m_vecAbsOrigin; // edict::origin
  67. };
  68. inline const Vector &CMoveData::GetAbsOrigin() const
  69. {
  70. return m_vecAbsOrigin;
  71. }
  72. #if !defined( CLIENT_DLL ) && defined( _DEBUG )
  73. // We only ever want this code path on the server side in a debug build
  74. // and you have to uncomment the code below and rebuild to have the test operate.
  75. //#define PLAYER_GETTING_STUCK_TESTING
  76. #endif
  77. #if !defined( PLAYER_GETTING_STUCK_TESTING )
  78. // This is implemented with a more exhaustive test in gamemovement.cpp. We check if the origin being requested is
  79. // inside solid, which it never should be
  80. inline void CMoveData::SetAbsOrigin( const Vector &vec )
  81. {
  82. m_vecAbsOrigin = vec;
  83. }
  84. #endif
  85. //-----------------------------------------------------------------------------
  86. // Purpose: The basic player movement interface
  87. //-----------------------------------------------------------------------------
  88. abstract_class IGameMovement
  89. {
  90. public:
  91. virtual ~IGameMovement( void ) {}
  92. // Process the current movement command
  93. virtual void ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMove ) = 0;
  94. virtual void Reset( void ) = 0;
  95. virtual void StartTrackPredictionErrors( CBasePlayer *pPlayer ) = 0;
  96. virtual void FinishTrackPredictionErrors( CBasePlayer *pPlayer ) = 0;
  97. virtual void DiffPrint( PRINTF_FORMAT_STRING char const *fmt, ... ) = 0;
  98. // Allows other parts of the engine to find out the normal and ducked player bbox sizes
  99. virtual Vector const& GetPlayerMins( bool ducked ) const = 0;
  100. virtual Vector const& GetPlayerMaxs( bool ducked ) const = 0;
  101. virtual Vector const& GetPlayerViewOffset( bool ducked ) const = 0;
  102. virtual bool IsMovingPlayerStuck( void ) const = 0;
  103. virtual CBasePlayer *GetMovingPlayer( void ) const = 0;
  104. virtual void UnblockPusher( CBasePlayer *pPlayer, CBaseEntity *pPusher ) = 0;
  105. virtual void SetupMovementBounds( CMoveData *pMove ) = 0;
  106. };
  107. #endif // IGAMEMOVEMENT_H