diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/clienteffectprecachesystem.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/client/clienteffectprecachesystem.cpp')
| -rw-r--r-- | game/client/clienteffectprecachesystem.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/game/client/clienteffectprecachesystem.cpp b/game/client/clienteffectprecachesystem.cpp new file mode 100644 index 0000000..c5d4e07 --- /dev/null +++ b/game/client/clienteffectprecachesystem.cpp @@ -0,0 +1,78 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Deals with precaching requests from client effects +// +// $Revision: $ +// $NoKeywords: $ +//=============================================================================// +#include "cbase.h" +#include "fx.h" +#include "clienteffectprecachesystem.h" +#include "particles/particles.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +//Global singelton accessor +CClientEffectPrecacheSystem *ClientEffectPrecacheSystem( void ) +{ + static CClientEffectPrecacheSystem s_ClientEffectPrecacheSystem; + return &s_ClientEffectPrecacheSystem; +} + +//----------------------------------------------------------------------------- +// Purpose: Precache all the registered effects +//----------------------------------------------------------------------------- +void CClientEffectPrecacheSystem::LevelInitPreEntity( void ) +{ + //Precache all known effects + for ( int i = 0; i < m_Effects.Size(); i++ ) + { + m_Effects[i]->Cache(); + } + + //FIXME: Double check this + //Finally, force the cache of these materials + materials->CacheUsedMaterials(); + + // Now, cache off our material handles + FX_CacheMaterialHandles(); +} + +//----------------------------------------------------------------------------- +// Purpose: Nothing to do here +//----------------------------------------------------------------------------- +void CClientEffectPrecacheSystem::LevelShutdownPreEntity( void ) +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Dereference all the registered effects +//----------------------------------------------------------------------------- +void CClientEffectPrecacheSystem::LevelShutdownPostEntity( void ) +{ + // mark all known effects as free + for ( int i = 0; i < m_Effects.Size(); i++ ) + { + m_Effects[i]->Cache( false ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: Purges the effect list +//----------------------------------------------------------------------------- +void CClientEffectPrecacheSystem::Shutdown( void ) +{ + //Release all effects + m_Effects.Purge(); +} + +//----------------------------------------------------------------------------- +// Purpose: Adds the effect to the list to be precached +// Input : *effect - system to precache +//----------------------------------------------------------------------------- +void CClientEffectPrecacheSystem::Register( IClientEffect *effect ) +{ + //Hold onto this effect for precaching later + m_Effects.AddToTail( effect ); +} |