mp/src/game/client/sdk/hud/da_hud_crosshair.cpp
bool CDAHudCrosshair::ShouldDraw( void )
{
	// OnThink isn't called when the thing isn't visible so force it to update.
	CalculateCrosshair();

	bool bNeedsDraw;

	if ( m_bHideCrosshair )
		return false;

	C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
	if ( !pPlayer )
		return false;

	ConVarRef cl_observercrosshair("cl_observercrosshair");

	// draw a crosshair only if alive or spectating in eye
	if ( IsX360() )
	{
		bNeedsDraw = m_pCrosshair && 
			!engine->IsDrawingLoadingImage() &&
			!engine->IsPaused() && 
			( !pPlayer->IsSuitEquipped() || g_pGameRules->IsMultiplayer() ) &&
			g_pClientMode->ShouldDrawCrosshair() &&
			!( pPlayer->GetFlags() & FL_FROZEN ) &&
			( pPlayer->entindex() == render->GetViewEntity() ) &&
			( pPlayer->IsAlive() ||	( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) || ( cl_observercrosshair.GetBool() && pPlayer->GetObserverMode() == OBS_MODE_ROAMING ) );
	}
	else
	{
		bNeedsDraw = m_pCrosshair && 
			da_crosshair.GetInt() &&
			!engine->IsDrawingLoadingImage() &&
			!engine->IsPaused() && 
			g_pClientMode->ShouldDrawCrosshair() &&
			!( pPlayer->GetFlags() & FL_FROZEN ) &&
			( pPlayer->entindex() == render->GetViewEntity() ) &&
			!pPlayer->IsInVGuiInputMode() &&
			( pPlayer->IsAlive() ||	( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) || ( cl_observercrosshair.GetBool() && pPlayer->GetObserverMode() == OBS_MODE_ROAMING ) );
	}

	return ( bNeedsDraw && CHudElement::ShouldDraw() );
}
//-----------------------------------------------------------------------------
// Purpose: Save CPU cycles by letting the HUD system early cull
// costly traversal.  Called per frame, return true if thinking and 
// painting need to occur.
//-----------------------------------------------------------------------------
Save CPU cycles by letting the HUD system early cull
costly traversal.  Called per frame, return true if thinking and
painting need to occur.
Save CPU cycles by letting the HUD system early cull costly traversal . Called per frame return true if thinking and painting need to occur .
bool CDAHudCrosshair::ShouldDraw( void )
{
	CalculateCrosshair();
	bool bNeedsDraw;
	if ( m_bHideCrosshair )
		return false;
	C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
	if ( !pPlayer )
		return false;
	ConVarRef cl_observercrosshair("cl_observercrosshair");
	if ( IsX360() )
	{
		bNeedsDraw = m_pCrosshair && 
			!engine->IsDrawingLoadingImage() &&
			!engine->IsPaused() && 
			( !pPlayer->IsSuitEquipped() || g_pGameRules->IsMultiplayer() ) &&
			g_pClientMode->ShouldDrawCrosshair() &&
			!( pPlayer->GetFlags() & FL_FROZEN ) &&
			( pPlayer->entindex() == render->GetViewEntity() ) &&
			( pPlayer->IsAlive() ||	( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) || ( cl_observercrosshair.GetBool() && pPlayer->GetObserverMode() == OBS_MODE_ROAMING ) );
	}
	else
	{
		bNeedsDraw = m_pCrosshair && 
			da_crosshair.GetInt() &&
			!engine->IsDrawingLoadingImage() &&
			!engine->IsPaused() && 
			g_pClientMode->ShouldDrawCrosshair() &&
			!( pPlayer->GetFlags() & FL_FROZEN ) &&
			( pPlayer->entindex() == render->GetViewEntity() ) &&
			!pPlayer->IsInVGuiInputMode() &&
			( pPlayer->IsAlive() ||	( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) || ( cl_observercrosshair.GetBool() && pPlayer->GetObserverMode() == OBS_MODE_ROAMING ) );
	}
	return ( bNeedsDraw && CHudElement::ShouldDraw() );
}
bool CDAHudCrosshair :: ShouldDraw ( void ) { CalculateCrosshair ( ) ; bool bNeedsDraw ; if ( m_bHideCrosshair ) return false ; C_BasePlayer * pPlayer = C_BasePlayer :: GetLocalPlayer ( ) ; if ( ! pPlayer ) return false ; ConVarRef cl_observercrosshair ( " " ) ; if ( IsX360 ( ) ) { bNeedsDraw = m_pCrosshair && ! engine -> IsDrawingLoadingImage ( ) && ! engine -> IsPaused ( ) && ( ! pPlayer -> IsSuitEquipped ( ) || g_pGameRules -> IsMultiplayer ( ) ) && g_pClientMode -> ShouldDrawCrosshair ( ) && ! ( pPlayer -> GetFlags ( ) & FL_FROZEN ) && ( pPlayer -> entindex ( ) == render -> GetViewEntity ( ) ) && ( pPlayer -> IsAlive ( ) || ( pPlayer -> GetObserverMode ( ) == OBS_MODE_IN_EYE ) || ( cl_observercrosshair . GetBool ( ) && pPlayer -> GetObserverMode ( ) == OBS_MODE_ROAMING ) ) ; } else { bNeedsDraw = m_pCrosshair && da_crosshair . GetInt ( ) && ! engine -> IsDrawingLoadingImage ( ) && ! engine -> IsPaused ( ) && g_pClientMode -> ShouldDrawCrosshair ( ) && ! ( pPlayer -> GetFlags ( ) & FL_FROZEN ) && ( pPlayer -> entindex ( ) == render -> GetViewEntity ( ) ) && ! pPlayer -> IsInVGuiInputMode ( ) && ( pPlayer -> IsAlive ( ) || ( pPlayer -> GetObserverMode ( ) == OBS_MODE_IN_EYE ) || ( cl_observercrosshair . GetBool ( ) && pPlayer -> GetObserverMode ( ) == OBS_MODE_ROAMING ) ) ; } return ( bNeedsDraw && CHudElement :: ShouldDraw ( ) ) ; }
Purpose: Save CPU cycles by letting the HUD system early cull
costly traversal.
Purpose : Save CPU cycles by letting the HUD system early cull costly traversal .
// OnThink isn't called when the thing isn't visible so force it to update. // draw a crosshair only if alive or spectating in eye