bool CASW_Hud_Squad_Hotbar::ShouldDraw( void )
{
	if ( !ASWGameResource() )
		return false;

	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return false;

	if ( asw_hotbar_self.GetBool() )
	{
		return asw_draw_hud.GetBool() && CASW_HudElement::ShouldDraw();
	}

	m_iNumMarines = 0;
	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource* pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR )
			continue;

		if ( pMR->GetCommander() != pPlayer )
			continue;

		C_ASW_Marine *pMarine = pMR->GetMarineEntity();
		if ( !pMarine )
			continue;

		m_iNumMarines++;
	}

	return m_iNumMarines > 1 && asw_draw_hud.GetBool() && CASW_HudElement::ShouldDraw();
}
示例#2
0
void C_ASW_Alien::GetShadowFromFlashlight(Vector &vecDir, float &fContribution) const
{
	if (gpGlobals->framecount == m_iLastCustomFrame)
	{
		return;
	}
	
	if ( ASWGameResource() )
	{
		// go through all marines
		int iMaxMarines = ASWGameResource()->GetMaxMarineResources();
		for (int i=0;i<iMaxMarines;i++)
		{
			C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource(i);
			C_ASW_Marine *pMarine = pMR ? pMR->GetMarineEntity() : NULL;
			if (pMarine && pMarine->m_pFlashlight)	// if this is a marine with a flashlight
			{
				Vector diff = WorldSpaceCenter() - pMarine->EyePosition();
				if (diff.Length() < 700.0f)
				{
					diff.NormalizeInPlace();
					Vector vecMarineFacing(0,0,0);
					AngleVectors(pMarine->GetAbsAngles(), &vecMarineFacing);
					float dot = vecMarineFacing.Dot(diff);
					if (dot > 0.2)	// if the flashlight is facing us
					{
						vecDir += dot * diff;
						fContribution += (dot - 0.2f) * 1.25f;
					}
				}
			}
		}
	}
}
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++;
			}
		}		
	}
}
示例#4
0
void CASWHudPortraits::OnThink()
{
    VPROF_BUDGET( "CASWHudPortraits::OnThink", VPROF_BUDGETGROUP_ASW_CLIENT );

    int iNumMyMarines = 0;
    int iNumOtherMarines = 0;
    C_ASW_Player *local = C_ASW_Player::GetLocalASWPlayer();
    if ( local )
    {
        C_ASW_Game_Resource* pGameResource = ASWGameResource();
        if (pGameResource)
        {
            for (int i=0; i<pGameResource->GetMaxMarineResources(); i++)
            {
                C_ASW_Marine_Resource* pMR = pGameResource->GetMarineResource(i);
                if (pMR)
                {
                    if (pMR->GetCommander() == local)
                    {
                        m_hMyMarine[iNumMyMarines] = pMR;

                        iNumMyMarines++;
                        if (pMR->GetMarineEntity() == local->GetMarine())
                            m_hCurrentlySelectedMarineResource = pMR;
                    }
                    else if (!(ASWGameRules() && ASWGameRules()->IsTutorialMap()))	// in tutorial, don't show marines not under your command
                    {
                        m_hOtherMarine[iNumOtherMarines] = pMR;
                        iNumOtherMarines++;
                    }
                }
            }
            // clear out future slots
            for (int i=iNumMyMarines; i<ASW_MAX_MARINE_RESOURCES; i++)
            {
                m_hMyMarine[i] == NULL;
            }
            for (int i=iNumOtherMarines; i<ASW_MAX_MARINE_RESOURCES; i++)
            {
                m_hOtherMarine[i] == NULL;
            }
        }
    }
    // JOYPAD REMOVED
    //bool bJoypadModeChanged = (m_bLastJoypadMode != engine->ASW_IsJoypadMode());
    //m_bLastJoypadMode = engine->ASW_IsJoypadMode();
    bool bJoypadModeChanged = m_bLastJoypadMode = false;
    bool bResize = ((m_iNumMyMarines != iNumMyMarines) || (m_iNumOtherMarines != iNumOtherMarines) || bJoypadModeChanged);
    m_iNumMyMarines = iNumMyMarines;
    m_iNumOtherMarines = iNumOtherMarines;

    UpdatePortraits(bResize);
}
/// @TODO can use a more optimal sorting strategy
void C_ASW_Game_Resource::CMarineToCrosshairInfo::RecomputeCache()
{
	VPROF("C_ASW_Game_Resource::CMarineToCrosshairInfo::RecomputeCache()");
	C_ASW_Game_Resource * RESTRICT  pGameResource = ASWGameResource();
	// purge the array.
	m_tMarines.RemoveAll();

	const Vector vecCrosshairAimingPos = ASWInput()->GetCrosshairAimingPos();

	for ( int i=0; i<pGameResource->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = pGameResource->GetMarineResource(i);
		C_ASW_Marine *pMarine;
		if ( pMR && (pMarine = pMR->GetMarineEntity()) )
		{
			float dist = (vecCrosshairAimingPos - pMR->GetMarineEntity()->GetAbsOrigin()).Length2D();
			m_tMarines.AddToTail( tuple_t(pMarine, dist) );
		}
	}

	m_tMarines.Sort( &MarineTupleComparator );

	m_iLastFrameCached = gpGlobals->framecount;
}
示例#6
0
void CASWHudEmotes::PaintEmotes()
{
    C_ASW_Game_Resource *pGameResource = ASWGameResource();
    if (!pGameResource)
        return;

    for (int i=0; i<pGameResource->GetMaxMarineResources(); i++)
    {
        C_ASW_Marine_Resource *pMR = pGameResource->GetMarineResource(i);
        if (!pMR)
            continue;

        C_ASW_Marine *marine = pMR->GetMarineEntity();
        if ( !marine )
            continue;

        PaintEmotesFor(marine);
    }
}
void CASW_Hud_Squad_Hotbar::UpdateList()
{
	if ( !ASWGameResource() )
		return;

	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();

	int iEntry = 0;
	bool bHasItem = false;
	if ( asw_hotbar_self.GetBool() )
	{
		if ( iEntry >= m_pEntries.Count() )
		{
			CASW_Hotbar_Entry *pPanel = new CASW_Hotbar_Entry( this, "SquadInventoryPanelEntry" );
			m_pEntries.AddToTail( pPanel );
			InvalidateLayout();
		}

		// add your offhand item to the hotbar first
		CASW_Marine *pPlayerMarine = pPlayer->GetMarine();
		if ( pPlayerMarine )
		{
			C_ASW_Weapon *pWeapon = pPlayerMarine->GetASWWeapon( ASW_INVENTORY_SLOT_EXTRA );
			if ( pWeapon )
			{
				m_pEntries[ iEntry ]->m_iHotKeyIndex = -1;
				m_pEntries[ iEntry ]->SetVisible( true );
				m_pEntries[ iEntry ]->SetDetails( pPlayerMarine, ASW_INVENTORY_SLOT_EXTRA );
				bHasItem = true;
			}
		}

		if ( !bHasItem )	// blank it out if there's no item in that slot
		{
			m_pEntries[ iEntry ]->m_iHotKeyIndex = iEntry;
			m_pEntries[ iEntry ]->SetDetails( NULL, -1 );
			m_pEntries[ iEntry ]->SetVisible( false );
		}

		iEntry++;
	}

	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource* pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR )
			continue;

		if ( pMR->GetCommander() != pPlayer )
			continue;

		C_ASW_Marine *pMarine = pMR->GetMarineEntity();
		if ( !pMarine )
			continue;

		if ( pMarine->IsInhabited() )
			continue;

		if ( iEntry >= m_pEntries.Count() )
		{
			CASW_Hotbar_Entry *pPanel = new CASW_Hotbar_Entry( this, "SquadInventoryPanelEntry" );
			m_pEntries.AddToTail( pPanel );
			InvalidateLayout();
		}

		bHasItem = false;
		for ( int k = 0; k < ASW_NUM_INVENTORY_SLOTS; k++ )
		{
			C_ASW_Weapon *pWeapon = pMarine->GetASWWeapon( k );
			if ( !pWeapon )
				continue;

			const CASW_WeaponInfo* pInfo = pWeapon->GetWeaponInfo();
			if ( !pInfo || !pInfo->m_bOffhandActivate )		// TODO: Fix for sentry guns
				continue;

			m_pEntries[ iEntry ]->m_iHotKeyIndex = iEntry;
			m_pEntries[ iEntry ]->SetVisible( true );
			m_pEntries[ iEntry ]->SetDetails( pMarine, k );
			bHasItem = true;

			if ( asw_hotbar_simple.GetBool() )		// only 1 item per marine
				break;
		}

		if ( !bHasItem )	// blank it out if there's no item in that slot
		{
			m_pEntries[ iEntry ]->m_iHotKeyIndex = iEntry;
			m_pEntries[ iEntry ]->SetDetails( NULL, -1 );
			m_pEntries[ iEntry ]->SetVisible( false );
		}

		iEntry++;
	}

	for ( int i = iEntry; i < m_pEntries.Count(); i++ )
	{
		m_pEntries[ i ]->SetVisible( false );
	}
}