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.

134 lines
3.8 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef PATHTRACK_H
  7. #define PATHTRACK_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "entityoutput.h"
  12. //-----------------------------------------------------------------------------
  13. // Spawnflag for CPathTrack
  14. //-----------------------------------------------------------------------------
  15. #define SF_PATH_DISABLED 0x00000001
  16. //#define SF_PATH_FIREONCE 0x00000002
  17. #define SF_PATH_ALTREVERSE 0x00000004
  18. #define SF_PATH_DISABLE_TRAIN 0x00000008
  19. #define SF_PATH_TELEPORT 0x00000010
  20. #define SF_PATH_ALTERNATE 0x00008000
  21. enum TrackOrientationType_t
  22. {
  23. TrackOrientation_Fixed = 0,
  24. TrackOrientation_FacePath,
  25. TrackOrientation_FacePathAngles,
  26. };
  27. //-----------------------------------------------------------------------------
  28. // Paths!
  29. //-----------------------------------------------------------------------------
  30. class CPathTrack : public CServerOnlyPointEntity
  31. {
  32. DECLARE_CLASS( CPathTrack, CServerOnlyPointEntity );
  33. public:
  34. CPathTrack();
  35. void Spawn( void );
  36. void Activate( void );
  37. void DrawDebugGeometryOverlays();
  38. void ToggleAlternatePath( void );
  39. void EnableAlternatePath( void );
  40. void DisableAlternatePath( void );
  41. bool HasAlternathPath() const;
  42. void TogglePath( void );
  43. void EnablePath( void );
  44. void DisablePath( void );
  45. static CPathTrack *ValidPath( CPathTrack *ppath, int testFlag = true ); // Returns ppath if enabled, NULL otherwise
  46. CPathTrack *GetNextInDir( bool bForward );
  47. CPathTrack *GetNext( void );
  48. CPathTrack *GetPrevious( void );
  49. CPathTrack *Nearest( const Vector &origin );
  50. //CPathTrack *LookAhead( Vector &origin, float dist, int move );
  51. CPathTrack *LookAhead( Vector &origin, float dist, int move, CPathTrack **pNextNext = NULL );
  52. TrackOrientationType_t GetOrientationType();
  53. QAngle GetOrientation( bool bForwardDir );
  54. CPathTrack *m_pnext;
  55. CPathTrack *m_pprevious;
  56. CPathTrack *m_paltpath;
  57. float GetRadius() const { return m_flRadius; }
  58. // These four methods help for circular path checking. Call BeginIteration
  59. // before iterating, EndInteration afterwards. Call Visit on each path in the
  60. // list. Then you can use HasBeenVisited to see if you've visited the node
  61. // already, which means you've got a circular or lasso path. You can use the
  62. // macro BEGIN_PATH_TRACK_ITERATION below to simplify the calls to
  63. // BeginInteration + EndIteration.
  64. static void BeginIteration();
  65. static void EndIteration();
  66. void Visit();
  67. bool HasBeenVisited() const;
  68. private:
  69. void Project( CPathTrack *pstart, CPathTrack *pend, Vector &origin, float dist );
  70. void SetPrevious( CPathTrack *pprevious );
  71. void Link( void );
  72. static CPathTrack *Instance( edict_t *pent );
  73. void InputPass( inputdata_t &inputdata );
  74. void InputToggleAlternatePath( inputdata_t &inputdata );
  75. void InputEnableAlternatePath( inputdata_t &inputdata );
  76. void InputDisableAlternatePath( inputdata_t &inputdata );
  77. void InputTogglePath( inputdata_t &inputdata );
  78. void InputEnablePath( inputdata_t &inputdata );
  79. void InputDisablePath( inputdata_t &inputdata );
  80. DECLARE_DATADESC();
  81. float m_flRadius;
  82. float m_length;
  83. string_t m_altName;
  84. int m_nIterVal;
  85. TrackOrientationType_t m_eOrientationType;
  86. COutputEvent m_OnPass;
  87. static int s_nCurrIterVal;
  88. static bool s_bIsIterating;
  89. };
  90. //-----------------------------------------------------------------------------
  91. // Used to make sure circular iteration works all nice
  92. //-----------------------------------------------------------------------------
  93. #define BEGIN_PATH_TRACK_ITERATION() CPathTrackVisitor _visit
  94. class CPathTrackVisitor
  95. {
  96. public:
  97. CPathTrackVisitor() { CPathTrack::BeginIteration(); }
  98. ~CPathTrackVisitor() { CPathTrack::EndIteration(); }
  99. };
  100. #endif // PATHTRACK_H