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.

124 lines
4.2 KiB

  1. //========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef REPLAYDIRECTOR_H
  7. #define REPLAYDIRECTOR_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "GameEventListener.h"
  12. #include <igamesystem.h>
  13. #include <ireplaydirector.h>
  14. #include <ireplay.h>
  15. #include <utlrbtree.h>
  16. #define REPLAY_MIN_DIRECTOR_DELAY 10 // minimum delay if director is enabled
  17. #define REPLAY_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 CReplayGameEvent
  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 CReplayDirector : public CGameEventListener, public CBaseGameSystemPerFrame, public IReplayDirector
  30. {
  31. public:
  32. DECLARE_CLASS_NOBASE( CReplayDirector );
  33. virtual char const *Name() { return "CReplayDirector"; }
  34. CReplayDirector();
  35. virtual ~CReplayDirector();
  36. virtual void SetReplayServer( IReplayServer *replay ); // give the director an Replay interface
  37. IReplayServer* GetReplayServer( 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 Replay 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 CReplayGameEvent *FindBestGameEvent();
  71. virtual void CreateShotFromEvent( CReplayGameEvent *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. IReplayServer *m_pReplayServer; // interface to servers Replay object
  76. float m_fDelay; // replay 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_pReplayClient; // the Replay 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<CReplayGameEvent> m_EventHistory;
  91. };
  92. extern IGameSystem* ReplayDirectorSystem();
  93. extern CReplayDirector* ReplayDirector();
  94. #endif // REPLAYDIRECTOR_H