Esempio n. 1
0
void Item::SetCoolItem( qboolean cool, const str &dialog, const str &anim )
{
	coolitem = cool;
	cool_dialog = dialog;
	if ( cool_dialog.length() )
	{
		CacheResource( cool_dialog, this );
	}
	
	CacheResource( "models/fx_coolitem.tik", this );
	CacheResource( "models/fx_coolitem_reverse.tik", this );
	
	cool_anim = anim;
}
//-----------------------------------------------------------------------------
// Purpose: Precache game-specific models & sounds
//-----------------------------------------------------------------------------
void CPrecacheHandler::CacheResourceFile( const char *pFilename, bool bPrecache, ResourceList_t hResourceList )
{
	COMPILE_TIME_ASSERT( ARRAYSIZE(s_pPrecacheResourceTypeName) == PRECACHE_RESOURCE_TYPE_COUNT );

	KeyValues *pValues = new KeyValues( "ResourceFile" );

	if ( !pValues->LoadFromFile( g_pFullFileSystem, pFilename, "GAME" ) )
	{
		Warning( "Can't open %s for client precache info.", pFilename );
		pValues->deleteThis();
		return;
	}

	for ( KeyValues *pData = pValues->GetFirstSubKey(); pData != NULL; pData = pData->GetNextKey() )
	{
		const char *pszType = pData->GetName();
		const char *pszFile = pData->GetString();

		if ( Q_strlen( pszType ) == 0 || Q_strlen( pszFile ) == 0 )
			continue;

		bool bFoundMatch = false;
		for ( int i = 0; i < PRECACHE_RESOURCE_TYPE_COUNT; ++i )
		{
			if ( !Q_stricmp( pData->GetName(), s_pPrecacheResourceTypeName[i] ) )
			{
				CacheResource( (PrecacheResourceType_t)i, pszFile, bPrecache, hResourceList );
				bFoundMatch = true;
				break;
			}
		}

		if ( !bFoundMatch )
		{
			Warning( "Error in precache file \"%s\":\n", pFilename );
			Warning( "\tUnknown resource type specified \"%s\", value \"%s\"\n", pszType, pszFile );
		}
	}

	pValues->deleteThis();
}
Esempio n. 3
0
//
// Name:        RegisterPackage
// Parameters:  str &packageName
// Description: Adds the package to the _BehaviorPackages container
//
void PackageManager::RegisterPackage( const str &packageName )
{
	BehaviorPackageEntry_t pEntry;
	BehaviorPackageType_t  *package;
	BehaviorPackageEntry_t *checkEntry;
	
	for ( int i = 1 ; i <= PackageList.NumObjects() ; i++ )
	{
		package = PackageList.ObjectAt( i );
		
		if ( !Q_stricmp( packageName.c_str() , package->packageName.c_str() ) )
		{
			// We have a match, let's check to make sure we're not doubling up
			for ( int j = 1 ; j <= _BehaviorPackages.NumObjects() ; j++ )
			{
				checkEntry = &_BehaviorPackages.ObjectAt( j );
				
				if ( checkEntry->packageIndex == i )
					return;
			}
			
			// We don't have a match, so lets add the package
			pEntry.currentScore     = 0;
			pEntry.lastScore        = 0;	
			pEntry.lastTimeExecuted = 0.0f;
			pEntry.priority         = 0.001f;
			pEntry.packageIndex     = i;
			
			_BehaviorPackages.AddObject( pEntry );
			
			// Make sure state machine gets cached properly
			
			CacheResource( package->stateFile, act );
			G_CacheStateMachineAnims( act, package->stateFile );
			
			return;
		}
	}
}
void CPrecacheHandler::PrecachePhysicsSounds( const char *pName, bool bPrecache, ResourceList_t hResourceList )
{
	if ( !bPrecache )
		return;

	// precache the surface prop sounds
	bool bBulletSounds = !Q_stricmp( pName, "BulletSounds" );
	bool bStepSounds = !Q_stricmp( pName, "StepSounds" );
	bool bPhysicsImpactSounds = !Q_stricmp( pName, "PhysicsImpactSounds" );

	for ( int i = 0; i < physprops->SurfacePropCount(); i++ )
	{
		surfacedata_t *pprop = physprops->GetSurfaceData( i );
		Assert( pprop );

		if ( bBulletSounds )
		{
			const char *pSoundName = physprops->GetString( pprop->sounds.bulletImpact );
			CacheResource( GAMESOUND, pSoundName, bPrecache, hResourceList, NULL );
		}

		if ( bStepSounds )
		{
			const char *pSoundName = physprops->GetString( pprop->sounds.walkStepLeft );
			CacheResource( GAMESOUND, pSoundName, bPrecache, hResourceList, NULL );
			pSoundName = physprops->GetString( pprop->sounds.walkStepRight );
			CacheResource( GAMESOUND, pSoundName, bPrecache, hResourceList, NULL );
			pSoundName = physprops->GetString( pprop->sounds.runStepLeft );
			CacheResource( GAMESOUND, pSoundName, bPrecache, hResourceList, NULL );
			pSoundName = physprops->GetString( pprop->sounds.runStepRight );
			CacheResource( GAMESOUND, pSoundName, bPrecache, hResourceList, NULL );
		}

		if ( bPhysicsImpactSounds )
		{
			const char *pSoundName = physprops->GetString( pprop->sounds.impactSoft );
			CacheResource( GAMESOUND, pSoundName, bPrecache, hResourceList, NULL );
			pSoundName = physprops->GetString( pprop->sounds.impactHard );
			CacheResource( GAMESOUND, pSoundName, bPrecache, hResourceList, NULL );
			pSoundName = physprops->GetString( pprop->sounds.scrapeSmooth );
			CacheResource( GAMESOUND, pSoundName, bPrecache, hResourceList, NULL );
			pSoundName = physprops->GetString( pprop->sounds.scrapeRough );
			CacheResource( GAMESOUND, pSoundName, bPrecache, hResourceList, NULL );
			pSoundName = physprops->GetString( pprop->sounds.rolling );
			CacheResource( GAMESOUND, pSoundName, bPrecache, hResourceList, NULL );
			pSoundName = physprops->GetString( pprop->sounds.breakSound );
			CacheResource( GAMESOUND, pSoundName, bPrecache, hResourceList, NULL );
			pSoundName = physprops->GetString( pprop->sounds.strainSound );
			CacheResource( GAMESOUND, pSoundName, bPrecache, hResourceList, NULL );
		}
	}
}