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.

78 lines
2.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Deals with precaching requests from client effects
  4. //
  5. // $Revision: $
  6. // $NoKeywords: $
  7. //=============================================================================//
  8. #include "cbase.h"
  9. #include "fx.h"
  10. #include "clienteffectprecachesystem.h"
  11. #include "particles/particles.h"
  12. // memdbgon must be the last include file in a .cpp file!!!
  13. #include "tier0/memdbgon.h"
  14. //Global singelton accessor
  15. CClientEffectPrecacheSystem *ClientEffectPrecacheSystem( void )
  16. {
  17. static CClientEffectPrecacheSystem s_ClientEffectPrecacheSystem;
  18. return &s_ClientEffectPrecacheSystem;
  19. }
  20. //-----------------------------------------------------------------------------
  21. // Purpose: Precache all the registered effects
  22. //-----------------------------------------------------------------------------
  23. void CClientEffectPrecacheSystem::LevelInitPreEntity( void )
  24. {
  25. //Precache all known effects
  26. for ( int i = 0; i < m_Effects.Size(); i++ )
  27. {
  28. m_Effects[i]->Cache();
  29. }
  30. //FIXME: Double check this
  31. //Finally, force the cache of these materials
  32. materials->CacheUsedMaterials();
  33. // Now, cache off our material handles
  34. FX_CacheMaterialHandles();
  35. }
  36. //-----------------------------------------------------------------------------
  37. // Purpose: Nothing to do here
  38. //-----------------------------------------------------------------------------
  39. void CClientEffectPrecacheSystem::LevelShutdownPreEntity( void )
  40. {
  41. }
  42. //-----------------------------------------------------------------------------
  43. // Purpose: Dereference all the registered effects
  44. //-----------------------------------------------------------------------------
  45. void CClientEffectPrecacheSystem::LevelShutdownPostEntity( void )
  46. {
  47. // mark all known effects as free
  48. for ( int i = 0; i < m_Effects.Size(); i++ )
  49. {
  50. m_Effects[i]->Cache( false );
  51. }
  52. }
  53. //-----------------------------------------------------------------------------
  54. // Purpose: Purges the effect list
  55. //-----------------------------------------------------------------------------
  56. void CClientEffectPrecacheSystem::Shutdown( void )
  57. {
  58. //Release all effects
  59. m_Effects.Purge();
  60. }
  61. //-----------------------------------------------------------------------------
  62. // Purpose: Adds the effect to the list to be precached
  63. // Input : *effect - system to precache
  64. //-----------------------------------------------------------------------------
  65. void CClientEffectPrecacheSystem::Register( IClientEffect *effect )
  66. {
  67. //Hold onto this effect for precaching later
  68. m_Effects.AddToTail( effect );
  69. }