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
4.5 KiB

  1. //========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef HLTVDIRECTOR_H
  7. #define HLTVDIRECTOR_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "GameEventListener.h"
  12. #include <igamesystem.h>
  13. #include <ihltvdirector.h>
  14. #include <ihltv.h>
  15. #include <utlrbtree.h>
  16. #define HLTV_MIN_DIRECTOR_DELAY 3 // minimum delay if director is enabled
  17. #define HLTV_MAX_DELAY 120 // maximum delay
  18. #define MAX_NUM_CAMERAS 64 // support up to 64 fixed cameras per level
  19. #define MIN_SHOT_LENGTH 4.0f // minimum time of a cut (seconds)
  20. #define MAX_SHOT_LENGTH 8.0f // maximum time of a cut (seconds)
  21. #define DEF_SHOT_LENGTH 6.0f // average time of a cut (seconds)
  22. class CHLTVGameEvent
  23. {
  24. public:
  25. int m_Tick; // tick of this command
  26. int m_Priority; // game event priority
  27. IGameEvent *m_Event; // IGameEvent
  28. };
  29. class CHLTVDirector : public CGameEventListener, public CBaseGameSystemPerFrame, public IHLTVDirector
  30. {
  31. public:
  32. DECLARE_CLASS_NOBASE( CHLTVDirector );
  33. virtual char const *Name() { return "CHLTVDirector"; }
  34. CHLTVDirector();
  35. virtual ~CHLTVDirector();
  36. virtual void AddHLTVServer( IHLTVServer *hltv )OVERRIDE; // give the director an HLTV interface
  37. virtual void RemoveHLTVServer( IHLTVServer *hltv ) OVERRIDE;
  38. virtual IHLTVServer* GetHLTVServer( int nIndex ) OVERRIDE { return m_HltvServers[ nIndex ].m_pHLTVServer; }
  39. virtual int GetHLTVServerCount() OVERRIDE { return m_HltvServers.Count(); }
  40. int GetDirectorTick( void ); // get current broadcast tick from director
  41. int GetPVSEntity( void ); // get current view entity (PVS)
  42. Vector GetPVSOrigin( void ); // get current PVS origin, if PVS entity is 0
  43. float GetDelay( void ); // returns current delay in seconds
  44. bool IsActive( void );
  45. virtual const char** GetModEvents(); // returns list of event names forwarded to HLTV clients
  46. void BuildCameraList( void );
  47. // Starts automatic recording of the current session
  48. void StartAutoRecording( void );
  49. public: // IGameEventListener Interface
  50. virtual void FireGameEvent( IGameEvent * event );
  51. public: // CBaseGameSystem overrides
  52. virtual bool Init();
  53. virtual void Shutdown();
  54. virtual void FrameUpdatePostEntityThink();
  55. virtual void LevelInitPostEntity();
  56. virtual char *GetFixedCameraEntityName( void ) { return "point_viewcontrol"; }
  57. bool SetCameraMan( int iPlayerIndex );
  58. int GetCameraMan() { return m_iCameraManIndex; }
  59. protected:
  60. virtual void StartNewShot();
  61. virtual void StartRandomShot();
  62. virtual void StartDelayMessage();
  63. virtual void StartBestFixedCameraShot(bool bForce);
  64. virtual void StartBestPlayerCameraShot();
  65. virtual void StartFixedCameraShot(int iCamera, int iTarget);
  66. virtual void StartChaseCameraShot(int iTarget1, int iTarget2, int distance, int phi, int theta, bool bInEye);
  67. virtual void UpdateSettings();
  68. virtual void AnalyzePlayers();
  69. virtual void AnalyzeCameras();
  70. virtual bool StartCameraManShot();
  71. virtual void StartInstantBroadcastShot();
  72. virtual void FinishCameraManShot();
  73. virtual void BuildActivePlayerList();
  74. virtual CHLTVGameEvent *FindBestGameEvent();
  75. virtual void CreateShotFromEvent( CHLTVGameEvent *ge );
  76. int FindFirstEvent( int tick ); // finds first event >= tick
  77. void CheckHistory();
  78. void RemoveEventsFromHistory(int tick); // removes all commands < tick, or all if tick -1
  79. struct HltvServerRecord_t
  80. {
  81. IHLTVServer *m_pHLTVServer; // interface to servers HLTV object
  82. CBasePlayer *m_pHLTVClient; // the HLTV fake client
  83. };
  84. CUtlVector< HltvServerRecord_t > m_HltvServers;
  85. float m_fDelay; // hltv delay in seconds
  86. int m_nBroadcastTick; // world time that is currently "on the air"
  87. int m_iPVSEntity; // entity for PVS center
  88. Vector m_vPVSOrigin; // PVS origin if PVS entity is 0
  89. int m_iCameraMan; // >0 if current view entity is a cameraman
  90. int m_nNextShotTick; // time for the next scene cut
  91. int m_iLastPlayer; // last player in random rotation
  92. int m_nNextAnalyzeTick;
  93. int m_nNumFixedCameras; //number of cameras in current map
  94. CBaseEntity *m_pFixedCameras[MAX_NUM_CAMERAS]; // fixed cameras (point_viewcontrol)
  95. int m_nNumActivePlayers; //number of cameras in current map
  96. CBasePlayer *m_pActivePlayers[MAX_PLAYERS]; // fixed cameras (point_viewcontrol)
  97. int m_iCameraManIndex; // entity index of current camera man or 0
  98. CUtlRBTree<CHLTVGameEvent> m_EventHistory;
  99. };
  100. extern IGameSystem* HLTVDirectorSystem();
  101. extern CHLTVDirector* HLTVDirector();
  102. #endif // HLTVDIRECTOR_H