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.

48 lines
1.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: random steam class
  4. //
  5. //===========================================================================//
  6. #include <tier0/dbg.h>
  7. #include <vstdlib/random.h>
  8. #include "cdll_int.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. //-----------------------------------------------------------------------------
  12. //
  13. // implementation of IUniformRandomStream
  14. //
  15. //-----------------------------------------------------------------------------
  16. class CEngineUniformRandomStream : public IUniformRandomStream
  17. {
  18. public:
  19. // Sets the seed of the random number generator
  20. void SetSeed( int iSeed )
  21. {
  22. // Never call this from the client or game!
  23. Assert(0);
  24. }
  25. // Generates random numbers
  26. float RandomFloat( float flMinVal = 0.0f, float flMaxVal = 1.0f )
  27. {
  28. return ::RandomFloat( flMinVal, flMaxVal );
  29. }
  30. float RandomFloatExp( float flMinVal = 0.0f, float flMaxVal = 1.0f, float flExponent = 1.0f )
  31. {
  32. return ::RandomFloatExp( flMinVal, flMaxVal, flExponent );
  33. }
  34. int RandomInt( int iMinVal, int iMaxVal )
  35. {
  36. return ::RandomInt( iMinVal, iMaxVal );
  37. }
  38. };
  39. static CEngineUniformRandomStream s_EngineRandomStream;
  40. EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CEngineUniformRandomStream, IUniformRandomStream,
  41. VENGINE_CLIENT_RANDOM_INTERFACE_VERSION, s_EngineRandomStream );