Exemplo n.º 1
0
bool CTornado::UseFunnelEffect(const char* effectName)
{
	m_pFunnelEffect = gEnv->pParticleManager->FindEffect(effectName);

	if (!m_pFunnelEffect)
		return false;

	// move particle slot to the helper position+offset
	GetEntity()->LoadParticleEmitter(0, m_pFunnelEffect, 0, false);
	Matrix34 tm(IDENTITY);
	GetEntity()->SetSlotLocalTM(0, tm);
	GetEntity()->SetSlotFlags(0, GetEntity()->GetSlotFlags(0)|ENTITY_SLOT_RENDER);
	IParticleEmitter* pEmitter = GetEntity()->GetParticleEmitter(0);
	assert(pEmitter);
	pEmitter->Prime();

	// init the first time
	if (!m_pCloudConnectEffect)
	{
		m_pCloudConnectEffect = gEnv->pParticleManager->FindEffect("weather.tornado.cloud_connection");
		if (m_pCloudConnectEffect)
		{
			GetEntity()->LoadParticleEmitter(1, m_pCloudConnectEffect, 0, true);
		}
	}
	if (!m_pTopEffect)
	{
		m_pTopEffect = gEnv->pParticleManager->FindEffect("weather.tornado.top_part");
		if (m_pTopEffect)
		{
			GetEntity()->LoadParticleEmitter(2, m_pTopEffect, 0, true);
		}
	}

	if (!m_pGroundEffect)
	{
		m_pGroundEffect = g_pGame->GetIGameFramework()->GetIEffectSystem()->CreateGroundEffect(GetEntity());
		m_pGroundEffect->SetParticleEffect("weather.tornado.leaves");
	}

	UpdateParticleEmitters();
	return true;
}
IParticleEmitter* EntityEffects::SpawnParticleFX( IParticleEffect* pParticleEffect, const EntityEffects::SEffectSpawnParams& spawnParams)
{
	if (pParticleEffect)
	{
		IParticleEmitter* pEmitter = pParticleEffect->Spawn(true, IParticleEffect::ParticleLoc(spawnParams.position, spawnParams.direction, spawnParams.scale));

		if (pEmitter != NULL && spawnParams.prime)
		{
			pEmitter->Prime();
		}

		if (spawnParams.speed > 0.0f)
		{
			ParticleParams particleParams = pParticleEffect->GetParticleParams();
			particleParams.fSpeed = spawnParams.speed;
			pParticleEffect->SetParticleParams(particleParams);
		}

		return pEmitter;
	}

	return NULL;
}