Example #1
0
//-----------------------------------------------------------------------------
// 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 );
			}
		}
	}
}
bool CASW_VGUI_Stylin_Cam::ShouldShowStylinCam()
{
	if ( !ASWGameRules() )
		return false;

	if ( ASWGameRules()->ShouldShowCommanderFace() )
		return false;

	C_ASW_Player *pLocal = C_ASW_Player::GetLocalASWPlayer();
	bool bHasMarine = pLocal && pLocal->GetMarine();

	bool bAdrenalineActive = GameTimescale()->GetCurrentTimescale() <= asw_stim_cam_time.GetFloat() && ASWGameRules()->GetStimEndTime() >= gpGlobals->curtime;
	bool bShowCam = ASWGameRules()->ShouldForceStylinCam() ||
		( bAdrenalineActive && bHasMarine );

	if ( bShowCam && !ASWGameRules()->ShouldShowCommanderFace() )
	{
		// check if there's a mapper designed camera turned on
		C_PointCamera *pCameraEnt = GetPointCameraList();
		bool bMapperCam = false;
		for ( int cameraNum = 0; pCameraEnt != NULL; pCameraEnt = pCameraEnt->m_pNext )
		{
			if ( pCameraEnt != pLocal->GetStimCam() && pCameraEnt->IsActive() && !pCameraEnt->IsDormant()
				&& !(ASW_IsSecurityCam(pCameraEnt) && asw_stim_cam_time.GetFloat()!=2.0f))
			{							
				bMapperCam = true;
				break;
			}
			++cameraNum;
		}
		if ( !bMapperCam && !asw_spinning_stim_cam.GetBool() && !ASWGameRules()->ShouldShowCommanderFace() )	// don't show the cam if the mapper hasn't set a specific view, unless the convar is set
			bShowCam = false;
	}

	return bShowCam;
}