void CASWHud3DMarineNames::PaintMarineNameLabels()
{
	C_ASW_Player *local = C_ASW_Player::GetLocalASWPlayer();
	if ( !local )
		return;

	C_ASW_Game_Resource *pGameResource = ASWGameResource();
	if ( !pGameResource )
		return;

	int count = 0;
	int my_count = 0;
	for ( int i = 0; i < pGameResource->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = pGameResource->GetMarineResource( i );
		if ( pMR && pMR->GetHealthPercent() > 0 )
		{
			C_ASW_Marine *pMarine = pMR->GetMarineEntity();
			if ( pMarine )
			{
				if ( pMarine->GetCommander() == local )
				{
					PaintMarineLabel( my_count, pMarine, pMR, local->GetMarine() == pMarine );
					my_count++;
				}
				else
				{
					PaintMarineLabel( -1, pMarine, pMR, false );
				}

				count++;
			}
		}		
	}
}
void CASW_Weapon_Sniper_Rifle::UpdateDynamicLight()
{
	// DLIGHT disabled, since it looks bad
	return;

	C_ASW_Marine *pMarine =GetMarine();
	C_ASW_Player *pPlayer = pMarine ? pMarine->GetCommander() : NULL;
	
	if ( !pMarine || pMarine->GetActiveWeapon() != this || !pPlayer || !pMarine->IsInhabited() || !pPlayer->IsLocalPlayer() )
	{
		if (m_pSniperDynamicLight)
		{			
			m_pSniperDynamicLight->die = gpGlobals->curtime + 0.001;
			m_pSniperDynamicLight = NULL;
		}
		return;
	}

	if ( !m_pSniperDynamicLight || (m_pSniperDynamicLight->key != index) )
	{
		m_pSniperDynamicLight = effects->CL_AllocDlight ( index );
	}

	//m_fAmbientLight = asw_flashlight_marine_ambient.GetFloat();
	//m_fLightingScale = asw_flashlight_marine_lightscale.GetFloat();

	Vector vecForward, vecRight, vecUp;

	if (m_pSniperDynamicLight)
	{
		AngleVectors( GetLocalAngles(), &vecForward, &vecRight, &vecUp );
		m_pSniperDynamicLight->origin = pPlayer->GetCrosshairTracePos() + Vector( 0, 0, 10 );	
		Msg( "crosshair trace pos is %f %f %f\n", VectorExpand( pPlayer->GetCrosshairTracePos() ) );
		debugoverlay->AddTextOverlay( m_pSniperDynamicLight->origin, 0.01f, "Light" );
		m_pSniperDynamicLight->color.r = asw_sniper_dlight_r.GetInt();
		m_pSniperDynamicLight->color.g = asw_sniper_dlight_g.GetInt();
		m_pSniperDynamicLight->color.b = asw_sniper_dlight_b.GetInt();
		m_pSniperDynamicLight->radius = asw_sniper_dlight_radius.GetFloat();
		m_pSniperDynamicLight->color.exponent = asw_sniper_dlight_exponent.GetFloat();
		//m_pSniperDynamicLight->decay = 0;
		m_pSniperDynamicLight->die = gpGlobals->curtime + 30.0f;
	}
}
void C_ASW_AOEGrenade_Projectile::UpdateTargetAOEEffects( void )
{
	// Find all the targets we've stopped giving a buff to
	AOEGrenTargetFXList_t::IndexLocalType_t i = m_hAOETargetEffects.Head();
	while ( m_hAOETargetEffects.IsValidIndex(i) )
	{
		AOETargetEffects_t &aoeTargetEffect = m_hAOETargetEffects[i];
		Assert( m_hAOETargetEffects[i].me == &m_hAOETargetEffects[i] );
		bool bStillAOEGren = false;

		// Are we still buffing this target?
		for ( int target = 0; target < m_hAOETargets.Count(); target++ )
		{
			if ( m_hAOETargets[target] && m_hAOETargets[target] == aoeTargetEffect.hTarget.Get() )
			{
				bStillAOEGren = true;
				break;
			}
		}

		// advance before deleting the pointer out from under us
		const AOEGrenTargetFXList_t::IndexLocalType_t oldi = i;
		i = m_hAOETargetEffects.Next( i );

		if ( !bStillAOEGren )
		{
			ParticleProp()->StopEmission( aoeTargetEffect.pEffect );

			// stop the sound on this marine
			C_ASW_Marine *pMarine = dynamic_cast<C_ASW_Marine*>( m_hAOETargetEffects[oldi].hTarget.Get() );
			if ( pMarine && pMarine->GetCommander() )
			{
				C_ASW_Player *pLocalPlayer = C_ASW_Player::GetLocalASWPlayer();
				if ( pMarine->GetCommander() == pLocalPlayer && pMarine->IsInhabited() && m_hAOETargetEffects[oldi].pBuffLoopSound )
				{
					CSoundEnvelopeController::GetController().SoundDestroy( m_hAOETargetEffects[oldi].pBuffLoopSound );
					m_hAOETargetEffects[oldi].pBuffLoopSound = NULL;
				}
			}

			m_hAOETargetEffects.Remove(oldi);
		}
	}

	// Now add any new targets
	for ( int i = 0; i < m_hAOETargets.Count(); i++ )
	{
		C_BaseEntity *pTarget = m_hAOETargets[i].Get();

		// Loops through the aoe targets, and make sure we have an effect for each of them
		if ( pTarget )
		{
			bool bHaveEffect = false;

			for ( AOEGrenTargetFXList_t::IndexLocalType_t i = m_hAOETargetEffects.Head() ;
				  m_hAOETargetEffects.IsValidIndex(i) ;
				  i = m_hAOETargetEffects.Next(i) )
			{
				if ( m_hAOETargetEffects[i].hTarget.Get() == pTarget )
				{
					bHaveEffect = true;
					break;
				}
			}

			if ( !bHaveEffect )
			{
				CNewParticleEffect *pEffect = ParticleProp()->Create( GetArcEffectName(), PATTACH_ABSORIGIN_FOLLOW );

				AOEGrenTargetFXList_t::IndexLocalType_t iIndex = m_hAOETargetEffects.AddToTail();
				m_hAOETargetEffects[iIndex].hTarget = pTarget;
				m_hAOETargetEffects[iIndex].pEffect = pEffect;
				Assert( m_hAOETargetEffects[iIndex].me == &m_hAOETargetEffects[iIndex] );

				UpdateParticleAttachments( m_hAOETargetEffects[iIndex].pEffect, pTarget );

				// Start the sound over again every time we start a new beam
				//StopSound( GetLoopSoundName() );

				C_ASW_Marine *pMarine = C_ASW_Marine::AsMarine( pTarget );
				if ( pMarine && pMarine->GetCommander() )
				{
					C_ASW_Player *pLocalPlayer = C_ASW_Player::GetLocalASWPlayer();
					if ( pMarine->GetCommander() == pLocalPlayer && pMarine->IsInhabited() )
					{
						if ( m_hAOETargetEffects[iIndex].pBuffLoopSound )
						{
							CSoundEnvelopeController::GetController().SoundDestroy( m_hAOETargetEffects[iIndex].pBuffLoopSound );
							m_hAOETargetEffects[iIndex].pBuffLoopSound = NULL;
						}

						CSingleUserRecipientFilter filter( pLocalPlayer );
						EmitSound( filter, pMarine->entindex(), GetStartSoundName() );
						m_hAOETargetEffects[iIndex].pBuffLoopSound = CSoundEnvelopeController::GetController().SoundCreate( filter, pMarine->entindex(), GetLoopSoundName() );
						CSoundEnvelopeController::GetController().Play( m_hAOETargetEffects[iIndex].pBuffLoopSound, 1.0, 100 );
					}
				}
			}
		}
	}
}