//----------------------------------------------------------------------------- // Frame-based update //----------------------------------------------------------------------------- void CTeleportCountdownScreen::OnTick() { BaseClass::OnTick(); // Find the active info teleporter countdown C_InfoTeleporterCountdown *pActiveCountdown = NULL; for ( int i = g_InfoTeleporterCountdownList.Head(); i != g_InfoTeleporterCountdownList.InvalidIndex(); i = g_InfoTeleporterCountdownList.Next(i) ) { if ( g_InfoTeleporterCountdownList[i]->m_bCountdownStarted ) { pActiveCountdown = g_InfoTeleporterCountdownList[i]; break; } } if ( !GetEntity() || !pActiveCountdown ) { m_pTimeRemainingTitleLabel->SetVisible( false ); m_pTimeRemainingLabel->SetVisible( false ); m_pMalfunctionLabel->SetVisible( false ); return; } // Make the appropriate labels visible bool bMalfunction = pActiveCountdown->m_bDisabled; m_pTimeRemainingTitleLabel->SetVisible( !bMalfunction ); m_pTimeRemainingLabel->SetVisible( !bMalfunction ); // This will make it flash m_pMalfunctionLabel->SetVisible( bMalfunction && (((int)(gpGlobals->curtime) & 0x1) == 0x1) ); // Update the time remaining if ( !bMalfunction ) { char buf[32]; if (m_pTimeRemainingLabel) { float dt = gpGlobals->curtime - pActiveCountdown->m_flStartTime; if ( dt < 0.0f ) { dt = 0.0f; } int nTimeRemaining = (int)(pActiveCountdown->m_flTimeRemaining - dt + 0.5f); if ( nTimeRemaining < 0 ) { nTimeRemaining = 0; } Q_snprintf( buf, sizeof( buf ), "%d", nTimeRemaining ); m_pTimeRemainingLabel->SetText( buf ); } } }
//----------------------------------------------------------------------------- // Sets up visibility //----------------------------------------------------------------------------- void PointCameraSetupVisibility( CBaseEntity *pPlayer, int area, unsigned char *pvs, int pvssize ) { for ( CPointCamera *pCameraEnt = GetPointCameraList(); pCameraEnt != NULL; pCameraEnt = pCameraEnt->m_pNext ) { pCameraEnt->SetActive( false ); } int nNext; for ( int i = g_InfoCameraLinkList.Head(); i != g_InfoCameraLinkList.InvalidIndex(); i = nNext ) { nNext = g_InfoCameraLinkList.Next( i ); CBaseEntity *pTargetEnt = g_InfoCameraLinkList[i]->m_hTargetEntity; if ( !pTargetEnt ) { UTIL_Remove( g_InfoCameraLinkList[i] ); continue; } // Don't bother if it's not visible if ( pTargetEnt->IsEffectActive( EF_NODRAW ) ) continue; if ( !pTargetEnt->NetworkProp()->IsInPVS( pPlayer->edict(), pvs, pvssize ) ) continue; if ( engine->CheckAreasConnected( area, pTargetEnt->NetworkProp()->AreaNum() ) ) { CPointCamera *pCameraEnt = g_InfoCameraLinkList[i]->m_hCamera; if ( pCameraEnt ) { engine->AddOriginToPVS( pCameraEnt->GetAbsOrigin() ); pCameraEnt->SetActive( true ); } } } }