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.

80 lines
3.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=============================================================================
  4. #ifndef AI_TACTICALSERVICES_H
  5. #define AI_TACTICALSERVICES_H
  6. #include "ai_component.h"
  7. #if defined( _WIN32 )
  8. #pragma once
  9. #endif
  10. class CAI_Network;
  11. class CAI_Pathfinder;
  12. enum FlankType_t
  13. {
  14. FLANKTYPE_NONE = 0,
  15. FLANKTYPE_ARC, // Stay flFlankParam degrees of arc away from vecFlankRefPos
  16. FLANKTYPE_RADIUS, // Stay flFlankParam units away from vecFlankRefPos
  17. };
  18. //-----------------------------------------------------------------------------
  19. class CAI_TacticalServices : public CAI_Component
  20. {
  21. public:
  22. CAI_TacticalServices( CAI_BaseNPC *pOuter )
  23. : CAI_Component(pOuter),
  24. m_pNetwork( NULL )
  25. {
  26. m_bAllowFindLateralLos = true;
  27. }
  28. void Init( CAI_Network *pNetwork );
  29. bool FindLos( const Vector &threatPos, const Vector &threatEyePos, float minThreatDist, float maxThreatDist, float blockTime, Vector *pResult );
  30. bool FindLos( const Vector &threatPos, const Vector &threatEyePos, float minThreatDist, float maxThreatDist, float blockTime, FlankType_t eFlankType, const Vector &VecFlankRefPos, float flFlankParam, Vector *pResult );
  31. bool FindLateralLos( const Vector &threatPos, Vector *pResult );
  32. bool FindBackAwayPos( const Vector &vecThreat, Vector *pResult );
  33. bool FindCoverPos( const Vector &vThreatPos, const Vector &vThreatEyePos, float flMinDist, float flMaxDist, Vector *pResult );
  34. bool FindCoverPos( const Vector &vNearPos, const Vector &vThreatPos, const Vector &vThreatEyePos, float flMinDist, float flMaxDist, Vector *pResult );
  35. bool FindLateralCover( const Vector &vecThreat, float flMinDist, Vector *pResult );
  36. bool FindLateralCover( const Vector &vecThreat, float flMinDist, float distToCheck, int numChecksPerDir, Vector *pResult );
  37. bool FindLateralCover( const Vector &vNearPos, const Vector &vecThreat, float flMinDist, float distToCheck, int numChecksPerDir, Vector *pResult );
  38. void AllowFindLateralLos( bool bAllow ) { m_bAllowFindLateralLos = bAllow; }
  39. private:
  40. // Checks lateral cover
  41. bool TestLateralCover( const Vector &vecCheckStart, const Vector &vecCheckEnd, float flMinDist );
  42. bool TestLateralLos( const Vector &vecCheckStart, const Vector &vecCheckEnd );
  43. int FindBackAwayNode( const Vector &vecThreat );
  44. int FindCoverNode( const Vector &vThreatPos, const Vector &vThreatEyePos, float flMinDist, float flMaxDist );
  45. int FindCoverNode( const Vector &vNearPos, const Vector &vThreatPos, const Vector &vThreatEyePos, float flMinDist, float flMaxDist );
  46. int FindLosNode( const Vector &vThreatPos, const Vector &vThreatEyePos, float flMinThreatDist, float flMaxThreatDist, float flBlockTime, FlankType_t eFlankType, const Vector &vThreatFacing, float flFlankParam );
  47. Vector GetNodePos( int );
  48. CAI_Network *GetNetwork() { return m_pNetwork; }
  49. const CAI_Network *GetNetwork() const { return m_pNetwork; }
  50. CAI_Pathfinder *GetPathfinder() { return m_pPathfinder; }
  51. const CAI_Pathfinder *GetPathfinder() const { return m_pPathfinder; }
  52. CAI_Network *m_pNetwork;
  53. CAI_Pathfinder *m_pPathfinder;
  54. bool m_bAllowFindLateralLos; // Allows us to turn Lateral LOS checking on/off.
  55. DECLARE_SIMPLE_DATADESC();
  56. };
  57. //-----------------------------------------------------------------------------
  58. #endif // AI_TACTICALSERVICES_H