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.

170 lines
5.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Special handling for Portal usable ladders
  4. //
  5. //=============================================================================//
  6. #ifndef PORTAL_GAMEMOVEMENT_H
  7. #define PORTAL_GAMEMOVEMENT_H
  8. #include "cbase.h"
  9. #include "hl_gamemovement.h"
  10. #if defined( CLIENT_DLL )
  11. #include "c_portal_player.h"
  12. #else
  13. #include "portal_player.h"
  14. #endif
  15. class CTrace_PlayerAABB_vs_Portals;
  16. //-----------------------------------------------------------------------------
  17. // Purpose: Portal specific movement code
  18. //-----------------------------------------------------------------------------
  19. class CPortalGameMovement : public CGameMovement
  20. {
  21. typedef CGameMovement BaseClass;
  22. public:
  23. CPortalGameMovement();
  24. bool m_bInPortalEnv;
  25. // Overrides
  26. virtual void ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMove );
  27. virtual const Vector& GetPlayerMins( bool ducked ) const;
  28. virtual const Vector& GetPlayerMaxs( bool ducked ) const;
  29. virtual const Vector& GetPlayerViewOffset( bool ducked ) const;
  30. virtual void SetupMovementBounds( CMoveData *pMove );
  31. virtual bool CheckJumpButton( void );
  32. Vector PortalFunnel( const Vector &wishdir );
  33. // Traces the player bbox as it is swept from start to end
  34. virtual void TracePlayerBBox( const Vector& start, const Vector& end, unsigned int fMask, int collisionGroup, CTrace_PlayerAABB_vs_Portals& pm );
  35. virtual void TracePlayerBBox( const Vector& start, const Vector& end, unsigned int fMask, int collisionGroup, trace_t& pm );
  36. // Tests the player position
  37. virtual CBaseHandle TestPlayerPosition( const Vector& pos, int collisionGroup, trace_t& pm );
  38. virtual int CheckStuck( void );
  39. virtual void SetGroundEntity( trace_t *pm );
  40. void HandlePortalling( void );
  41. protected:
  42. CPortal_Player *GetPortalPlayer() const;
  43. bool IsInPortalFunnelVolume( const Vector& vPlayerToPortal, const CPortal_Base2D* pPortal, const float flExtentX, const float flExtentY ) const;
  44. // Does most of the player movement logic.
  45. // Returns with origin, angles, and velocity modified in place.
  46. // were contacted during the move.
  47. virtual void PlayerMove();
  48. // Handles both ground friction and water friction
  49. virtual void Friction();
  50. virtual void TBeamMove();
  51. virtual void AirMove();
  52. virtual void AirAccelerate( Vector& wishdir, float wishspeed, float accel );
  53. // Only used by players. Moves along the ground when player is a MOVETYPE_WALK.
  54. virtual void WalkMove();
  55. virtual void WaterMove();
  56. // Try to keep a walking player on the ground when running down slopes etc
  57. virtual void StayOnGround();
  58. virtual void CheckWallImpact( Vector& primal_velocity );
  59. // Handle MOVETYPE_WALK.
  60. virtual void FullWalkMove();
  61. // Implement this if you want to know when the player collides during OnPlayerMove
  62. virtual void OnTryPlayerMoveCollision( trace_t &tr ) {}
  63. virtual const Vector& GetPlayerMins() const; // uses local player
  64. virtual const Vector& GetPlayerMaxs() const; // uses local player
  65. // Decompoosed gravity
  66. virtual void StartGravity();
  67. virtual void FinishGravity();
  68. // Apply normal ( undecomposed ) gravity
  69. virtual void AddGravity();
  70. // The basic solid body movement clip that slides along multiple planes
  71. virtual int TryPlayerMove( Vector *pFirstDest = NULL, trace_t *pFirstTrace = NULL );
  72. // Slide off of the impacting object
  73. // returns the blocked flags:
  74. // 0x01 == floor
  75. // 0x02 == step / wall
  76. virtual int ClipVelocity( Vector& in, Vector& normal, Vector& out, float overbounce );
  77. // Determine if player is in water, on ground, etc.
  78. virtual void CategorizePosition();
  79. virtual void CheckParameters();
  80. virtual void PlayerRoughLandingEffects( float fvol );
  81. virtual void PlayerWallImpactEffects( float fvol, float normalVelocity );
  82. virtual void PlayerCeilingImpactEffects( float fvol );
  83. // Ducking
  84. virtual void Duck();
  85. virtual void FinishUnDuck();
  86. virtual void FinishDuck();
  87. virtual bool CanUnduck();
  88. virtual void UpdateDuckJumpEyeOffset();
  89. virtual bool CanUnDuckJump( trace_t &trace );
  90. virtual void StartUnDuckJump();
  91. virtual void FinishUnDuckJump( trace_t &trace );
  92. virtual void SetDuckedEyeOffset( float duckFraction );
  93. virtual void FixPlayerCrouchStuck( bool moveup );
  94. virtual void CategorizeGroundSurface( trace_t &pm );
  95. virtual void StepMove( Vector &vecDestination, trace_t &trace );
  96. virtual bool GameHasLadders() const { return false; }
  97. private:
  98. virtual bool PlayerShouldFunnel( const CPortal_Base2D* pPortal, const Vector& vPlayerForward, const Vector& wishDir ) const;
  99. void AirPortalFunnel( Vector& wishdir,
  100. const Vector& vPlayerToFunnelPortal,
  101. float flExtraFunnelForce,
  102. float flTimeToPortal );
  103. void GroundPortalFunnel( Vector& wishdir,
  104. const Vector& vPlayerToPortalFunnel,
  105. const Vector& vPortalNormal,
  106. float flExtraFunnelForce,
  107. float flTimeToPortal );
  108. #if defined( CLIENT_DLL )
  109. void ClientVerticalElevatorFixes( CBasePlayer *pPlayer, CMoveData *pMove );
  110. #endif
  111. // Stick is done by changing gravity direction because it's easier to think about that way.
  112. // Gravity direction is always the negation of the player's stick normal.
  113. Vector m_vGravityDirection;
  114. Vector m_vMoveStartPosition; //where the player started before the movement code ran
  115. };
  116. //trace that has special understanding of how to handle portals
  117. class CTrace_PlayerAABB_vs_Portals : public CGameTrace
  118. {
  119. public:
  120. CTrace_PlayerAABB_vs_Portals( void );
  121. bool HitPortalRamp( const Vector &vUp );
  122. bool m_bContactedPortalTransitionRamp;
  123. };
  124. #endif //PORTAL_GAMEMOVEMENT_H