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.

76 lines
2.0 KiB

  1. //============ Copyright (c) Valve Corporation, All rights reserved. ============
  2. #ifndef GAME_TIMESCALE_SHARED_H
  3. #define GAME_TIMESCALE_SHARED_H
  4. #ifdef _WIN32
  5. #pragma once
  6. #endif
  7. #include "igamesystem.h"
  8. //=============================================================================
  9. //
  10. // Smoothly blends the timescale through an engine interface
  11. //
  12. class CGameTimescale : public CAutoGameSystemPerFrame
  13. {
  14. public:
  15. enum Interpolators_e
  16. {
  17. INTERPOLATOR_LINEAR,
  18. INTERPOLATOR_ACCEL,
  19. INTERPOLATOR_DEACCEL,
  20. INTERPOLATOR_EASE_IN_OUT,
  21. };
  22. // Creation/Destruction.
  23. CGameTimescale();
  24. ~CGameTimescale();
  25. // Initialization/Shutdown.
  26. virtual bool Init();
  27. virtual void Shutdown();
  28. #ifdef CLIENT_DLL
  29. virtual void Update( float frametime );
  30. #else
  31. virtual void FrameUpdatePostEntityThink();
  32. #endif
  33. // Level init, shutdown
  34. virtual void LevelInitPostEntity();
  35. virtual void LevelShutdownPostEntity();
  36. float GetCurrentTimescale( void ) const { return m_flCurrentTimescale; }
  37. float GetDesiredTimescale( void ) const { return m_flDesiredTimescale; }
  38. // Set the timescale to an exact value without doing a ramp in/out blend
  39. void SetCurrentTimescale( float flTimescale );
  40. // Sets the desired timescale and will automatically ramp in/out
  41. void SetDesiredTimescaleAtTime( float flDesiredTimescale, float flDurationRealTimeSeconds = 0.0f, Interpolators_e nInterpolatorType = INTERPOLATOR_LINEAR, float flStartBlendTime = 0.0f );
  42. void SetDesiredTimescale( float flDesiredTimescale, float flDurationRealTimeSeconds = 0.0f, Interpolators_e nInterpolatorType = INTERPOLATOR_LINEAR, float flDelayRealtime = 0.0f );
  43. private:
  44. void UpdateTimescale( void );
  45. void ResetTimescale( void );
  46. private:
  47. float m_flDesiredTimescale;
  48. float m_flCurrentTimescale;
  49. float m_flDurationRealTimeSeconds;
  50. Interpolators_e m_nInterpolatorType;
  51. float m_flStartTimescale;
  52. float m_flStartBlendTime;
  53. float m_flStartBlendRealtime;
  54. };
  55. CGameTimescale *GameTimescale();
  56. #endif // GAME_TIMESCALE_SHARED_H