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.

105 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. //========= Copyright � 1996-2001, Valve LLC, All rights reserved. ============
  8. //
  9. // Purpose:
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================
  13. #include "cbase.h"
  14. #include "gamemovement.h"
  15. #include "tfc_gamerules.h"
  16. #include "tfc_shareddefs.h"
  17. #include "in_buttons.h"
  18. #include "movevars_shared.h"
  19. #ifdef CLIENT_DLL
  20. #include "c_tfc_player.h"
  21. #else
  22. #include "tfc_player.h"
  23. #endif
  24. class CTFCGameMovement : public CGameMovement
  25. {
  26. public:
  27. DECLARE_CLASS( CTFCGameMovement, CGameMovement );
  28. CTFCGameMovement();
  29. virtual void ProcessMovement( CBasePlayer *pBasePlayer, CMoveData *pMove );
  30. virtual bool CanAccelerate();
  31. virtual bool CheckJumpButton();
  32. private:
  33. CTFCPlayer *m_pTFCPlayer;
  34. };
  35. // Expose our interface.
  36. static CTFCGameMovement g_GameMovement;
  37. IGameMovement *g_pGameMovement = ( IGameMovement * )&g_GameMovement;
  38. EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CGameMovement, IGameMovement,INTERFACENAME_GAMEMOVEMENT, g_GameMovement );
  39. // ---------------------------------------------------------------------------------------- //
  40. // CTFCGameMovement.
  41. // ---------------------------------------------------------------------------------------- //
  42. CTFCGameMovement::CTFCGameMovement()
  43. {
  44. m_vecViewOffsetNormal = TFC_PLAYER_VIEW_OFFSET;
  45. m_pTFCPlayer = NULL;
  46. }
  47. void CTFCGameMovement::ProcessMovement( CBasePlayer *pBasePlayer, CMoveData *pMove )
  48. {
  49. m_pTFCPlayer = ToTFCPlayer( pBasePlayer );
  50. Assert( m_pTFCPlayer );
  51. BaseClass::ProcessMovement( pBasePlayer, pMove );
  52. }
  53. bool CTFCGameMovement::CanAccelerate()
  54. {
  55. // Only allow the player to accelerate when in certain states.
  56. TFCPlayerState curState = m_pTFCPlayer->m_Shared.State_Get();
  57. if ( curState == STATE_ACTIVE )
  58. {
  59. return player->GetWaterJumpTime() == 0;
  60. }
  61. else if ( player->IsObserver() )
  62. {
  63. return true;
  64. }
  65. else
  66. {
  67. return false;
  68. }
  69. }
  70. bool CTFCGameMovement::CheckJumpButton()
  71. {
  72. if ( BaseClass::CheckJumpButton() )
  73. {
  74. m_pTFCPlayer->DoAnimationEvent( PLAYERANIMEVENT_JUMP );
  75. return true;
  76. }
  77. else
  78. {
  79. return false;
  80. }
  81. }