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.

56 lines
1.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TEST_STRESSENTITIES_H
  8. #define TEST_STRESSENTITIES_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. class CBaseEntity;
  13. typedef CBaseEntity* (*StressEntityFn)(); // Function to create an entity for the stress test.
  14. // Each game DLL can instantiate these to register types of entities it can create
  15. // for the entity stress test.
  16. class CStressEntityReg
  17. {
  18. public:
  19. CStressEntityReg( StressEntityFn fn )
  20. {
  21. m_pFn = fn;
  22. m_pNext = s_pHead;
  23. s_pHead = this;
  24. }
  25. static CStressEntityReg*GetListHead() { return s_pHead; }
  26. CStressEntityReg* GetNext() { return m_pNext; }
  27. StressEntityFn GetFn() { return m_pFn; }
  28. private:
  29. static CStressEntityReg *s_pHead; // List of all CStressEntityReg's.
  30. CStressEntityReg *m_pNext;
  31. StressEntityFn m_pFn;
  32. };
  33. // Use this macro to register a function to create stresstest entities.
  34. #define REGISTER_STRESS_ENTITY( fnName ) static CStressEntityReg s_##fnName##__( fnName );
  35. // Helper function for the functions that create the stress entities.
  36. // Moves the entity to a random place in the level and returns the entity.
  37. CBaseEntity* MoveToRandomSpot( CBaseEntity *pEnt );
  38. Vector GetRandomSpot();
  39. #endif // TEST_STRESSENTITIES_H