当前位置: 首页>>代码示例>>C++>>正文


C++ C_BaseObject类代码示例

本文整理汇总了C++中C_BaseObject的典型用法代码示例。如果您正苦于以下问题:C++ C_BaseObject类的具体用法?C++ C_BaseObject怎么用?C++ C_BaseObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了C_BaseObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetOwningObject

//-----------------------------------------------------------------------------
// Purpose: Handle ammo input to the sentrygun
//-----------------------------------------------------------------------------
void CSentrygunControlPanel::AddAmmo( void )
{
	C_BaseObject *pObj = GetOwningObject();
	if (pObj)
	{
		pObj->SendClientCommand( "addammo" );
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:11,代码来源:c_objectsentrygun.cpp

示例2: GetOwningObject

//-----------------------------------------------------------------------------
// Purpose: Handle clicking on the Occupy button
//-----------------------------------------------------------------------------
void CVehicleWagonControlPanel::GetInRam( void )
{
	C_BaseObject *pObj = GetOwningObject();
	if (pObj)
	{
		pObj->SendClientCommand( "toggle_use" );
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:11,代码来源:c_vehicle_wagon.cpp

示例3: GetOwningObject

//-----------------------------------------------------------------------------
// Purpose: Handle clicking on the Connect/Disconnect button
//-----------------------------------------------------------------------------
void CBuffStationControlPanel::ConnectToStation( void )
{
	C_BaseObject *pObj = GetOwningObject();
	if (pObj)
	{
		pObj->SendClientCommand( "toggle_connect" );
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:11,代码来源:c_obj_buff_station.cpp

示例4: OnSliderMoved

void CRotationSlider::OnSliderMoved( int position )
{
    C_BaseObject *pObj = m_hObject.Get();
    if (pObj && pObj->IsPreviewingYaw())
    {
        m_flYaw = anglemod(position);
        pObj->PreviewYaw( m_flInitialYaw - m_flYaw );
    }
}
开发者ID:steadyfield,项目名称:SourceEngine2007,代码行数:9,代码来源:vgui_rotation_slider.cpp

示例5: GetOwningObject

//-----------------------------------------------------------------------------
// Buys stuff
//-----------------------------------------------------------------------------
void CResupplyControlPanel::Buy( ResupplyBuyType_t type )
{
	C_BaseObject *pObj = GetOwningObject();
	if (pObj)
	{
		char szbuf[48];
		Q_snprintf( szbuf, sizeof( szbuf ), "buy %d", type );
		pObj->SendClientCommand( szbuf );
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:13,代码来源:c_obj_resupply.cpp

示例6: OnMousePressed

//-----------------------------------------------------------------------------
// When the slider is activated, deactivated, or moves
//-----------------------------------------------------------------------------
void CRotationSlider::OnMousePressed( vgui::MouseCode code )
{
    BaseClass::OnMousePressed( code );

    if (code != vgui::MOUSE_LEFT)
        return;

    C_BaseObject *pObj = m_hObject.Get();
    if (pObj)
    {
        m_flInitialYaw = pObj->GetAbsAngles().y;
        pObj->PreviewYaw( m_flInitialYaw );
        pObj->ActivateYawPreview( true );
    }
}
开发者ID:steadyfield,项目名称:SourceEngine2007,代码行数:18,代码来源:vgui_rotation_slider.cpp

示例7: OnMouseReleased

void CRotationSlider::OnMouseReleased( vgui::MouseCode code )
{
    BaseClass::OnMouseReleased( code );

    if (code != vgui::MOUSE_LEFT)
        return;

    C_BaseObject *pObj = m_hObject.Get();
    if (pObj)
    {
        char szbuf[48];
        Q_snprintf( szbuf, sizeof( szbuf ), "yaw %0.2f\n",  m_flInitialYaw - m_flYaw );
        pObj->SendClientCommand( szbuf );
        pObj->ActivateYawPreview( false );
        SetValue(0);
        m_flYaw = 0;
    }
}
开发者ID:steadyfield,项目名称:SourceEngine2007,代码行数:18,代码来源:vgui_rotation_slider.cpp

示例8: PerformLayout

//-----------------------------------------------------------------------------
// Purpose: Calc visibility of subpanels
//-----------------------------------------------------------------------------
void CBuildingStatusItem::PerformLayout( void )
{
	BaseClass::PerformLayout();

	C_BaseObject *pObj = m_pObject.Get();

	m_bActive = ( pObj != NULL );

	m_pHealthBar->SetVisible( m_bActive );

	m_pNotBuiltPanel->SetVisible( !m_bActive );
	m_pBuiltPanel->SetVisible( m_bActive );

	if ( pObj )
	{
		// redo the background
		m_pBackground->SetIcon( GetBackgroundImage() );

		if ( pObj->IsBuilding() )
		{
			m_pBuildingPanel->SetVisible( true );
			m_pRunningPanel->SetVisible( false );
		}
		else
		{
			m_pBuildingPanel->SetVisible( false );
			m_pRunningPanel->SetVisible( true );
		}
	}
	else
	{
		// redo the background
		m_pBackground->SetIcon( GetInactiveBackgroundImage() );

		if ( m_pAlertTray->IsTrayOut() )
		{
			m_pAlertTray->HideTray();
			m_pWrenchIcon->SetVisible( false );
			m_pSapperIcon->SetVisible( false );
		}
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:45,代码来源:tf_hud_building_status.cpp

示例9: OnBind

//-----------------------------------------------------------------------------
// Set the appropriate texture...
//-----------------------------------------------------------------------------
void CObjectBuildAlphaProxy::OnBind( C_BaseEntity *pEntity )
{
	if( !m_pAlphaVar )
		return;
	
	// It needs to be a TF2 C_BaseObject to have this proxy applied
	C_BaseObject *pObject = dynamic_cast< C_BaseObject * >( pEntity );
	if ( !pObject )
		return;

	float build_amount = pObject->m_flCycle; //pObject->GetPercentageConstructed();
	float frac;

	if ( build_amount <= buildstart )
	{
		frac = 0.0f;
	}
	else if ( build_amount >= buildend )
	{
		frac = 1.0f;
	}
	else
	{
		// Avoid div by zero
		if ( buildend == buildstart )
		{
			frac = 1.0f;
		}
		else
		{
			frac = ( build_amount - buildstart ) / ( buildend - buildstart );
			frac = clamp( frac, 0.0f, 1.0f );
		}
	}

	if ( !pObject->IsBuilding() )
	{
		frac = 1.0f;
	}

	m_pAlphaVar->SetFloatValue( frac );
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:45,代码来源:ObjectBuildAlphaProxy.cpp

示例10: GetBuildingIDFromSlot

void CHudMenuEngyBuild::OnTick( void )
{
	C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();

	if ( !pLocalPlayer )
		return;

	int iAccount = pLocalPlayer->GetAmmoCount( TF_AMMO_METAL );

	for ( int i=0;i<4; i++ )
	{
		int iRemappedObjectID = GetBuildingIDFromSlot( i + 1 );

		// update this slot
		C_BaseObject *pObj = NULL;

		if ( pLocalPlayer )
		{
			pObj = pLocalPlayer->GetObjectOfType( iRemappedObjectID );
		}			

		m_pAvailableObjects[i]->SetVisible( false );
		m_pAlreadyBuiltObjects[i]->SetVisible( false );
		m_pCantAffordObjects[i]->SetVisible( false );

		// If the building is already built
		if ( pObj != NULL && !pObj->IsPlacing() )
		{
			m_pAlreadyBuiltObjects[i]->SetVisible( true );
		}
		// See if we can afford it
		else if ( iAccount < GetObjectInfo( iRemappedObjectID )->m_Cost )
		{
			m_pCantAffordObjects[i]->SetVisible( true );
		}
		else
		{
			// we can buy it
			m_pAvailableObjects[i]->SetVisible( true );
		}
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:42,代码来源:tf_hud_menu_engy_build.cpp

示例11: HintEventFn_BuildObject

void HintEventFn_BuildObject( CHintData *pData, C_HintEvent_Base *pEvent )
{
	if ( pEvent->GetType() == HINTEVENT_OBJECT_BUILT_BY_LOCAL_PLAYER )
	{
		C_BaseObject *pObj = ((C_HintEvent_ObjectBuiltByLocalPlayer*)pEvent)->m_pObject;
		
		if ( pObj->GetType() == pData->m_ObjectType )
		{
			// Ok, they just built the object that any hints of this type are referring to, so disable 
			// all further hints of this type.
			KeyValues *pkvStats = GetHintDisplayStats();
			if ( pkvStats )
			{
				KeyValues *pkvStatSection = pkvStats->FindKey( pData->name, true );
				if ( pkvStatSection )
				{
					pkvStatSection->SetString( "times_shown", VarArgs( "%i", 100 ) );
				}
			}
		}
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:22,代码来源:c_hint_events.cpp

示例12: SetVisible

void CBuildingStatusItem_Sapper::PerformLayout( void )
{
	BaseClass::PerformLayout();

	// We only tick while active and with a valid built object
	C_ObjectSapper *pSapper = static_cast<C_ObjectSapper*>(GetRepresentativeObject());

	// only visible 
	SetVisible( pSapper != NULL );

	if ( !IsActive() || !pSapper )
	{
		return;
	}

	C_BaseObject *pTarget = pSapper->GetParentObject();

	if ( pTarget )
	{
		float flHealth = (float)pTarget->GetHealth() / (float)pTarget->GetMaxHealth();

		m_pTargetHealthBar->SetProgress( flHealth );

		int iTargetType = pTarget->GetType();

		if ( m_iTargetType != iTargetType )
		{
			m_pTargetIcon->SetIcon( pTarget->GetHudStatusIcon() );

			m_iTargetType = iTargetType;
		}
	}
	else
	{
		m_pTargetHealthBar->SetProgress( 0.0f );
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:37,代码来源:tf_hud_building_status.cpp

示例13: _snwprintf

//-----------------------------------------------------------------------------
// Purpose: Status string for hud
//-----------------------------------------------------------------------------
void C_ObjectSapper::GetStatusText( wchar_t *pStatus, int iMaxStatusLen )
{
	float flHealthPercent = (float)GetHealth() / (float)GetMaxHealth();
	wchar_t wszHealthPercent[32];
	_snwprintf(wszHealthPercent, sizeof(wszHealthPercent)/sizeof(wchar_t) - 1, L"%d%%", (int)( flHealthPercent * 100 ) );

	wchar_t *pszTemplate;

	if ( IsBuilding() )
	{
		pszTemplate = g_pVGuiLocalize->Find( "#TF_ObjStatus_Sapper_Building" );
	}
	else
	{
		pszTemplate = g_pVGuiLocalize->Find( "#TF_ObjStatus_Sapper" );
	}

	if ( pszTemplate )
	{
		wchar_t wszTargetHealthPercent[32];
		wszTargetHealthPercent[0] = '\0';

		C_BaseObject *pParent = GetParentObject();
		Assert( pParent );
		if ( pParent )
		{
			float flTargetHealthPercent = (float)pParent->GetHealth() / (float)pParent->GetMaxHealth();
			_snwprintf(wszTargetHealthPercent, sizeof(wszTargetHealthPercent)/sizeof(wchar_t) - 1, L"%d%%", (int)( flTargetHealthPercent * 100 ) );
		}

		g_pVGuiLocalize->ConstructString( pStatus, iMaxStatusLen, pszTemplate,
			2,
			wszHealthPercent,
			wszTargetHealthPercent);
	}
}
开发者ID:TenmaPL,项目名称:TF2Classic,代码行数:39,代码来源:c_obj_sapper.cpp

示例14: if


//.........这里部分代码省略.........
				//If this was just a regular kill but this guy is our nemesis then just show it.
				if ( pVictim && pTFKiller && pTFKiller->m_Shared.IsPlayerDominated( pVictim->entindex() ) )
				{
					if ( !pKiller->IsAlive() )
					{
						m_pFreezeLabel->SetText( "#FreezePanel_Nemesis_Dead" );
					}
					else
					{
						m_pFreezeLabel->SetText( "#FreezePanel_Nemesis" );
					}
				}
				else
				{
					if ( !pKiller->IsAlive() )
					{
						m_pFreezeLabel->SetText( "#FreezePanel_Killer_Dead" );
					}
					else
					{
						m_pFreezeLabel->SetText( "#FreezePanel_Killer" );
					}
				}

				m_pBasePanel->SetDialogVariable( "killername", g_PR->GetPlayerName( m_iKillerIndex ) );

				if ( m_pAvatar )
				{
					m_pAvatar->SetPlayer( (C_BasePlayer*)pKiller );
				}
			}
			else if ( pKiller->IsBaseObject() )
			{
				C_BaseObject *pObj = assert_cast<C_BaseObject *>( pKiller );
				C_TFPlayer *pOwner = pObj->GetOwner();

				Assert( pOwner && "Why does this object not have an owner?" );

				if ( pOwner )
				{
					m_iKillerIndex = pOwner->entindex();

					m_pBasePanel->SetDialogVariable( "killername", g_PR->GetPlayerName( m_iKillerIndex ) );

					if ( m_pAvatar )
					{
						m_pAvatar->SetPlayer( pOwner );
					}

					pKiller = pOwner;
				}

				if ( m_pFreezeLabel )
				{
					if ( pKiller && !pKiller->IsAlive() )
					{
						m_pFreezeLabel->SetText( "#FreezePanel_KillerObject_Dead" );
					}
					else
					{
						m_pFreezeLabel->SetText( "#FreezePanel_KillerObject" );
					}
				}
				const char *pszStatusName = pObj->GetStatusName();
				wchar_t *wszLocalized = g_pVGuiLocalize->Find( pszStatusName );
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:66,代码来源:tf_hud_freezepanel.cpp

示例15: HighlightBuildPoints

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_BaseObject::HighlightBuildPoints( int flags )
{
	C_TFPlayer *pLocal = C_TFPlayer::GetLocalTFPlayer();
	if ( !pLocal )
		return;

	if ( !GetNumBuildPoints() || !InLocalTeam() )
		return;

	C_TFWeaponBuilder *pBuilderWpn = dynamic_cast< C_TFWeaponBuilder * >( pLocal->GetActiveWeaponForSelection() );
	if ( !pBuilderWpn )
		return;
	if ( !pBuilderWpn->IsPlacingObject() )
		return;
	C_BaseObject *pPlacementObj = pBuilderWpn->GetPlacementModel();
	if ( !pPlacementObj || pPlacementObj == this )
		return;

	// Near enough?
	if ( (GetAbsOrigin() - pLocal->GetAbsOrigin()).LengthSqr() < MAX_VISIBLE_BUILDPOINT_DISTANCE )
	{
		bool bRestoreModel = false;
		Vector vecPrevAbsOrigin = pPlacementObj->GetAbsOrigin();
		QAngle vecPrevAbsAngles = pPlacementObj->GetAbsAngles();

		Vector orgColor;
		render->GetColorModulation( orgColor.Base() );
		float orgBlend = render->GetBlend();

		bool bSameTeam = ( pPlacementObj->GetTeamNumber() == GetTeamNumber() );

		if ( pPlacementObj->IsHostileUpgrade() && bSameTeam )
		{
			// Don't hilight hostile upgrades on friendly objects
			return;
		}
		else if ( !bSameTeam )
		{
			// Don't hilight upgrades on enemy objects
			return;
		}

		// Any empty buildpoints?
		for ( int i = 0; i < GetNumBuildPoints(); i++ )
		{
			// Can this object build on this point?
			if ( CanBuildObjectOnBuildPoint( i, pPlacementObj->GetType() ) )
			{
				Vector vecBPOrigin;
				QAngle vecBPAngles;
				if ( GetBuildPoint(i, vecBPOrigin, vecBPAngles) )
				{
					pPlacementObj->InvalidateBoneCaches();

					Vector color( 0, 255, 0 );
					render->SetColorModulation(	color.Base() );
					float frac = fmod( gpGlobals->curtime, 3 );
					frac *= 2 * M_PI;
					frac = cos( frac );
					render->SetBlend( (175 + (int)( frac * 75.0f )) / 255.0 );

					// FIXME: This truly sucks! The bone cache should use
					// render location for this computation instead of directly accessing AbsAngles
					// Necessary for bone cache computations to work
					pPlacementObj->SetAbsOrigin( vecBPOrigin );
					pPlacementObj->SetAbsAngles( vecBPAngles );

					modelrender->DrawModel( 
						flags, 
						pPlacementObj,
						pPlacementObj->GetModelInstance(),
						pPlacementObj->index, 
						pPlacementObj->GetModel(),
						vecBPOrigin,
						vecBPAngles,
						pPlacementObj->m_nSkin,
						pPlacementObj->m_nBody,
						pPlacementObj->m_nHitboxSet
						);

					bRestoreModel = true;
				}
			}
		}

		if ( bRestoreModel )
		{
			pPlacementObj->SetAbsOrigin(vecPrevAbsOrigin);
			pPlacementObj->SetAbsAngles(vecPrevAbsAngles);
			pPlacementObj->InvalidateBoneCaches();

			render->SetColorModulation( orgColor.Base() );
			render->SetBlend( orgBlend );
		}
	}
}
开发者ID:Deathreus,项目名称:TF2Classic,代码行数:99,代码来源:c_baseobject.cpp


注:本文中的C_BaseObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。