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.

81 lines
2.9 KiB

  1. //========= Copyright 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. //-------------------------------------------------------------------------------------------------------------------
  15. /**
  16. * A CNavArea is a rectangular region defining a walkable area in the environment
  17. */
  18. class CCSNavArea : public CNavArea
  19. {
  20. public:
  21. DECLARE_CLASS( CCSNavArea, CNavArea );
  22. CCSNavArea( void );
  23. ~CCSNavArea();
  24. virtual void OnServerActivate( void ); // (EXTEND) invoked when map is initially loaded
  25. virtual void OnRoundRestart( void ); // (EXTEND) invoked for each area when the round restarts
  26. virtual void Draw( void ) const; // draw area for debugging & editing
  27. virtual void Save( CUtlBuffer &fileBuffer, unsigned int version ) const; // (EXTEND)
  28. virtual NavErrorType Load( CUtlBuffer &fileBuffer, unsigned int version, unsigned int subVersion ); // (EXTEND)
  29. virtual NavErrorType PostLoad( void ); // (EXTEND) invoked after all areas have been loaded - for pointer binding, etc
  30. virtual void CustomAnalysis( bool isIncremental = false ); // for game-specific analysis
  31. //- approach areas ----------------------------------------------------------------------------------
  32. struct ApproachInfo
  33. {
  34. NavConnect here; ///< the approach area
  35. NavConnect prev; ///< the area just before the approach area on the path
  36. NavTraverseType prevToHereHow;
  37. NavConnect next; ///< the area just after the approach area on the path
  38. NavTraverseType hereToNextHow;
  39. };
  40. const ApproachInfo *GetApproachInfo( int i ) const { return &m_approach[i]; }
  41. int GetApproachInfoCount( void ) const { return m_approachCount; }
  42. void ComputeApproachAreas( void ); ///< determine the set of "approach areas" - for map learning
  43. //- player counting --------------------------------------------------------------------------------
  44. void ClearPlayerCount( void ); ///< set the player count to zero
  45. protected:
  46. NavErrorType LoadLegacy( CUtlBuffer &fileBuffer, unsigned int version, unsigned int subVersion );
  47. private:
  48. //- approach areas ----------------------------------------------------------------------------------
  49. enum { MAX_APPROACH_AREAS = 16 };
  50. ApproachInfo m_approach[ MAX_APPROACH_AREAS ];
  51. unsigned char m_approachCount;
  52. };
  53. //--------------------------------------------------------------------------------------------------------------
  54. //--------------------------------------------------------------------------------------------------------------
  55. //
  56. // Inlines
  57. //
  58. inline void CCSNavArea::ClearPlayerCount( void )
  59. {
  60. for( int i=0; i<MAX_NAV_TEAMS; ++i )
  61. {
  62. m_playerCount[ i ] = 0;
  63. }
  64. }
  65. #endif // _CS_NAV_AREA_H_