Пример #1
0
void ByteQueue::Unget(byte inByte)
{
	Unget(&inByte, 1);
}
void CEnvEffectsScript::ParseNewEffect( void )
{
	//Add a new effect to the list.
	CEffectScriptElement NewElement;
	
	// Effect Group Name
	ParseToken();
	Q_strncpy( NewElement.m_szEffectName, token, sizeof( NewElement.m_szEffectName ) );

	while ( 1 )
	{
		ParseToken();

		// Oops, part of next definition
		if( IsRootCommand() )
		{
			Unget();
			break;
		}

		if ( !Q_stricmp( token, "{" ) )
		{
			while ( 1 )
			{
				ParseToken();
				if ( !Q_stricmp( token, "}" ) )
					break;

				if ( !Q_stricmp( token, "type" ) )
				{
					ParseToken();

					if ( !Q_stricmp( token, "trail" ) )
						NewElement.m_iType = EFFECT_TYPE_TRAIL;
					else if ( !Q_stricmp( token, "sprite" ) )
						NewElement.m_iType = EFFECT_TYPE_SPRITE;

					continue;
				}

				if ( !Q_stricmp( token, "material" ) )
				{
					ParseToken();
					Q_strncpy( NewElement.m_szMaterial, token, sizeof( NewElement.m_szMaterial ) );
					PrecacheModel( NewElement.m_szMaterial );

					continue;
				}

				if ( !Q_stricmp( token, "attachment" ) )
				{
					ParseToken();
					Q_strncpy( NewElement.m_szAttachment, token, sizeof( NewElement.m_szAttachment ) );

					continue;
				}

				if ( !Q_stricmp( token, "color" ) )
				{
					ParseToken();
					sscanf( token, "%i %i %i %i", &NewElement.m_iR, &NewElement.m_iG, &NewElement.m_iB, &NewElement.m_iA );

					continue;
				}

				if ( !Q_stricmp( token, "scale" ) )
				{
					ParseToken();

					NewElement.m_flScale = atof( token );
					continue;
				}

				if ( !Q_stricmp( token, "texturescale" ) )
				{
					ParseToken();

					float flTextureScale = atof( token );
					NewElement.m_flTextureRes = (flTextureScale > 0.0f) ? 1.0f / flTextureScale : 0.0f;
					continue;
				}

				if ( !Q_stricmp( token, "fadetime" ) )
				{
					ParseToken();

					NewElement.m_flFadeTime = atof( token );
					continue;
				}

				if ( !Q_stricmp( token, "stopfollowonkill" ) )
				{
					ParseToken();

					NewElement.m_bStopFollowOnKill = !!atoi( token );
					continue;
				}

			}
			break;
		}
	}

	m_ScriptElements.AddToTail( NewElement );
}