本文整理汇总了C++中CGrenade::Useful方法的典型用法代码示例。如果您正苦于以下问题:C++ CGrenade::Useful方法的具体用法?C++ CGrenade::Useful怎么用?C++ CGrenade::Useful使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGrenade
的用法示例。
在下文中一共展示了CGrenade::Useful方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Feel_Grenade_Update
void CActor::Feel_Grenade_Update( float rad )
{
if ( !IsGameTypeSingle() )
{
return;
}
// Find all nearest objects
Fvector pos_actor;
Center( pos_actor );
q_nearest.clear_not_free();
g_pGameLevel->ObjectSpace.GetNearest( q_nearest, pos_actor, rad, NULL );
xr_vector<CObject*>::iterator it_b = q_nearest.begin();
xr_vector<CObject*>::iterator it_e = q_nearest.end();
// select only grenade
for ( ; it_b != it_e; ++it_b )
{
if ( (*it_b)->getDestroy() ) continue; // Don't touch candidates for destroy
CGrenade* grn = smart_cast<CGrenade*>( *it_b );
if( !grn || grn->Initiator() == ID() || grn->Useful() )
{
continue;
}
if ( grn->time_from_begin_throw() < m_fFeelGrenadeTime )
{
continue;
}
if ( HUD().AddGrenade_ForMark( grn ) )
{
//. Msg("__ __ Add new grenade! id = %d ", grn->ID() );
}
}// for it
HUD().Update_GrenadeView( pos_actor );
}
示例2:
void CActor::PickupModeUpdate_COD ()
{
if (Level().CurrentViewEntity() != this || !g_b_COD_PickUpMode) return;
if (!g_Alive() || eacFirstEye != cam_active)
{
CurrentGameUI()->UIMainIngameWnd->SetPickUpItem(NULL);
return;
};
CFrustum frustum;
frustum.CreateFromMatrix (Device.mFullTransform, FRUSTUM_P_LRTB|FRUSTUM_P_FAR);
ISpatialResult.clear_not_free ();
g_SpatialSpace->q_frustum (ISpatialResult, 0, STYPE_COLLIDEABLE, frustum);
float maxlen = 1000.0f;
CInventoryItem* pNearestItem = NULL;
for (u32 o_it=0; o_it<ISpatialResult.size(); o_it++)
{
ISpatial* spatial = ISpatialResult[o_it];
CInventoryItem* pIItem = smart_cast<CInventoryItem*> (spatial->dcast_CObject ());
if (0 == pIItem) continue;
if (pIItem->object().H_Parent() != NULL) continue;
if (!pIItem->CanTake()) continue;
if ( smart_cast<CExplosiveRocket*>( &pIItem->object() ) ) continue;
CGrenade* pGrenade = smart_cast<CGrenade*> (spatial->dcast_CObject ());
if (pGrenade && !pGrenade->Useful()) continue;
CMissile* pMissile = smart_cast<CMissile*> (spatial->dcast_CObject ());
if (pMissile && !pMissile->Useful()) continue;
Fvector A, B, tmp;
pIItem->object().Center (A);
if (A.distance_to_sqr(Position())>4) continue;
tmp.sub(A, cam_Active()->vPosition);
B.mad(cam_Active()->vPosition, cam_Active()->vDirection, tmp.dotproduct(cam_Active()->vDirection));
float len = B.distance_to_sqr(A);
if (len > 1) continue;
if (maxlen>len && !pIItem->object().getDestroy())
{
maxlen = len;
pNearestItem = pIItem;
};
}
if(pNearestItem)
{
CFrustum frustum;
frustum.CreateFromMatrix (Device.mFullTransform,FRUSTUM_P_LRTB|FRUSTUM_P_FAR);
if (!CanPickItem(frustum, Device.vCameraPosition, &pNearestItem->object()))
pNearestItem = NULL;
}
if (pNearestItem && pNearestItem->cast_game_object())
{
if (Level().m_feel_deny.is_object_denied(pNearestItem->cast_game_object()))
pNearestItem = NULL;
}
if (pNearestItem && pNearestItem->cast_game_object())
{
if(!pNearestItem->cast_game_object()->getVisible())
pNearestItem = NULL;
}
CurrentGameUI()->UIMainIngameWnd->SetPickUpItem(pNearestItem);
if (pNearestItem && m_bPickupMode)
{
CUsableScriptObject* pUsableObject = smart_cast<CUsableScriptObject*>(pNearestItem);
if(pUsableObject && (!m_pUsableObject))
pUsableObject->use(this);
//подбирание объекта
Game().SendPickUpEvent(ID(), pNearestItem->object().ID());
}
};