//internal function called to handle creation of a client effect into the provided object using //the provided values bool CClientFXMgr::StartClientFX(CClientFXInstance* pInstance, const CLIENTFX_CREATESTRUCT &fxInit) { if(!pInstance) return false; const FX_GROUP *pRef = CClientFXDB::GetSingleton().FindGroupFX(fxInit.m_sName); if (!pRef) return false; pInstance->m_hParent = fxInit.m_hParentObject; pInstance->m_hTarget = fxInit.m_hTargetObject; pInstance->m_bLoop = (fxInit.m_dwFlags & FXFLAG_LOOP) ? true : false; pInstance->m_bSmoothShutdown = (fxInit.m_dwFlags & FXFLAG_NOSMOOTHSHUTDOWN) ? false : true; pInstance->m_bShutdown = false; // Load the instance with all the inactive FX pInstance->m_fDuration = pRef->m_tmTotalTime; pInstance->m_tmElapsed = 0.0f; //also make sure to save our creation structure #ifndef _FINAL pInstance->SetCreateStruct(fxInit); #endif //now go through and actually create all of our keys for(uint32 nCurrKey = 0; nCurrKey < pRef->m_KeyList.GetSize(); nCurrKey++) { //make sure that the detail level is enabled if(!IsDetailLevelEnabled(pRef->m_KeyList[nCurrKey].m_pProps->m_nDetailLevel)) { continue; } //make sure that the gore level is enabled if(!IsGoreLevelEnabled(pRef->m_KeyList[nCurrKey].m_pProps->m_eGoreSetting)) { continue; } //make sure that the slow motion level is enabled if(!IsSlowMotionLevelEnabled(pRef->m_KeyList[nCurrKey].m_pProps->m_eSlowMotion)) { continue; } CreateFXKey(fxInit, pInstance, &pRef->m_KeyList[nCurrKey]); } // Success !! return true; }
CLIENTFX_INSTANCE* CClientFXMgr::CreateClientFX(const CLIENTFX_CREATESTRUCT &fxInit, LTBOOL bStartInst, bool bAddNextUpdate) { //setup the callback in case it creates any effects when it is created SetupCreateEffectCallback(); FX_GROUP *pRef = CClientFXDB::GetSingleton().FindGroupFX(fxInit.m_sName); if (!pRef) return NULL; CLIENTFX_INSTANCE *pNewInst = g_pCLIENTFX_INSTANCE_Bank->New(); //debug_new( CLIENTFX_INSTANCE ); if( !pNewInst ) return NULL; pNewInst->m_pData = pRef; pNewInst->m_dwID = GetUniqueID(); pNewInst->m_hParent = fxInit.m_hParent; pNewInst->m_bLoop = (fxInit.m_dwFlags & FXFLAG_LOOP) ? true : false; pNewInst->m_bSmoothShutdown = (fxInit.m_dwFlags & FXFLAG_NOSMOOTHSHUTDOWN) ? false : true; pNewInst->m_dwObjectFlags |= (fxInit.m_dwFlags & FXFLAG_REALLYCLOSE) ? FLAG_REALLYCLOSE : 0; pNewInst->m_bPlayerView = !!(fxInit.m_dwFlags & FXFLAG_REALLYCLOSE); pNewInst->m_bShutdown = false; pNewInst->m_hTarget = fxInit.m_hTarget; pNewInst->m_bUseTargetData = fxInit.m_bUseTargetData; pNewInst->m_vTargetPos = fxInit.m_vTargetPos; pNewInst->m_vTargetNorm = fxInit.m_vTargetNorm; pNewInst->m_pLink = LTNULL; // Load the instance with all the inactive FX pNewInst->m_fDuration = pRef->m_tmTotalTime; // Add it to the appropriate list if(bAddNextUpdate) { m_collNextUpdateGroupFX.AddTail(pNewInst); } else { m_collActiveGroupFX.AddTail(pNewInst); } // Set the position if( pNewInst->m_bPlayerView ) { pNewInst->m_vPos.Init(); pNewInst->m_rRot.Init(); } else if (fxInit.m_hParent) { g_pLTClient->GetObjectPos(fxInit.m_hParent,&pNewInst->m_vPos); g_pLTClient->GetObjectRotation( fxInit.m_hParent, &pNewInst->m_rRot ); } else { pNewInst->m_vPos = fxInit.m_vPos; pNewInst->m_rRot = fxInit.m_rRot; } pNewInst->m_tmElapsed = 0.0f; //now go through and actually create all of our keys for(uint32 nCurrKey = 0; nCurrKey < pRef->m_nNumKeys; nCurrKey++) { //make sure that the detail level is enabled if(!IsDetailLevelEnabled(pRef->m_pKeys[nCurrKey].m_nDetailLevel)) { continue; } //make sure that if it is gore, we can show gore if(!m_bGoreEnabled && pRef->m_pKeys[nCurrKey].m_bGore) { continue; } CreateFXKey(pNewInst, &pRef->m_pKeys[nCurrKey]); } // Immediatly start the instance if told to. if( bStartInst ) { //make sure it is visible pNewInst->Show(); //and create any effects that start out instantly UpdateInstanceInterval(pNewInst, 0.0f, 0.0f); } // Success !! return pNewInst; }