//------------------------------------------------------------------------ void CGameRulesHoldObjectiveBase::RadiusEffectPulse(EntityId entityId, eRadiusPulseType pulseType, float fScale) { IEntity* pEntity = gEnv->pEntitySystem->GetEntity(entityId); Vec3 entityPos(0.0f,0.0f,0.0f); if(pEntity) { entityPos = pEntity->GetPos(); entityPos.z += 0.5f; } if (m_effectData.pParticleEffect) { float particleEffectScale = fScale*m_effectData.particleEffectScale; IParticleEmitter* pEmitter = m_effectData.pParticleEffect->Spawn(false, IParticleEffect::ParticleLoc(entityPos, Vec3(0.f, 0.f, 1.f), particleEffectScale)); if(pEmitter) { SpawnParams spawnParams; pEmitter->GetSpawnParams(spawnParams); spawnParams.fStrength = m_effectData.particleColorLerp.GetValue(); pEmitter->SetSpawnParams(spawnParams); } } #ifndef _RELEASE if(g_pGameCVars->g_holdObjectiveDebug == eHOB_Debug_Fade_Ring_With_Pulse) { m_effectData.alphaLerp.Set(0.0f,0.0f,1.0f); } #endif // Start ring geom fade-in if(m_effectData.alphaLerp.GetValue() == 0.0f) { m_effectData.alphaLerp.Set(0.0f,1.0f,0.0f); m_effectData.alphaFadeInDelay = m_effectData.alphaFadeInDelayDuration; IEntity *pRingEntity = gEnv->pEntitySystem->GetEntity(m_effectData.ringEntityID); if(pRingEntity) { float ringGeomScale = fScale * m_effectData.ringGeomScale; pRingEntity->SetPos(entityPos); pRingEntity->SetScale(Vec3(ringGeomScale,ringGeomScale,1.0f)); #ifndef _RELEASE if(g_pGameCVars->g_holdObjectiveDebug == eHOB_Debug_Fade_Ring_With_Pulse) { pRingEntity->Hide(true); SetRingAlpha(pRingEntity,0.0f); } #endif } } }
void CSmokeManager::UpdateSmokeInstance(SSmokeInstance& smokeInstance, float dt) { IEntity * pGrenade = gEnv->pEntitySystem->GetEntity(smokeInstance.grenadeId); CullOtherSmokeEffectsInProximityWhenGrenadeHasLanded(smokeInstance,pGrenade); if(pGrenade) { //Update the radius of the smoke according to the speed of movement, // it should reduce to nothing when moving fast enough, and should increase // when the grenade is stationary Vec3 vNewPosition = pGrenade->GetPos(); Vec3 vPositionDiff = vNewPosition - smokeInstance.vPositon; const float fDistanceTravelled = vPositionDiff.len(); const float fSpeed = fDistanceTravelled * __fres(dt); const float fNewRadius = smokeInstance.fCurrentRadius + (float)__fsel( smokeInstance.fTimer-kInitialDelay, ((kSmokeRadiusIncrease - fSpeed) * dt), 0.0f); smokeInstance.fCurrentRadius = clamp(fNewRadius, 0.0f, kMaxSmokeRadius); // If grenade on ground, then override its timer to be maximum of kMaxPhysicsSleepTime if((smokeInstance.state == eSIS_Active_PhysicsAsleep) && (smokeInstance.fTimer < kInitialDelay-kMaxPhysicsSleepTime)) { smokeInstance.fTimer = kInitialDelay-kMaxPhysicsSleepTime; } const float previousTimer = smokeInstance.fTimer; smokeInstance.fTimer = smokeInstance.fTimer + dt; if(previousTimer < kInitialDelay && smokeInstance.fTimer >= kInitialDelay) { // Spawn explosion particle effect if (m_pExplosionParticleEffect) { m_pExplosionParticleEffect->Spawn(false,IParticleEffect::ParticleLoc(vNewPosition)); } // Spawn smoke particle effect // Find a free slot on the grenade SEntitySlotInfo dummySlotInfo; int i=0; while (pGrenade->GetSlotInfo(i, dummySlotInfo)) { i++; } if (m_pOutsideSmokeParticleEffect) { pGrenade->LoadParticleEmitter(i, m_pOutsideSmokeParticleEffect); IParticleEmitter* pEmitter = pGrenade->GetParticleEmitter(i); if(pEmitter) { SpawnParams spawnParams; pEmitter->GetSpawnParams(spawnParams); pEmitter->SetSpawnParams(spawnParams); } } } //Update the smoke's position smokeInstance.vPositon = vNewPosition; if (smokeInstance.pObstructObject) { pe_params_pos pos; pos.scale = clamp(smokeInstance.fCurrentRadius * __fres(kMaxSmokeRadius), 0.1f, 1.0f); pos.pos = vNewPosition; smokeInstance.pObstructObject->SetParams(&pos); } } else { //The grenade entity has been deleted, so smoke has stopped being produced if(smokeInstance.fTimer > kSmokeEmitEndTime) { //The smoke has cleared, delete the SmokeInstance smokeInstance.state = eSIS_ForDeletion; } else { //Count down the remaining life, and reduce the radius smokeInstance.fTimer += dt; smokeInstance.fCurrentRadius = max(smokeInstance.fCurrentRadius - (dt * kMaxSmokeRadius / kSmokeLingerTime), 0.0f); if (smokeInstance.pObstructObject) { pe_params_pos pos; pos.scale = clamp(smokeInstance.fCurrentRadius * __fres(kMaxSmokeRadius), 0.1f, 1.0f); smokeInstance.pObstructObject->SetParams(&pos); } } } }