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.

49 lines
1.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #include "thinkmanager.h"
  5. #include "ithinker.h"
  6. #include "replay/ienginereplay.h"
  7. #include "replay_dbg.h"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include "tier0/memdbgon.h"
  10. //----------------------------------------------------------------------------------------
  11. extern IEngineReplay *g_pEngine;
  12. //----------------------------------------------------------------------------------------
  13. void CThinkManager::AddThinker( IThinker *pThinker )
  14. {
  15. Assert( m_lstManagers.Find( pThinker ) == m_lstManagers.InvalidIndex() );
  16. m_lstManagers.AddToTail( pThinker );
  17. }
  18. void CThinkManager::RemoveThinker( IThinker *pThinker )
  19. {
  20. int it = m_lstManagers.Find( pThinker ); Assert( it != m_lstManagers.InvalidIndex() );
  21. m_lstManagers.Remove( it );
  22. }
  23. void CThinkManager::Think()
  24. {
  25. FOR_EACH_LL( m_lstManagers, i )
  26. {
  27. IThinker *pCurThinker = m_lstManagers[ i ];
  28. if ( !pCurThinker->ShouldThink() )
  29. continue;
  30. pCurThinker->Think();
  31. pCurThinker->PostThink();
  32. }
  33. }
  34. //----------------------------------------------------------------------------------------
  35. static CThinkManager s_ThinkManager;
  36. IThinkManager *g_pThinkManager = &s_ThinkManager;
  37. //----------------------------------------------------------------------------------------