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.

130 lines
4.0 KiB

  1. //========= Copyright 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. EntityHandle_t m_nPlayerHandle; // edict index on server, client entity handle on client
  35. int m_nImpulseCommand; // Impulse command issued.
  36. QAngle m_vecViewAngles; // Command view angles (local space)
  37. QAngle m_vecAbsViewAngles; // Command view angles (world space)
  38. int m_nButtons; // Attack buttons.
  39. int m_nOldButtons; // From host_client->oldbuttons;
  40. float m_flForwardMove;
  41. float m_flOldForwardMove;
  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. QAngle m_vecAngles; // edict::angles
  50. QAngle m_vecOldAngles;
  51. // Output only
  52. float m_outStepHeight; // how much you climbed this move
  53. Vector m_outWishVel; // This is where you tried
  54. Vector m_outJumpVel; // This is your jump velocity
  55. // Movement constraints (radius 0 means no constraint)
  56. Vector m_vecConstraintCenter;
  57. float m_flConstraintRadius;
  58. float m_flConstraintWidth;
  59. float m_flConstraintSpeedFactor;
  60. void SetAbsOrigin( const Vector &vec );
  61. const Vector &GetAbsOrigin() const;
  62. private:
  63. Vector m_vecAbsOrigin; // edict::origin
  64. };
  65. inline const Vector &CMoveData::GetAbsOrigin() const
  66. {
  67. return m_vecAbsOrigin;
  68. }
  69. #if !defined( CLIENT_DLL ) && defined( _DEBUG )
  70. // We only ever want this code path on the server side in a debug build
  71. // and you have to uncomment the code below and rebuild to have the test operate.
  72. //#define PLAYER_GETTING_STUCK_TESTING
  73. #endif
  74. #if !defined( PLAYER_GETTING_STUCK_TESTING )
  75. // This is implemented with a more exhaustive test in gamemovement.cpp. We check if the origin being requested is
  76. // inside solid, which it never should be
  77. inline void CMoveData::SetAbsOrigin( const Vector &vec )
  78. {
  79. m_vecAbsOrigin = vec;
  80. }
  81. #endif
  82. //-----------------------------------------------------------------------------
  83. // Purpose: The basic player movement interface
  84. //-----------------------------------------------------------------------------
  85. abstract_class IGameMovement
  86. {
  87. public:
  88. virtual ~IGameMovement( void ) {}
  89. // Process the current movement command
  90. virtual void ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMove ) = 0;
  91. virtual void StartTrackPredictionErrors( CBasePlayer *pPlayer ) = 0;
  92. virtual void FinishTrackPredictionErrors( CBasePlayer *pPlayer ) = 0;
  93. virtual void DiffPrint( PRINTF_FORMAT_STRING char const *fmt, ... ) = 0;
  94. // Allows other parts of the engine to find out the normal and ducked player bbox sizes
  95. virtual Vector GetPlayerMins( bool ducked ) const = 0;
  96. virtual Vector GetPlayerMaxs( bool ducked ) const = 0;
  97. virtual Vector GetPlayerViewOffset( bool ducked ) const = 0;
  98. };
  99. #endif // IGAMEMOVEMENT_H