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.

124 lines
4.1 KiB

  1. //========= Copyright 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 10 // 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 SetHLTVServer( IHLTVServer *hltv ); // give the director an HLTV interface
  37. IHLTVServer* GetHLTVServer( void );
  38. int GetDirectorTick( void ); // get current broadcast tick from director
  39. int GetPVSEntity( void ); // get current view entity (PVS)
  40. Vector GetPVSOrigin( void ); // get current PVS origin, if PVS entity is 0
  41. float GetDelay( void ); // returns current delay in seconds
  42. bool IsActive( void );
  43. virtual const char** GetModEvents(); // returns list of event names forwarded to HLTV clients
  44. void BuildCameraList( void );
  45. public: // IGameEventListener Interface
  46. virtual void FireGameEvent( IGameEvent * event );
  47. public: // CBaseGameSystem overrides
  48. virtual bool Init();
  49. virtual void Shutdown();
  50. virtual void FrameUpdatePostEntityThink();
  51. virtual void LevelInitPostEntity();
  52. virtual char *GetFixedCameraEntityName( void ) { return "point_viewcontrol"; }
  53. bool SetCameraMan( int iPlayerIndex );
  54. int GetCameraMan() { return m_iCameraManIndex; }
  55. protected:
  56. virtual void StartNewShot();
  57. virtual void StartRandomShot();
  58. virtual void StartDelayMessage();
  59. virtual void StartBestFixedCameraShot(bool bForce);
  60. virtual void StartBestPlayerCameraShot();
  61. virtual void StartFixedCameraShot(int iCamera, int iTarget);
  62. virtual void StartChaseCameraShot(int iTarget1, int iTarget2, int distance, int phi, int theta, bool bInEye);
  63. virtual void UpdateSettings();
  64. virtual void AnalyzePlayers();
  65. virtual void AnalyzeCameras();
  66. virtual bool StartCameraManShot();
  67. virtual void StartInstantBroadcastShot();
  68. virtual void FinishCameraManShot();
  69. virtual void BuildActivePlayerList();
  70. virtual CHLTVGameEvent *FindBestGameEvent();
  71. virtual void CreateShotFromEvent( CHLTVGameEvent *ge );
  72. int FindFirstEvent( int tick ); // finds first event >= tick
  73. void CheckHistory();
  74. void RemoveEventsFromHistory(int tick); // removes all commands < tick, or all if tick -1
  75. IHLTVServer *m_pHLTVServer; // interface to servers HLTV object
  76. float m_fDelay; // hltv delay in seconds
  77. int m_nBroadcastTick; // world time that is currently "on the air"
  78. int m_iPVSEntity; // entity for PVS center
  79. Vector m_vPVSOrigin; // PVS origin if PVS entity is 0
  80. int m_iCameraMan; // >0 if current view entity is a cameraman
  81. CBasePlayer *m_pHLTVClient; // the HLTV fake client
  82. int m_nNextShotTick; // time for the next scene cut
  83. int m_iLastPlayer; // last player in random rotation
  84. int m_nNextAnalyzeTick;
  85. int m_nNumFixedCameras; //number of cameras in current map
  86. CBaseEntity *m_pFixedCameras[MAX_NUM_CAMERAS]; // fixed cameras (point_viewcontrol)
  87. int m_nNumActivePlayers; //number of cameras in current map
  88. CBasePlayer *m_pActivePlayers[MAX_PLAYERS]; // fixed cameras (point_viewcontrol)
  89. int m_iCameraManIndex; // entity index of current camera man or 0
  90. CUtlRBTree<CHLTVGameEvent> m_EventHistory;
  91. };
  92. extern IGameSystem* HLTVDirectorSystem();
  93. extern CHLTVDirector* HLTVDirector();
  94. #endif // HLTVDIRECTOR_H