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.

78 lines
2.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef AI_LOCALNAVIGATOR_H
  7. #define AI_LOCALNAVIGATOR_H
  8. #include "simtimer.h"
  9. #include "ai_component.h"
  10. #include "ai_movetypes.h"
  11. #include "ai_obstacle_type.h"
  12. #if defined( _WIN32 )
  13. #pragma once
  14. #endif
  15. class CAI_PlaneSolver;
  16. class CAI_MoveProbe;
  17. FORWARD_DECLARE_HANDLE( Obstacle_t );
  18. //-----------------------------------------------------------------------------
  19. // CAI_LocalNavigator
  20. //
  21. // Purpose: Handles all the immediate tasks of navigation, independent of
  22. // path. Implements steering.
  23. //-----------------------------------------------------------------------------
  24. class CAI_LocalNavigator : public CAI_Component,
  25. public CAI_ProxyMovementSink
  26. {
  27. public:
  28. CAI_LocalNavigator(CAI_BaseNPC *pOuter);
  29. virtual ~CAI_LocalNavigator();
  30. void Init( IAI_MovementSink *pMovementServices );
  31. //---------------------------------
  32. AIMoveResult_t MoveCalc( AILocalMoveGoal_t *pResult, bool bPreviouslyValidated = false );
  33. void ResetMoveCalculations();
  34. //---------------------------------
  35. void AddObstacle( const Vector &pos, float radius, AI_MoveSuggType_t type = AIMST_AVOID_OBJECT );
  36. bool HaveObstacles();
  37. static Obstacle_t AddGlobalObstacle( const Vector &pos, float radius, AI_MoveSuggType_t type = AIMST_AVOID_OBJECT );
  38. static void RemoveGlobalObstacle( Obstacle_t hObstacle );
  39. static void RemoveGlobalObstacles( void );
  40. static bool IsSegmentBlockedByGlobalObstacles( const Vector &vecStart, const Vector &vecEnd );
  41. protected:
  42. AIMoveResult_t MoveCalcRaw( AILocalMoveGoal_t *pResult, bool bOnlyCurThink );
  43. bool MoveCalcDirect( AILocalMoveGoal_t *pMoveGoal, bool bOnlyCurThink, float *pDistClear, AIMoveResult_t *pResult );
  44. bool MoveCalcSteer( AILocalMoveGoal_t *pMoveGoal, float distClear, AIMoveResult_t *pResult );
  45. bool MoveCalcStop( AILocalMoveGoal_t *pMoveGoal, float distClear, AIMoveResult_t *pResult );
  46. CAI_MoveProbe * GetMoveProbe() { return m_pMoveProbe; }
  47. const CAI_MoveProbe *GetMoveProbe() const { return m_pMoveProbe; }
  48. private:
  49. // --------------------------------
  50. bool m_fLastWasClear;
  51. AILocalMoveGoal_t m_LastMoveGoal;
  52. CSimpleSimTimer m_FullDirectTimer;
  53. CAI_PlaneSolver * m_pPlaneSolver;
  54. CAI_MoveProbe * m_pMoveProbe;
  55. DECLARE_SIMPLE_DATADESC();
  56. };
  57. #endif // AI_LOCALNAVIGATOR_H