LTBOOL CSteamFX::Update() { if (m_bWantRemove) return LTFALSE; // Debugging aid... if (s_cvarTweak.GetFloat() > 0) { TweakSystem(); } // Start/stop steam sound if necessary... if (m_hServerObject) { uint32 dwUserFlags; g_pLTClient->GetObjectUserFlags(m_hServerObject, &dwUserFlags); if (!(dwUserFlags & USRFLG_VISIBLE)) { if ((m_dwLastUserFlags & USRFLG_VISIBLE)) { StopSound(); } } else // visible { if (!(m_dwLastUserFlags & USRFLG_VISIBLE)) { StartSound(); } } m_dwLastUserFlags = dwUserFlags; // Make sure the sound is in the correct place (in case we are getting // keyframed)... if (m_hSound) { LTVector vPos; g_pLTClient->GetObjectPos(m_hServerObject, &vPos); g_pLTClient->SetSoundPosition(m_hSound, &vPos); } // Update the steam velocity based on our current rotation (again // for keyframing)... LTRotation rRot; g_pLTClient->GetObjectRotation(m_hServerObject, &rRot); LTVector vU, vR, vF; g_pLTClient->GetRotationVectors(&rRot, &vU, &vR, &vF); m_Steam.SetDriftVel(vF * (m_cs.fVel * 0.75f), vF * m_cs.fVel); } return m_Steam.Update(); }
LTBOOL CLineSystemFX::Update() { if (!m_hObject || !m_pClientDE || m_bWantRemove) return LTFALSE; LTFLOAT fTime = m_pClientDE->GetTime(); // Hide/show the line system if necessary... if (m_hServerObject) { uint32 dwUserFlags; g_pCommonLT->GetObjectFlags(m_hServerObject, OFT_User, dwUserFlags); if (!(dwUserFlags & USRFLG_VISIBLE)) { g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, 0, FLAG_VISIBLE); m_fLastTime = fTime; return LTTRUE; } else { g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE); } } // Debugging aid... if (s_cvarTweak.GetFloat() > 0) { TweakSystem(); } if (m_bFirstUpdate) { m_fLastTime = fTime; m_bFirstUpdate = LTFALSE; } else { UpdateSystem(); } // Make sure it is time to update... if (fTime < m_fLastTime + m_fNextUpdate) { return LTTRUE; } // Ok, how many to add this frame.... float fTimeDelta = fTime - m_fLastTime; // Make sure delta time is no less than 15 frames/sec if we're // continuously adding lines... if (m_bContinuous) { fTimeDelta = fTimeDelta > 0.0666f ? 0.0666f : fTimeDelta; } int nToAdd = (int) floor(m_cs.fLinesPerSecond * fTimeDelta); nToAdd = LTMIN(nToAdd, (int)(MAX_LINES_PER_SECOND * fTimeDelta)); // Add new lines... AddLines(nToAdd); // Determine when next update should occur... if (m_cs.fBurstWait > 0.001f) { m_fNextUpdate = m_cs.fBurstWait * GetRandom(m_cs.fBurstWaitMin, m_cs.fBurstWaitMax); } else { m_fNextUpdate = 0.001f; } m_fLastTime = fTime; return LTTRUE; }
LTBOOL CParticleSystemFX::Update() { if (!m_hObject || !m_pClientDE || m_bWantRemove) return LTFALSE; LTFLOAT fTime = m_pClientDE->GetTime(); // Hide/show the particle system if necessary... if (m_hServerObject) { uint32 dwUserFlags; g_pCommonLT->GetObjectFlags(m_hServerObject, OFT_User, dwUserFlags); if (!(dwUserFlags & USRFLG_VISIBLE)) { uint32 dwFlags; g_pCommonLT->GetObjectFlags(m_hObject, OFT_Flags, dwFlags); // Once last puff as disappeared, hide the system (no new puffs // will be added...) if (dwFlags & FLAG_VISIBLE) { if (fTime > m_fLastTime + m_cs.fParticleLifetime) { g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, 0, FLAG_VISIBLE); } } else { m_fLastTime = fTime; } return LTTRUE; } else { g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE); } } // Debugging aid... if (s_cvarTweak.GetFloat() > 0) { TweakSystem(); } if (m_bFirstUpdate) { m_fLastTime = fTime; m_bFirstUpdate = LTFALSE; } // Make sure it is time to update... if (fTime < m_fLastTime + m_fNextUpdate) { return LTTRUE; } // Ok, how many to add this frame....(make sure time delta is no more than // 15 frames/sec... float fTimeDelta = fTime - m_fLastTime; fTimeDelta = fTimeDelta > 0.0666f ? 0.0666f : fTimeDelta; int nToAdd = (int) floor(m_cs.fParticlesPerSecond * fTimeDelta); nToAdd = LTMIN(nToAdd, (int)(MAX_PARTICLES_PER_SECOND * fTimeDelta)); nToAdd = GetNumParticles(nToAdd); m_pClientDE->AddParticles(m_hObject, nToAdd, &m_vMinOffset, &m_vMaxOffset, // Position offset &(m_cs.vMinVel), &(m_cs.vMaxVel), // Velocity &(m_cs.vColor1), &(m_cs.vColor2), // Color m_cs.fParticleLifetime, m_cs.fParticleLifetime); // Determine when next update should occur... if (m_cs.fBurstWait > 0.001f) { m_fNextUpdate = m_cs.fBurstWait * GetRandom(m_cs.fBurstWaitMin, m_cs.fBurstWaitMax); } else { m_fNextUpdate = 0.001f; } // Rotate the particle system... if (m_cs.fRotationVelocity != 0.0f) { LTRotation rRot; g_pLTClient->GetObjectRotation(m_hObject, &rRot); rRot.Rotate(rRot.Up(), g_pGameClientShell->GetFrameTime() * m_cs.fRotationVelocity); g_pLTClient->SetObjectRotation(m_hObject, &rRot); } m_fLastTime = fTime; return LTTRUE; }