本文整理汇总了C++中C_BaseObject::IsBuilding方法的典型用法代码示例。如果您正苦于以下问题:C++ C_BaseObject::IsBuilding方法的具体用法?C++ C_BaseObject::IsBuilding怎么用?C++ C_BaseObject::IsBuilding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C_BaseObject
的用法示例。
在下文中一共展示了C_BaseObject::IsBuilding方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: 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 );
}
}
}
示例3: OnTick
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CBuildingStatusItem::OnTick()
{
// We only tick while active and with a valid built object
C_BaseObject *pObj = GetRepresentativeObject();
if ( !pObj ) // implies not active
{
if ( m_bActive )
{
// we lost our object. force relayout to inactive mode
InvalidateLayout();
// tell our parent that we're gone
IGameEvent *event = gameeventmanager->CreateEvent( "building_info_changed" );
if ( event )
{
event->SetInt( "building_type", GetRepresentativeObjectType() );
gameeventmanager->FireEventClientSide( event );
}
}
// We don't want to tick while inactive regardless
return;
}
float flHealth = (float)pObj->GetHealth() / (float)pObj->GetMaxHealth();
m_pHealthBar->SetProgress( flHealth );
if ( pObj->IsBuilding() )
{
m_pBuildingPanel->SetVisible( true );
m_pRunningPanel->SetVisible( false );
m_pBuildingProgress->SetProgress( pObj->GetPercentageConstructed() );
}
else
{
m_pBuildingPanel->SetVisible( false );
m_pRunningPanel->SetVisible( true );
}
// what is our current alert state?
BuildingHudAlert_t alertLevel = pObj->GetBuildingAlertLevel();
if ( alertLevel <= BUILDING_HUD_ALERT_NONE )
{
// if the tray is out, hide it
if ( m_pAlertTray->IsTrayOut() )
{
m_pAlertTray->HideTray();
m_pWrenchIcon->SetVisible( false );
m_pSapperIcon->SetVisible( false );
}
}
else
{
if ( !m_pAlertTray->IsTrayOut() )
{
m_pAlertTray->ShowTray();
}
m_pAlertTray->SetAlertType( alertLevel );
m_pWrenchIcon->SetVisible( false );
m_pSapperIcon->SetVisible( false );
if ( m_pAlertTray->GetAlertType() != BUILDING_HUD_ALERT_NONE &&
m_pAlertTray->GetPercentDeployed() >= 1.0f )
{
switch( m_pAlertTray->GetAlertType() )
{
case BUILDING_HUD_ALERT_LOW_AMMO:
case BUILDING_HUD_ALERT_LOW_HEALTH:
case BUILDING_HUD_ALERT_VERY_LOW_AMMO:
case BUILDING_HUD_ALERT_VERY_LOW_HEALTH:
m_pWrenchIcon->SetVisible( true );
break;
case BUILDING_HUD_ALERT_SAPPER:
m_pSapperIcon->SetVisible( true );
break;
case BUILDING_HUD_ALERT_NONE:
default:
break;
}
}
}
}