Пример #1
0
// Fetch template if we have a valid template index, create a new custom template if we don't
AvHParticleTemplate*
AvHParticleSystemEntity::GetCustomTemplate()
{
	AvHParticleTemplate* theTemplate = NULL;

	if(!this->mCreatedTemplate)
	{
		if(this->mTemplateIndex == -1)
		{
			// Create a new template, none was specified in the name field
			ASSERT(!this->mCreatedTemplate);
			this->mTemplateIndex = gParticleTemplateList.CreateTemplateFromIndex();
		}
		//else
		//{
		//	// Create a template from our existing base template
		//	this->mTemplateIndex = gParticleTemplateList.CreateTemplateFromIndex(this->mTemplateIndex);
		//}
		
		// Set the name of our new custom particle system
		theTemplate = gParticleTemplateList.GetTemplateAtIndex(this->mTemplateIndex);
		ASSERT(theTemplate);
		string theName = STRING(this->pev->targetname);
		theTemplate->SetName(theName);
		
		this->mCreatedTemplate = true;
	}
	
	ASSERT(this->mTemplateIndex != -1);
	if(!theTemplate)
		theTemplate = gParticleTemplateList.GetTemplateAtIndex(this->mTemplateIndex);
	
	return theTemplate;
}
Пример #2
0
void
AvHParticleSystemEntity::Spawn( void )
{
	// Just in case our class derives off of something else in the future
	CBaseEntity::Spawn();
	
	this->Precache();
	
	this->pev->classname = MAKE_STRING(kesParticlesCustom);
	this->pev->solid = SOLID_NOT;
	this->pev->movetype = MOVETYPE_NONE;
	//this->pev->movetype = MOVETYPE_PUSH;
	//this->pev->effects = EF_BRIGHTLIGHT;
	
	this->SetTouch(&AvHParticleSystemEntity::ParticleTouch);
	this->SetUse(&AvHParticleSystemEntity::ParticleUse);
	
	SET_MODEL(ENT(this->pev), kNullModel);
	UTIL_SetOrigin(this->pev, this->pev->origin);
	
	// Set the other flags
	AvHParticleTemplate* theTemplate = gParticleTemplateList.GetTemplateAtIndex(this->mTemplateIndex);
	//ASSERT(theTemplate);
	if(theTemplate)
	{
		//theTemplate->SetFlags(theSpawnFlags);
		
		string theTargetName = STRING(this->pev->targetname);
		if(!FStrEq(theTargetName.c_str(), ""))
		{
			theTemplate->SetName(theTargetName);
		}
		
		this->SetThink(&AvHParticleSystemEntity::ParticleThink);
		pev->nextthink = gpGlobals->time + kDefaultParticleSystemThinkRate;
		
		// The spawn flags field is the only one that doesn't get set through KeyValue(), so
		// we set it in the template this way
		int theSpawnFlags = this->pev->spawnflags;
		if(!theSpawnFlags)
		{
			theSpawnFlags = theTemplate->GetFlags();
		}

		// Did they check the "start on" flag?
		if(theSpawnFlags & 1)
		{
			this->mUseState = true;
		}

		theTemplate->SetFlags(theSpawnFlags);
	}
	else
	{
		ALERT(at_logged, "Couldn't find particle system template: %d\n", this->mTemplateIndex);
		UTIL_Remove(this);
	}
}
int	AvHParticleTemplateListClient::InitializeDemoPlayback(int inSize, unsigned char* inBuffer, int index)
{
	// Read one particle template and add it to the list
	int theBytesRead = 0;

	AvHParticleTemplate theTemplate;

	// Read all fields
	string theTemplateName;
	LoadStringData(theTemplateName, inBuffer, theBytesRead);
	theTemplate.SetName(theTemplateName);

	uint32 theMaxParticles;
	LOAD_DATA(theMaxParticles);
	theTemplate.SetMaxParticles(theMaxParticles);

	float theParticleSize;
	LOAD_DATA(theParticleSize);
	theTemplate.SetParticleSize(theParticleSize);

	float theParticleSystemLifetime;
	LOAD_DATA(theParticleSystemLifetime);
	theTemplate.SetParticleSystemLifetime(theParticleSystemLifetime);
	
	float theParticleLifetime;
	LOAD_DATA(theParticleLifetime);
	theTemplate.SetParticleLifetime(theParticleLifetime);
	
	string theSpriteName;
	LoadStringData(theSpriteName, inBuffer, theBytesRead);
	theTemplate.SetSprite(theSpriteName);

	ShapeType theGenerationShape;
	LOAD_DATA(theGenerationShape);
	theTemplate.SetGenerationShape(theGenerationShape);

	string theGenerationEntityName;
	LoadStringData(theGenerationEntityName, inBuffer, theBytesRead);
	theTemplate.SetGenerationEntityName(theGenerationEntityName);

	string theParticleSystemToGenerate;
	LoadStringData(theParticleSystemToGenerate, inBuffer, theBytesRead);
	theTemplate.SetParticleSystemToGenerate(theParticleSystemToGenerate);

	int theParticleSystemIndexToGenerate;
	LOAD_DATA(theParticleSystemIndexToGenerate);
	theTemplate.SetParticleSystemIndexToGenerate(theParticleSystemIndexToGenerate);

	int theGenerationEntityIndex;
	LOAD_DATA(theGenerationEntityIndex);
	theTemplate.SetGenerationEntityIndex(theGenerationEntityIndex);
	
	float theGenerationEntityParameter;
	LOAD_DATA(theGenerationEntityParameter);
	theTemplate.SetGenerationEntityParameter(theGenerationEntityParameter);

	ShapeType theStartingVelocityShape;
	LOAD_DATA(theStartingVelocityShape);
	theTemplate.SetStartingVelocityShape(theStartingVelocityShape);

	ParticleParams theGenerationParams;
	LOAD_DATA(theGenerationParams);
	theTemplate.SetGenerationParams(theGenerationParams);

	ParticleParams theStartingVelocityParams;
	LOAD_DATA(theStartingVelocityParams);
	theTemplate.SetStartingVelocityParams(theStartingVelocityParams);

	uint32 theGenerationRate;
	LOAD_DATA(theGenerationRate);
	theTemplate.SetGenerationRate(theGenerationRate);

	int theParticleFlags;
	LOAD_DATA(theParticleFlags);
	theTemplate.SetFlags(theParticleFlags);

	PSVector theGravity;
	LOAD_DATA(theGravity);
	theTemplate.SetGravity(theGravity);

	float theAnimationSpeed;
	LOAD_DATA(theAnimationSpeed);
	theTemplate.SetAnimationSpeed(theAnimationSpeed);

	int theNumSpriteFrames;
	LOAD_DATA(theNumSpriteFrames);
	theTemplate.SetNumSpriteFrames(theNumSpriteFrames);

	float theParticleScaling;
	LOAD_DATA(theParticleScaling);
	theTemplate.SetParticleScaling(theParticleScaling);

	int theRenderMode;
	LOAD_DATA(theRenderMode);
	theTemplate.SetRenderMode(theRenderMode);

	float theMaxAlpha;
	LOAD_DATA(theMaxAlpha);
	theTemplate.SetMaxAlpha(theMaxAlpha);

	// Save the template
	this->mTemplateList[index]=theTemplate;

	return theBytesRead;
}