本文整理汇总了C++中IAIObject::IsFriendly方法的典型用法代码示例。如果您正苦于以下问题:C++ IAIObject::IsFriendly方法的具体用法?C++ IAIObject::IsFriendly怎么用?C++ IAIObject::IsFriendly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAIObject
的用法示例。
在下文中一共展示了IAIObject::IsFriendly方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckForFriendlyAI
//---------------------------------------------------------------------------
void CVehicleWeapon::CheckForFriendlyAI(float frameTime)
{
if (m_pVehicle)
{
if (CActor* pOwnerActor = GetOwnerActor())
{
if (pOwnerActor->IsPlayer() && !gEnv->bMultiplayer)
{
m_timeToUpdate -= frameTime;
if (m_timeToUpdate > 0.f)
return;
m_timeToUpdate = 0.15f;
if (IMovementController* pMC = pOwnerActor->GetMovementController())
{
SMovementState info;
pMC->GetMovementState(info);
LowerWeapon(false);
// Try ray hit
ray_hit rayhit;
IPhysicalEntity* pSkipEnts[10];
int nSkip = CSingle::GetSkipEntities(this, pSkipEnts, 10);
int intersect = gEnv->pPhysicalWorld->RayWorldIntersection(info.weaponPosition, info.aimDirection * 150.f, ent_all,
rwi_stop_at_pierceable | rwi_colltype_any, &rayhit, 1, pSkipEnts, nSkip);
if (intersect && rayhit.pCollider)
{
if (IEntity* pLookAtEntity = m_pEntitySystem->GetEntityFromPhysics(rayhit.pCollider))
{
if (EntityId lookAtEntityId = pLookAtEntity->GetId())
{
IAIObject* pLookAtAIObject = pLookAtEntity->GetAI();
IEntity* pOwnerEntity = pOwnerActor->GetEntity();
if (pOwnerEntity && pLookAtAIObject && (lookAtEntityId != GetEntityId()))
{
if (IVehicle* pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(lookAtEntityId))
{
if (pVehicle->HasFriendlyPassenger(pOwnerEntity))
{
LowerWeapon(true);
StopFire(); // Just in case
}
}
else
{
if (pLookAtAIObject->IsFriendly(pOwnerEntity->GetAI(), false))
{
LowerWeapon(true);
StopFire(); // Just in case
}
}
}
else
{
// Special case (Animated objects), check for script table value "bNoFriendlyFire"
if (IScriptTable* pScriptTable = pLookAtEntity->GetScriptTable())
{
SmartScriptTable props;
if (pScriptTable->GetValue("Properties", props))
{
int isFriendly;
if (props->GetValue("bNoFriendlyFire", isFriendly) && (isFriendly != 0))
{
LowerWeapon(true);
StopFire(); // Just in case
}
}
}
}
}
}
}
}
}
}
}
}