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.

96 lines
3.3 KiB

  1. // NextBotPathFollow.h
  2. // Path following
  3. // Author: Michael Booth, April 2005
  4. // Copyright (c) 2005 Turtle Rock Studios, Inc. - All Rights Reserved
  5. #ifndef _NEXT_BOT_PATH_FOLLOWER_
  6. #define _NEXT_BOT_PATH_FOLLOWER_
  7. #include "nav_mesh.h"
  8. #include "nav_pathfind.h"
  9. #include "NextBotPath.h"
  10. class INextBot;
  11. class ILocomotion;
  12. //--------------------------------------------------------------------------------------------------------
  13. /**
  14. * A PathFollower extends a Path to include mechanisms to move along (follow) it
  15. */
  16. class PathFollower : public Path
  17. {
  18. public:
  19. PathFollower( void );
  20. virtual ~PathFollower();
  21. virtual void Invalidate( void ); // (EXTEND) cause the path to become invalid
  22. virtual void Draw( const Path::Segment *start = NULL ) const; // (EXTEND) draw the path for debugging
  23. virtual void OnPathChanged( INextBot *bot, Path::ResultType result ); // invoked when the path is (re)computed (path is valid at the time of this call)
  24. virtual void Update( INextBot *bot ); // move bot along path
  25. virtual const Path::Segment *GetCurrentGoal( void ) const; // return current goal along the path we are trying to reach
  26. virtual void SetMinLookAheadDistance( float value ); // minimum range movement goal must be along path
  27. virtual CBaseEntity *GetHindrance( void ) const; // returns entity that is hindering our progress along the path
  28. virtual bool IsDiscontinuityAhead( INextBot *bot, Path::SegmentType type, float range = -1.0f ) const; // return true if there is a the given discontinuity ahead in the path within the given range (-1 = entire remaining path)
  29. private:
  30. const Path::Segment *m_goal; // our current goal along the path
  31. float m_minLookAheadRange;
  32. bool CheckProgress( INextBot *bot );
  33. bool IsAtGoal( INextBot *bot ) const; // return true if reached current path goal
  34. //bool IsOnStairs( INextBot *bot ) const; // return true if bot is standing on a stairway
  35. bool m_isOnStairs;
  36. CountdownTimer m_avoidTimer; // do avoid check more often if we recently avoided
  37. CountdownTimer m_waitTimer; // for waiting for a blocker to move off our path
  38. CHandle< CBaseEntity > m_hindrance;
  39. // debug display data for avoid volumes
  40. bool m_didAvoidCheck;
  41. Vector m_leftFrom;
  42. Vector m_leftTo;
  43. bool m_isLeftClear;
  44. Vector m_rightFrom;
  45. Vector m_rightTo;
  46. bool m_isRightClear;
  47. Vector m_hullMin, m_hullMax;
  48. void AdjustSpeed( INextBot *bot ); // adjust speed based on path curvature
  49. Vector Avoid( INextBot *bot, const Vector &goalPos, const Vector &forward, const Vector &left ); // avoidance movements for very nearby obstacles. returns modified goal position
  50. bool Climbing( INextBot *bot, const Path::Segment *goal, const Vector &forward, const Vector &left, float goalRange ); // climb up ledges
  51. bool JumpOverGaps( INextBot *bot, const Path::Segment *goal, const Vector &forward, const Vector &left, float goalRange ); // jump over gaps
  52. bool LadderUpdate( INextBot *bot ); // move bot along ladder
  53. CBaseEntity *FindBlocker( INextBot *bot ); // if entity is returned, it is blocking us from continuing along our path
  54. };
  55. inline const Path::Segment *PathFollower::GetCurrentGoal( void ) const
  56. {
  57. return m_goal;
  58. }
  59. inline void PathFollower::SetMinLookAheadDistance( float value )
  60. {
  61. m_minLookAheadRange = value;
  62. }
  63. inline CBaseEntity *PathFollower::GetHindrance( void ) const
  64. {
  65. return m_hindrance;
  66. }
  67. #endif // _NEXT_BOT_PATH_FOLLOWER_