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.

761 lines
24 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef AI_NAVIGATOR_H
  8. #define AI_NAVIGATOR_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "simtimer.h"
  13. #include "ai_component.h"
  14. #include "ai_navgoaltype.h"
  15. #include "ai_navtype.h"
  16. #include "ai_motor.h"
  17. class CAI_BaseNPC;
  18. class CAI_Motor;
  19. class CAI_Route;
  20. class CAI_Path;
  21. class CAI_Pathfinder;
  22. class CAI_LocalNavigator;
  23. struct AI_Waypoint_t;
  24. class CAI_WaypointList;
  25. class CAI_Network;
  26. struct AIMoveTrace_t;
  27. struct AILocalMoveGoal_t;
  28. typedef int AI_TaskFailureCode_t;
  29. //-----------------------------------------------------------------------------
  30. // Debugging tools
  31. //-----------------------------------------------------------------------------
  32. #define DEBUG_AI_NAVIGATION 1
  33. #ifdef DEBUG_AI_NAVIGATION
  34. extern ConVar ai_debug_nav;
  35. #define DbgNav() ai_debug_nav.GetBool()
  36. #define DbgNavMsg( pAI, pszMsg ) \
  37. do \
  38. { \
  39. if (DbgNav()) \
  40. DevMsg( pAI, "[Nav] %s", static_cast<const char *>(pszMsg) ); \
  41. } while (0)
  42. #define DbgNavMsg1( pAI, pszMsg, a ) DbgNavMsg( pAI, CFmtStr(static_cast<const char *>(pszMsg), (a) ) )
  43. #define DbgNavMsg2( pAI, pszMsg, a, b ) DbgNavMsg( pAI, CFmtStr(static_cast<const char *>(pszMsg), (a), (b) ) )
  44. #else
  45. #define DbgNav() false
  46. #define DbgNavMsg( pAI, pszMsg ) ((void)0)
  47. #define DbgNavMsg1( pAI, pszMsg, a ) ((void)0)
  48. #define DbgNavMsg2( pAI, pszMsg, a, b ) ((void)0)
  49. #endif
  50. //-----------------------------------------------------------------------------
  51. // STRUCTURES & ENUMERATIONS
  52. //-----------------------------------------------------------------------------
  53. DECLARE_POINTER_HANDLE( AI_PathNode_t );
  54. //-------------------------------------
  55. // Purpose: Constants used to specify the properties of a requested navigation
  56. // goal.
  57. //-------------------------------------
  58. // Navigator should use the default or previously set tolerance
  59. const float AIN_DEF_TOLERANCE = -1.0;
  60. // Navigator should use the hull size as the tolerance
  61. const float AIN_HULL_TOLERANCE = -2.0;
  62. // Goal does not specify a new activity
  63. const Activity AIN_DEF_ACTIVITY = ACT_INVALID;
  64. // Goal has no target
  65. CBaseEntity * const AIN_NO_TARGET = NULL;
  66. // Goal does not specify a new target, use the existing one, if any
  67. CBaseEntity * const AIN_DEF_TARGET = (AIN_NO_TARGET + 1);
  68. // Goal does not specify a vector location
  69. extern const Vector AIN_NO_DEST;
  70. // Goal does not specify a node location
  71. #define AIN_NO_NODE ((AI_PathNode_t)-1)
  72. //-------------------------------------
  73. enum AI_NavGoalFlags_t
  74. {
  75. // While navigating, try to face the destination point
  76. AIN_YAW_TO_DEST = 0x01,
  77. // If I'm a goal of type GOALTYPE_TARGETENT, update my goal position every time I think
  78. AIN_UPDATE_TARGET_POS = 0x02,
  79. // If navigating on a designer placed path, don't use pathfinder between waypoints, just do it
  80. AIN_NO_PATHCORNER_PATHFINDING = 0x04,
  81. // Succeed if we can arrive within tolerance
  82. AIN_LOCAL_SUCCEEED_ON_WITHIN_TOLERANCE = 0x08,
  83. // Skip local navigation
  84. AIN_NO_LOCAL_NAVIGATION = 0x10,
  85. // Path can be an unlimited distance away
  86. AIN_UNLIMITED_DISTANCE = 0x20,
  87. AIN_DEF_FLAGS = 0,
  88. };
  89. //-------------------------------------
  90. enum AI_NavSetGoalFlags_t
  91. {
  92. // Reset the navigator's navigation to the default state
  93. AIN_CLEAR_PREVIOUS_STATE = 0x01,
  94. // Clear out the target entity, while retaining other settings
  95. AIN_CLEAR_TARGET = 0x02,
  96. // If the navigate fails, return navigation to the default state
  97. AIN_DISCARD_IF_FAIL = 0x04,
  98. // Don't signal TaskFail() if the pathfind fails, just return the result
  99. AIN_NO_PATH_TASK_FAIL = 0x08,
  100. };
  101. //-------------------------------------
  102. enum AI_NpcBlockHandling_t
  103. {
  104. AISF_BLOCK,
  105. AISF_AVOID,
  106. AISF_IGNORE,
  107. };
  108. //-------------------------------------
  109. enum AI_NavPathProgress_t
  110. {
  111. AINPP_NO_CHANGE,
  112. AINPP_ADVANCED,
  113. AINPP_COMPLETE,
  114. AINPP_BLOCKED,
  115. };
  116. //-------------------------------------
  117. // Purpose: Describes a navigation request. The various constructors simply
  118. // allow ease of use in the common cases.
  119. //-------------------------------------
  120. struct AI_NavGoal_t
  121. {
  122. // Goal is unspecifed, or not a specific location
  123. AI_NavGoal_t( GoalType_t type = GOALTYPE_INVALID,
  124. Activity activity = AIN_DEF_ACTIVITY,
  125. float tolerance = AIN_DEF_TOLERANCE,
  126. unsigned flags = AIN_DEF_FLAGS,
  127. CBaseEntity * pTarget = AIN_DEF_TARGET);
  128. // Goal is a specific location, and GOALTYPE_LOCATION
  129. AI_NavGoal_t( const Vector &dest,
  130. Activity activity = AIN_DEF_ACTIVITY,
  131. float tolerance = AIN_DEF_TOLERANCE,
  132. unsigned flags = AIN_DEF_FLAGS,
  133. CBaseEntity * pTarget = AIN_DEF_TARGET);
  134. // Goal is a specific location and goal type
  135. AI_NavGoal_t( GoalType_t type,
  136. const Vector &dest,
  137. Activity activity = AIN_DEF_ACTIVITY,
  138. float tolerance = AIN_DEF_TOLERANCE,
  139. unsigned flags = AIN_DEF_FLAGS,
  140. CBaseEntity * pTarget = AIN_DEF_TARGET);
  141. // Goal is a specific node, and GOALTYPE_LOCATION
  142. AI_NavGoal_t( AI_PathNode_t destNode,
  143. Activity activity = AIN_DEF_ACTIVITY,
  144. float tolerance = AIN_DEF_TOLERANCE,
  145. unsigned flags = AIN_DEF_FLAGS,
  146. CBaseEntity * pTarget = AIN_DEF_TARGET);
  147. // Goal is a specific location and goal type
  148. AI_NavGoal_t( GoalType_t type,
  149. AI_PathNode_t destNode,
  150. Activity activity = AIN_DEF_ACTIVITY,
  151. float tolerance = AIN_DEF_TOLERANCE,
  152. unsigned flags = AIN_DEF_FLAGS,
  153. CBaseEntity * pTarget = AIN_DEF_TARGET);
  154. //----------------------------------
  155. // What type of goal is this
  156. GoalType_t type;
  157. // The destination, either as a vector, or as a path node
  158. Vector dest;
  159. AI_PathNode_t destNode;
  160. // The activity to use, or none if a previosly set activity should be used
  161. Activity activity;
  162. // The predicted activity used after arrival
  163. Activity arrivalActivity;
  164. int arrivalSequence;
  165. // The tolerance of success, or none if a previosly set tolerance should be used
  166. float tolerance;
  167. // How far to permit an initial simplification of path
  168. // (will use default if this value is less than the default)
  169. float maxInitialSimplificationDist;
  170. // Optional flags specifying
  171. unsigned flags;
  172. // The target of the navigation, primarily used to ignore the entity in hull and line traces
  173. CBaseEntity * pTarget;
  174. };
  175. //-------------------------------------
  176. // Purpose: Used to describe rules for advance on a (fly) path. There's nothing
  177. // specifically "flying" about it, other than it came from an attempte
  178. // to consolodate duplicated code in the various fliers. It may serve
  179. // a more general purpose in the future. The constructor takes those
  180. // arguments that can usually be specified just once (as in a
  181. // local static constructor)
  182. //-------------------------------------
  183. struct AI_ProgressFlyPathParams_t
  184. {
  185. AI_ProgressFlyPathParams_t( unsigned collisionMask,
  186. float strictPointTolerance = 32.0, float blockTolerance = 0.0,
  187. float waypointTolerance = 100, float goalTolerance = 12,
  188. AI_NpcBlockHandling_t blockHandling = AISF_BLOCK )
  189. : collisionMask( collisionMask ),
  190. strictPointTolerance( strictPointTolerance ),
  191. blockTolerance( blockTolerance ),
  192. waypointTolerance( waypointTolerance ),
  193. goalTolerance( goalTolerance ),
  194. blockHandling( blockHandling ),
  195. pTarget( NULL ),
  196. bTrySimplify( true )
  197. {
  198. }
  199. void SetCurrent( const CBaseEntity *pNewTarget, bool bNewTrySimplify = true )
  200. {
  201. pTarget = pNewTarget;
  202. bTrySimplify = bNewTrySimplify;
  203. }
  204. //----------------------------------
  205. // Fields that tend to stay constant
  206. unsigned collisionMask;
  207. float strictPointTolerance;
  208. float blockTolerance; // @TODO (toml 07-03-02): rename "blockTolerance". This is specifically the "simplify" block tolerance. See SimplifyFlyPath()
  209. float waypointTolerance;
  210. float goalTolerance; // @TODO (toml 07-03-02): goalTolerance appears to have come into existence because
  211. // noone had set a good tolerance in the path itself. It is therefore redundant,
  212. // and more than likely should be excised
  213. AI_NpcBlockHandling_t blockHandling; // @TODO (toml 07-03-02): rename "blockHandling". This is specifically the "simplify" block handling. See SimplifyFlyPath()
  214. // Fields that tend to change
  215. const CBaseEntity * pTarget;
  216. bool bTrySimplify;
  217. };
  218. //-----------------------------------------------------------------------------
  219. // CAI_Navigator
  220. //
  221. // Purpose: Implements pathing and path navigaton logic
  222. //-----------------------------------------------------------------------------
  223. class CAI_Navigator : public CAI_Component,
  224. public CAI_DefMovementSink
  225. {
  226. typedef CAI_Component BaseClass;
  227. public:
  228. // --------------------------------
  229. CAI_Navigator(CAI_BaseNPC *pOuter);
  230. virtual ~CAI_Navigator();
  231. virtual void Init( CAI_Network *pNetwork );
  232. // --------------------------------
  233. void SetPathcornerPathfinding( bool fNewVal) { m_bNoPathcornerPathfinds = !fNewVal; }
  234. void SetRememberStaleNodes( bool fNewVal) { m_fRememberStaleNodes = fNewVal; }
  235. void SetValidateActivitySpeed( bool bValidateActivitySpeed ) { m_bValidateActivitySpeed = bValidateActivitySpeed; }
  236. // --------------------------------
  237. void Save( ISave &save );
  238. void Restore( IRestore &restore );
  239. // --------------------------------
  240. // Methods to issue movement directives
  241. // --------------------------------
  242. // Simple pathfind
  243. virtual bool SetGoal( const AI_NavGoal_t &goal, unsigned flags = 0 );
  244. // Change the target of the path
  245. virtual bool SetGoalTarget( CBaseEntity *pEntity, const Vector &offset );
  246. // Fancy pathing
  247. bool SetRadialGoal( const Vector &destination, const Vector &center, float radius, float arc, float stepDist, bool bClockwise, bool bAirRoute = false );
  248. bool SetRandomGoal( float minPathLength, const Vector &dir = vec3_origin );
  249. bool SetRandomGoal( const Vector &from, float minPathLength, const Vector &dir = vec3_origin );
  250. bool SetDirectGoal( const Vector &goalPos, Navigation_t navType = NAV_GROUND );
  251. bool SetWanderGoal( float minRadius, float maxRadius );
  252. bool SetVectorGoal( const Vector &dir, float targetDist, float minDist = 0, bool fShouldDeflect = false );
  253. bool SetVectorGoalFromTarget( const Vector &goalPos, float minDist = 0, bool fShouldDeflect = false );
  254. bool FindVectorGoal( Vector *pResult, const Vector &dir, float targetDist, float minDist = 0, bool fShouldDeflect = false );
  255. // Path manipulation
  256. bool PrependLocalAvoidance( float distObstacle, const AIMoveTrace_t &directTrace );
  257. void PrependWaypoint( const Vector &newPoint, Navigation_t navType, unsigned waypointFlags = 0 );
  258. // Query or change the movement activity
  259. Activity GetMovementActivity() const;
  260. Activity SetMovementActivity(Activity activity);
  261. int GetMovementSequence();
  262. void SetMovementSequence( int sequence );
  263. // Query or change the Arrival activity
  264. Activity GetArrivalActivity() const;
  265. void SetArrivalActivity( Activity activity );
  266. int GetArrivalSequence( int curSequence );
  267. void SetArrivalSequence( int sequence );
  268. // Set the facing direction at arrival
  269. void SetArrivalDirection( const Vector &goalDirection );
  270. void SetArrivalDirection( const QAngle &goalAngle );
  271. void SetArrivalDirection( CBaseEntity *pTarget );
  272. Vector GetArrivalDirection( );
  273. // Set the speed to reach at arrival (
  274. void SetArrivalSpeed( float flSpeed );
  275. float GetArrivalSpeed();
  276. // Set the estimated distance to stop before the actual goal
  277. void SetArrivalDistance( float flDistance );
  278. float GetArrivalDistance( ) const;
  279. // Query or change the goal tolerance
  280. float GetGoalTolerance() const;
  281. void SetGoalTolerance(float tolerance);
  282. GoalType_t GetGoalType() const;
  283. const Vector & GetGoalPos() const;
  284. CBaseEntity * GetGoalTarget();
  285. int GetGoalFlags() const;
  286. const Vector & GetCurWaypointPos() const;
  287. int GetCurWaypointFlags() const;
  288. bool CurWaypointIsGoal() const;
  289. bool CurWaypointRequiresPreciseMovement() const;
  290. bool GetPointAlongPath( Vector *pResult, float distance, bool fReducibleOnly = false );
  291. float GetPathDistanceToGoal();
  292. float GetPathTimeToGoal();
  293. // Query if there is a current goal
  294. bool IsGoalSet() const;
  295. // Query if the current goal is active, meaning the navigator has a path in can progress on
  296. bool IsGoalActive() const;
  297. // Update the goal position to reflect current conditions
  298. bool RefindPathToGoal( bool fSignalTaskStatus = true, bool bDontIgnoreBadLinks = false );
  299. bool UpdateGoalPos( const Vector & );
  300. // Wrap up current locomotion
  301. void StopMoving( bool bImmediate = true );
  302. // Discard the current goal, use StopMoving() if just executing a normal stop
  303. bool ClearGoal();
  304. // --------------------------------
  305. void SetAllowBigStep( CBaseEntity *pEntToStepOff ) { if ( !pEntToStepOff || !pEntToStepOff->IsWorld() ) m_hBigStepGroundEnt = pEntToStepOff; }
  306. // --------------------------------
  307. bool SetGoalFromStoppingPath();
  308. void IgnoreStoppingPath();
  309. // --------------------------------
  310. // Navigation mode
  311. // --------------------------------
  312. Navigation_t GetNavType() const { return m_navType; }
  313. void SetNavType( Navigation_t navType );
  314. bool IsInterruptable() const { return ( m_navType != NAV_CLIMB && m_navType != NAV_JUMP ); }
  315. // --------------------------------
  316. // Pathing
  317. // --------------------------------
  318. AI_NavPathProgress_t ProgressFlyPath( const AI_ProgressFlyPathParams_t &params); // note: will not return "blocked"
  319. AI_PathNode_t GetNearestNode();
  320. Vector GetNodePos( AI_PathNode_t );
  321. CAI_Network * GetNetwork() { return m_pAINetwork; }
  322. const CAI_Network * GetNetwork() const { return m_pAINetwork; }
  323. void SetNetwork( CAI_Network *pNetwork ) { m_pAINetwork = pNetwork; }
  324. CAI_Path * GetPath() { return m_pPath; }
  325. const CAI_Path * GetPath() const { return m_pPath; }
  326. void AdvancePath();
  327. virtual bool SimplifyPath( bool bFirstForPath = false, float maxDist = -1 );
  328. void SimplifyFlyPath( unsigned collisionMask, const CBaseEntity *pTarget,
  329. float strictPointTolerance = 32.0, float blockTolerance = 0.0,
  330. AI_NpcBlockHandling_t blockHandling = AISF_BLOCK);
  331. bool SimplifyFlyPath( const AI_ProgressFlyPathParams_t &params );
  332. bool CanFitAtNode(int nodeNum, unsigned int collisionMask = MASK_NPCSOLID_BRUSHONLY);
  333. float MovementCost( int moveType, Vector &vecStart, Vector &vecEnd );
  334. bool CanFitAtPosition( const Vector &vStartPos, unsigned int collisionMask, bool bIgnoreTransients = false, bool bAllowPlayerAvoid = true );
  335. bool IsOnNetwork() const { return !m_bNotOnNetwork; }
  336. void SetMaxRouteRebuildTime(float time) { m_timePathRebuildMax = time; }
  337. // --------------------------------
  338. void DrawDebugRouteOverlay( void );
  339. // --------------------------------
  340. // Miscellany
  341. // --------------------------------
  342. float CalcYawSpeed();
  343. float GetStepDownMultiplier();
  344. CBaseEntity * GetNextPathcorner( CBaseEntity *pPathCorner );
  345. virtual void OnScheduleChange();
  346. // --------------------------------
  347. // See comments at CAI_BaseNPC::Move()
  348. virtual bool Move( float flInterval = 0.1 );
  349. virtual bool ShouldMove( bool bHasAGoal );
  350. // --------------------------------
  351. CBaseEntity * GetBlockingEntity() { return m_hLastBlockingEnt; }
  352. protected:
  353. // --------------------------------
  354. //
  355. // Common services provided by CAI_BaseNPC
  356. //
  357. CBaseEntity * GetNavTargetEntity();
  358. void TaskMovementComplete();
  359. float MaxYawSpeed();
  360. void SetSpeed( float );
  361. // --------------------------------
  362. CAI_Motor * GetMotor() { return m_pMotor; }
  363. const CAI_Motor * GetMotor() const { return m_pMotor; }
  364. CAI_MoveProbe * GetMoveProbe() { return m_pMoveProbe; }
  365. const CAI_MoveProbe *GetMoveProbe() const { return m_pMoveProbe; }
  366. CAI_LocalNavigator *GetLocalNavigator() { return m_pLocalNavigator; }
  367. const CAI_LocalNavigator *GetLocalNavigator() const { return m_pLocalNavigator; }
  368. CAI_Pathfinder * GetPathfinder();
  369. const CAI_Pathfinder *GetPathfinder() const;
  370. virtual void OnClearPath(void);
  371. // --------------------------------
  372. virtual void OnNewGoal();
  373. virtual void OnNavComplete();
  374. void OnNavFailed( bool bMovement = false );
  375. void OnNavFailed( AI_TaskFailureCode_t code, bool bMovement = false );
  376. void OnNavFailed( const char *pszGeneralFailText, bool bMovement = false );
  377. // --------------------------------
  378. virtual AIMoveResult_t MoveNormal();
  379. // Navigation execution
  380. virtual AIMoveResult_t MoveCrawl();
  381. virtual AIMoveResult_t MoveClimb();
  382. virtual AIMoveResult_t MoveJump();
  383. // --------------------------------
  384. virtual AIMoveResult_t MoveEnact( const AILocalMoveGoal_t &baseMove );
  385. protected:
  386. // made this virtual so strider can implement hover behavior with a navigator
  387. virtual void MoveCalcBaseGoal( AILocalMoveGoal_t *pMoveGoal);
  388. private:
  389. virtual bool OnCalcBaseMove( AILocalMoveGoal_t *pMoveGoal, float distClear, AIMoveResult_t *pResult );
  390. virtual bool OnObstructionPreSteer( AILocalMoveGoal_t *pMoveGoal, float distClear, AIMoveResult_t *pResult );
  391. virtual bool OnFailedSteer( AILocalMoveGoal_t *pMoveGoal, float distClear, AIMoveResult_t *pResult );
  392. virtual bool OnFailedLocalNavigation( AILocalMoveGoal_t *pMoveGoal, float distClear, AIMoveResult_t *pResult );
  393. virtual bool OnInsufficientStopDist( AILocalMoveGoal_t *pMoveGoal, float distClear, AIMoveResult_t *pResult );
  394. virtual bool OnMoveStalled( const AILocalMoveGoal_t &move );
  395. virtual bool OnMoveExecuteFailed( const AILocalMoveGoal_t &move, const AIMoveTrace_t &trace, AIMotorMoveResult_t fMotorResult, AIMoveResult_t *pResult );
  396. virtual bool OnMoveBlocked( AIMoveResult_t *pResult );
  397. void ResetCalculations();
  398. // Methods shared between ground and fly movement
  399. bool PreMove();
  400. virtual bool MoveUpdateWaypoint( AIMoveResult_t *pResult );
  401. bool IsMovingOutOfWay( const AILocalMoveGoal_t &moveGoal, float distClear );
  402. bool DelayNavigationFailure( const AIMoveTrace_t &trace );
  403. static void CalculateDeflection( const Vector &start, const Vector &dir, const Vector &normal, Vector *pResult );
  404. // --------------------------------
  405. // Pathfinding
  406. // --------------------------------
  407. public:
  408. float GetPathDistToCurWaypoint() const;
  409. float GetPathDistToGoal() const;
  410. float BuildAndGetPathDistToGoal();
  411. // --------------------------------
  412. int GetNavFailCounter() const;
  413. void ClearNavFailCounter();
  414. float GetLastNavFailTime() const;
  415. bool TeleportAlongPath();
  416. private:
  417. bool DoFindPath( void ); // Find a route
  418. bool DoFindPathToPathcorner( CBaseEntity *pPathCorner );
  419. protected:
  420. virtual bool DoFindPathToPos( );
  421. virtual bool ShouldOptimizeInitialPathSegment( AI_Waypoint_t * ) { return true; }
  422. private:
  423. void ClearPath(void);
  424. void SaveStoppingPath( void );
  425. protected:
  426. virtual bool GetStoppingPath( CAI_WaypointList *pClippedWaypoints );
  427. virtual bool MarkCurWaypointFailedLink( void ); // Call when route fails
  428. private:
  429. bool FindPath( const AI_NavGoal_t &goal, unsigned flags );
  430. bool FindPath( bool fSignalTaskStatus = true, bool bDontIgnoreBadLinks = false );
  431. struct SimplifyForwardScanParams
  432. {
  433. float scanDist;
  434. float radius;
  435. float increment;
  436. int maxSamples;
  437. };
  438. bool ShouldAttemptSimplifyTo( const Vector &pos );
  439. bool ShouldSimplifyTo( bool passedDetour, const Vector &pos );
  440. bool SimplifyPathForwardScan( const CAI_Navigator::SimplifyForwardScanParams &params );
  441. bool SimplifyPathForwardScan( const SimplifyForwardScanParams &params, AI_Waypoint_t *pCurWaypoint, const Vector &curPoint, float distRemaining, bool skip, bool passedDetour, int *pTestCount );
  442. bool SimplifyPathForward( float maxDist = -1 );
  443. bool SimplifyPathBacktrack();
  444. bool SimplifyPathQuick();
  445. void SimplifyPathInsertSimplification( AI_Waypoint_t *pSegmentStart, const Vector &point );
  446. // ---------------------------------
  447. static bool ActivityIsLocomotive( Activity );
  448. // ---------------------------------
  449. Navigation_t m_navType; // My current navigation type (walk,fly)
  450. bool m_fNavComplete;
  451. bool m_bLastNavFailed;
  452. // Cached pointers to other components, for efficiency
  453. CAI_Motor * m_pMotor;
  454. CAI_MoveProbe * m_pMoveProbe;
  455. CAI_LocalNavigator *m_pLocalNavigator;
  456. // ---------------------------------
  457. CAI_Network* m_pAINetwork; // My current AINetwork
  458. CAI_Path* m_pPath; // My current route
  459. CAI_WaypointList * m_pClippedWaypoints;
  460. float m_flTimeClipped;
  461. Activity m_PreviousMoveActivity;
  462. Activity m_PreviousArrivalActivity;
  463. bool m_bValidateActivitySpeed;
  464. bool m_bCalledStartMove;
  465. bool m_bNotOnNetwork; // This NPC has no reachable nodes!
  466. float m_flNextSimplifyTime; // next time we should try to simplify our route
  467. bool m_bForcedSimplify;
  468. float m_flLastSuccessfulSimplifyTime;
  469. float m_flTimeLastAvoidanceTriangulate;
  470. // --------------
  471. float m_timePathRebuildMax; // How long to try rebuilding path before failing task
  472. float m_timePathRebuildDelay; // How long to wait before trying to rebuild again
  473. float m_timePathRebuildFail; // Current global time when should fail building path
  474. float m_timePathRebuildNext; // Global time to try rebuilding again
  475. // --------------
  476. bool m_fRememberStaleNodes;
  477. bool m_bNoPathcornerPathfinds;
  478. // --------------
  479. bool m_fPeerMoveWait;
  480. EHANDLE m_hPeerWaitingOn;
  481. CSimTimer m_PeerWaitMoveTimer;
  482. CSimTimer m_PeerWaitClearTimer;
  483. CSimTimer m_NextSidestepTimer;
  484. // --------------
  485. EHANDLE m_hBigStepGroundEnt;
  486. EHANDLE m_hLastBlockingEnt;
  487. // --------------
  488. Vector m_vPosBeginFailedSteer;
  489. float m_timeBeginFailedSteer;
  490. // --------------
  491. int m_nNavFailCounter;
  492. float m_flLastNavFailTime;
  493. public:
  494. DECLARE_SIMPLE_DATADESC();
  495. };
  496. //-----------------------------------------------------------------------------
  497. // AI_NavGoal_t inline methods
  498. //-----------------------------------------------------------------------------
  499. inline AI_NavGoal_t::AI_NavGoal_t( GoalType_t type,
  500. Activity activity,
  501. float tolerance,
  502. unsigned flags,
  503. CBaseEntity *pTarget)
  504. : type(type),
  505. dest(AIN_NO_DEST),
  506. destNode(AIN_NO_NODE),
  507. activity(activity),
  508. tolerance(tolerance),
  509. maxInitialSimplificationDist(-1),
  510. flags(flags),
  511. pTarget(pTarget),
  512. arrivalActivity( AIN_DEF_ACTIVITY ),
  513. arrivalSequence( ACT_INVALID )
  514. {
  515. }
  516. inline AI_NavGoal_t::AI_NavGoal_t( const Vector &dest,
  517. Activity activity,
  518. float tolerance,
  519. unsigned flags,
  520. CBaseEntity *pTarget)
  521. : type(GOALTYPE_LOCATION),
  522. dest(dest),
  523. destNode(AIN_NO_NODE),
  524. activity(activity),
  525. tolerance(tolerance),
  526. maxInitialSimplificationDist(-1),
  527. flags(flags),
  528. pTarget(pTarget),
  529. arrivalActivity( AIN_DEF_ACTIVITY ),
  530. arrivalSequence( ACT_INVALID )
  531. {
  532. }
  533. inline AI_NavGoal_t::AI_NavGoal_t( GoalType_t type,
  534. const Vector &dest,
  535. Activity activity,
  536. float tolerance,
  537. unsigned flags,
  538. CBaseEntity *pTarget)
  539. : type(type),
  540. dest(dest),
  541. destNode(AIN_NO_NODE),
  542. activity(activity),
  543. tolerance(tolerance),
  544. maxInitialSimplificationDist(-1),
  545. flags(flags),
  546. pTarget(pTarget),
  547. arrivalActivity( AIN_DEF_ACTIVITY ),
  548. arrivalSequence( ACT_INVALID )
  549. {
  550. }
  551. inline AI_NavGoal_t::AI_NavGoal_t( AI_PathNode_t destNode,
  552. Activity activity,
  553. float tolerance,
  554. unsigned flags,
  555. CBaseEntity * pTarget)
  556. : type(GOALTYPE_LOCATION),
  557. dest(AIN_NO_DEST),
  558. destNode(destNode),
  559. activity(activity),
  560. tolerance(tolerance),
  561. maxInitialSimplificationDist(-1),
  562. flags(flags),
  563. pTarget(pTarget),
  564. arrivalActivity( AIN_DEF_ACTIVITY ),
  565. arrivalSequence( ACT_INVALID )
  566. {
  567. }
  568. inline AI_NavGoal_t::AI_NavGoal_t( GoalType_t type,
  569. AI_PathNode_t destNode,
  570. Activity activity,
  571. float tolerance,
  572. unsigned flags,
  573. CBaseEntity * pTarget)
  574. : type(type),
  575. dest(AIN_NO_DEST),
  576. destNode(destNode),
  577. activity(activity),
  578. tolerance(tolerance),
  579. maxInitialSimplificationDist(-1),
  580. flags(flags),
  581. pTarget(pTarget),
  582. arrivalActivity( AIN_DEF_ACTIVITY ),
  583. arrivalSequence( ACT_INVALID )
  584. {
  585. }
  586. //-----------------------------------------------------------------------------
  587. #endif // AI_NAVIGATOR_H