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.

107 lines
4.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // nav_area.h
  9. // Navigation areas
  10. // Author: Michael S. Booth ([email protected]), January 2003
  11. #ifndef _CS_NAV_AREA_H_
  12. #define _CS_NAV_AREA_H_
  13. #include "nav_area.h"
  14. class CCSHidingSpot : public HidingSpot
  15. {
  16. public:
  17. virtual ~CCSHidingSpot();
  18. void SetOwningEntity( class CPointHidingSpot *pHidingSpotEnt );
  19. protected:
  20. CPointHidingSpot *m_pOwningEntity;
  21. };
  22. //-------------------------------------------------------------------------------------------------------------------
  23. /**
  24. * A CNavArea is a rectangular region defining a walkable area in the environment
  25. */
  26. class CCSNavArea : public CNavArea
  27. {
  28. public:
  29. DECLARE_CLASS( CCSNavArea, CNavArea );
  30. CCSNavArea( void );
  31. ~CCSNavArea();
  32. virtual void OnServerActivate( void ); // (EXTEND) invoked when map is initially loaded
  33. virtual void OnRoundRestart( void ); // (EXTEND) invoked for each area when the round restarts
  34. virtual void Draw( void ) const; // draw area for debugging & editing
  35. virtual void Save( CUtlBuffer &fileBuffer, unsigned int version ) const; // (EXTEND)
  36. virtual NavErrorType Load( CUtlBuffer &fileBuffer, unsigned int version, unsigned int subVersion ); // (EXTEND)
  37. virtual NavErrorType PostLoad( void ); // (EXTEND) invoked after all areas have been loaded - for pointer binding, etc
  38. virtual void CustomAnalysis( bool isIncremental = false ); // for game-specific analysis
  39. virtual float GetDangerDecayRate( void ) const; // return danger decay rate per second
  40. virtual float GetEarliestOccupyTime( int teamID ) const OVERRIDE; // returns the minimum time for someone of the given team to reach this spot from their spawn
  41. // Use nav blockers in coop mode. There is a bug with these functions causing bots to lose
  42. // their path at the start of rounds that is undiagnosed at the time of this comment. Coop needs nav blockers
  43. // and doesn't (seem) to have any issues with blocked nav so let's leave it on for them
  44. virtual void UpdateBlocked( bool force = false, int teamID = TEAM_ANY ) OVERRIDE;
  45. // Updates the (un)blocked status of the nav area (throttled)
  46. virtual bool IsBlocked( int teamID, bool ignoreNavBlockers = false ) const OVERRIDE;
  47. //- approach areas ----------------------------------------------------------------------------------
  48. struct ApproachInfo
  49. {
  50. NavConnect here; ///< the approach area
  51. NavConnect prev; ///< the area just before the approach area on the path
  52. NavConnect next; ///< the area just after the approach area on the path
  53. uint16 prevToHereHow; // NavTraverseType
  54. uint16 hereToNextHow;
  55. };
  56. const ApproachInfo *GetApproachInfo( int i ) const { return &m_approach[i]; }
  57. int GetApproachInfoCount( void ) const { return m_approachCount; }
  58. void ComputeApproachAreas( void ); ///< determine the set of "approach areas" - for map learning
  59. //- player counting --------------------------------------------------------------------------------
  60. void ClearPlayerCount( void ); ///< set the player count to zero
  61. protected:
  62. NavErrorType LoadLegacy( CUtlBuffer &fileBuffer, unsigned int version, unsigned int subVersion );
  63. private:
  64. //- approach areas ----------------------------------------------------------------------------------
  65. enum { MAX_APPROACH_AREAS = 16 };
  66. ApproachInfo m_approach[ MAX_APPROACH_AREAS ];
  67. unsigned char m_approachCount;
  68. unsigned char m_paddingToAlignTo128[ int( 0 - sizeof( CNavArea ) - ( sizeof( ApproachInfo ) * MAX_APPROACH_AREAS ) - sizeof( unsigned char ) ) & 127 ];
  69. };
  70. //--------------------------------------------------------------------------------------------------------------
  71. //--------------------------------------------------------------------------------------------------------------
  72. //
  73. // Inlines
  74. //
  75. inline void CCSNavArea::ClearPlayerCount( void )
  76. {
  77. #ifndef PLATFORM_64BITS
  78. COMPILE_TIME_ASSERT( sizeof( CCSNavArea ) == 768 ); // legacy 32-bit struct was 768 bytes, preserving for compatibility
  79. #endif
  80. for( int i=0; i<MAX_NAV_TEAMS; ++i )
  81. {
  82. m_playerCount[ i ] = 0;
  83. }
  84. }
  85. #endif // _CS_NAV_AREA_H_