bool CPSSpawnEffect::Update(const float &time, const double &elapsedTime) { if (m_fDieTime > 0.0f && m_fDieTime <= time) dying = true; else if (m_iNumParticles == 0) dying = true; if (dying) return 1; if (!(m_iFlags & RENDERSYSTEM_FLAG_DONTFOLLOW)) FollowEntity(); CParticle *curPart = NULL; for (int i = 0; i < m_iNumParticles; ++i) { curPart = &m_pParticleList[i]; if (curPart->m_fEnergy <= 0.0f) m_pParticleList[i] = m_pParticleList[--m_iNumParticles]; VectorCopy(curPart->m_vPos, curPart->m_vPosPrev); curPart->m_vPos[0] = m_vecOrigin[0] + m_fRadius*sinf(-6.0f*time + (float)(i*2)); curPart->m_vPos[1] = m_vecOrigin[1] + m_fRadius*cosf(-6.0f*time + (float)(i*2)); curPart->m_vPos[2] = curPart->m_vPos[2] + curPart->m_vVel[2]*elapsedTime; VectorMA(curPart->m_vVel, elapsedTime, curPart->m_vAccel, curPart->m_vVel); if (m_iFlags & RENDERSYSTEM_FLAG_RANDOMFRAME) curPart->FrameRandomize(); else curPart->FrameIncrease(); // curPart->m_fEnergy += m_fBrightnessDelta*elapsedTime; curPart->UpdateColor(elapsedTime); curPart->UpdateSize(elapsedTime); curPart->UpdateEnergyByBrightness(); } m_fRadius += m_fRadiusDelta*elapsedTime;// effect radius is increasing return 0; }
//----------------------------------------------------------------------------- // Purpose: Update system parameters along with time // DO NOT PERFORM ANY DRAWING HERE! // Input : &time - current client time // &elapsedTime - time elapsed since last frame // Output : Returns true if needs to be removed //----------------------------------------------------------------------------- bool CPSDrips::Update(const float &time, const double &elapsedTime) { if (m_fDieTime > 0 && m_fDieTime <= time) dying = true; if (dying && m_iNumParticles == 0) return 1; // if (!(m_iFlags & RENDERSYSTEM_FLAG_DONTFOLLOW)) // if (FollowEntity() == false)// entity not visible // return 0; // CON_DPRINTF(" .. CPSDrips::Update() (e %d)\n", m_iFollowEntity); // Emit(ceil((float)m_iMaxParticles*0.5f)); Emit(max(1, m_iMaxParticles>>2));// 1/4 int c = 0; pmtrace_t pmtrace; CParticle *curPart = NULL; gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction(false, true); gEngfuncs.pEventAPI->EV_PushPMStates();// BUGBUG: do not call this during map loading process gEngfuncs.pEventAPI->EV_SetSolidPlayers(-1); gEngfuncs.pEventAPI->EV_SetTraceHull(2); for (int i = 0; i < m_iNumParticles; ++i) { curPart = &m_pParticleList[i]; if (curPart->m_fEnergy <= 0.0f) m_pParticleList[i] = m_pParticleList[--m_iNumParticles]; if (curPart->m_iFlags & PARTICLE_FLAG1)// splash { curPart->m_fEnergy -= (float)(1.5 * elapsedTime); } else { VectorCopy(curPart->m_vPos, curPart->m_vPosPrev); // BUGBUG TODO FIXME T_T do something with this!!! VectorMA(curPart->m_vVel, elapsedTime, curPart->m_vAccel, curPart->m_vVel); VectorMA(curPart->m_vPos, elapsedTime, curPart->m_vVel, curPart->m_vPos); //works LAGLAG VectorMA(curPart->m_vPos, elapsedTime, curPart->m_vVelAdd, curPart->m_vPos); //works VectorScale(curPart->m_vVelAdd, 1.0f-elapsedTime*2.0f, curPart->m_vVelAdd); // VectorMA(curPart->m_vAccel, elapsedTime*-0.1, curPart->m_vAccel, curPart->m_vAccel); gEngfuncs.pEventAPI->EV_PlayerTrace(curPart->m_vPosPrev, curPart->m_vPos, PM_STUDIO_BOX, -1, &pmtrace); if (!pmtrace.inwater) c = gEngfuncs.PM_PointContents(curPart->m_vPos, NULL); if (pmtrace.inwater || (c < CONTENTS_SOLID && c > CONTENTS_SKY)) { // CON_DPRINTF("in water\n"); VectorClear(curPart->m_vVel); if (/*m_iSplashTexture > 0*/m_pTexture2 && PointIsVisible(curPart->m_vPos))// FIXME too slow? { curPart->m_pTexture = m_pTexture2;//IEngineStudio.GetModelByIndex(m_iSplashTexture); /* if (!curPart->m_pTexture || curPart->m_pTexture->type != mod_sprite) { curPart->m_fEnergy = -1.0f; continue; } else*/ { // CON_DPRINTF("texture loaded\n"); curPart->m_fEnergy = 1.0f; // curPart->m_fSizeX = 4.0f; // curPart->m_fSizeY = 4.0f; curPart->SetSizeFromTexture(m_fScale, m_fScale);// slow? curPart->m_fSizeDelta = SPLASH_SIZE_DELTA; curPart->m_iFlags |= PARTICLE_FLAG1; curPart->m_iFrame = 0; #ifdef DRIPSPARALLELTEST// testing: circles parallel to surface Vector normal;//, angles; VectorCopy(pmtrace.plane.normal, normal); normal[0] *= -1.0f; normal[1] *= -1.0f; VectorAngles(normal, curPart->m_vVel);// angles #endif// unused since there is only horizontal water in Half-Life } } else { curPart->m_fEnergy = -1.0f; continue; } } else if (pmtrace.fraction != 1.0f) { // if (m_iFlags & RENDERSYSTEM_FLAG_CLIPREMOVE || c == CONTENTS_SOLID || !PointIsVisible(curPart->m_vPos)) curPart->m_fEnergy = -1.0f; curPart->m_fSizeDelta = 0.0f; VectorClear(curPart->m_vVel); continue; } } if (m_iFlags & RENDERSYSTEM_FLAG_RANDOMFRAME) curPart->FrameRandomize(); else curPart->FrameIncrease(); curPart->UpdateColor(elapsedTime); curPart->UpdateSize(elapsedTime); curPart->m_fColor[3] = curPart->m_fEnergy; } gEngfuncs.pEventAPI->EV_PopPMStates(); return 0; }