本文整理汇总了C++中CGameRules::SetEntityToIgnore方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameRules::SetEntityToIgnore方法的具体用法?C++ CGameRules::SetEntityToIgnore怎么用?C++ CGameRules::SetEntityToIgnore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameRules
的用法示例。
在下文中一共展示了CGameRules::SetEntityToIgnore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleEvent
//------------------------------------------------------------------------
void CBullet::HandleEvent(const SGameObjectEvent &event)
{
FUNCTION_PROFILER(GetISystem(), PROFILE_GAME);
CProjectile::HandleEvent(event);
if (event.event == eGFE_OnCollision)
{
if (m_destroying)
return;
EventPhysCollision *pCollision = reinterpret_cast<EventPhysCollision *>(event.ptr);
if (!pCollision)
return;
IEntity *pTarget = pCollision->iForeignData[1]==PHYS_FOREIGN_ID_ENTITY ? (IEntity*)pCollision->pForeignData[1]:0;
//Only process hits that have a target
if(pTarget)
{
Vec3 dir(0, 0, 0);
if (pCollision->vloc[0].GetLengthSquared() > 1e-6f)
dir = pCollision->vloc[0].GetNormalized();
CGameRules *pGameRules = g_pGame->GetGameRules();
IActor* pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_ownerId);
bool ok = true;
if(!gEnv->bMultiplayer && pActor && pActor->IsPlayer())
{
IActor* pAITarget = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pTarget->GetId());
if(pAITarget && pTarget->GetAI() && pTarget->GetAI()->IsFriendly(pActor->GetEntity()->GetAI(), false))
{
pGameRules->SetEntityToIgnore(pTarget->GetId());
ok = false;
}
}
if(ok)
{
HitInfo hitInfo(m_ownerId, pTarget->GetId(), m_weaponId,
(float)m_damage, 0.0f, pGameRules->GetHitMaterialIdFromSurfaceId(pCollision->idmat[1]), pCollision->partid[1],
m_hitTypeId, pCollision->pt, dir, pCollision->n);
hitInfo.remote = IsRemote();
hitInfo.projectileId = GetEntityId();
hitInfo.bulletType = m_pAmmoParams->bulletType;
pGameRules->ClientHit(hitInfo);
// Notify AI
if (gEnv->pAISystem && !gEnv->bMultiplayer)
{
static int htMelee = pGameRules->GetHitTypeId("melee");
if (m_ownerId && m_hitTypeId != htMelee)
{
ISurfaceType *pSurfaceType = pGameRules->GetHitMaterial(hitInfo.material);
const ISurfaceType::SSurfaceTypeAIParams* pParams = pSurfaceType ? pSurfaceType->GetAIParams() : 0;
const float radius = pParams ? pParams->fImpactRadius : 2.5f;
const float soundRadius = pParams ? pParams->fImpactSoundRadius : 20.0f;
// Associate event with vehicle if the shooter is in a vehicle (tank cannon shot, etc)
EntityId ownerId = m_ownerId;
if (pActor && pActor->GetLinkedVehicle() && pActor->GetLinkedVehicle()->GetEntityId())
ownerId = pActor->GetLinkedVehicle()->GetEntityId();
SAIStimulus stim(AISTIM_BULLET_HIT, 0, ownerId, 0, pCollision->pt, ZERO, radius);
gEnv->pAISystem->RegisterStimulus(stim);
SAIStimulus stimSound(AISTIM_SOUND, AISOUND_COLLISION_LOUD, ownerId, 0, pCollision->pt, ZERO, soundRadius, AISTIMPROC_FILTER_LINK_WITH_PREVIOUS);
gEnv->pAISystem->RegisterStimulus(stimSound);
}
}
}
}
else
{
// Notify AI
// The above case only catches entity vs. entity hits, the AI is interested in all hits.
if (gEnv->pAISystem && !gEnv->bMultiplayer)
{
CGameRules *pGameRules = g_pGame->GetGameRules();
static int htMelee = pGameRules->GetHitTypeId("melee");
if (m_ownerId && m_hitTypeId != htMelee)
{
int material = pGameRules->GetHitMaterialIdFromSurfaceId(pCollision->idmat[1]);
ISurfaceType *pSurfaceType = pGameRules->GetHitMaterial(material);
const ISurfaceType::SSurfaceTypeAIParams* pParams = pSurfaceType ? pSurfaceType->GetAIParams() : 0;
const float radius = pParams ? pParams->fImpactRadius : 2.5f;
const float soundRadius = pParams ? pParams->fImpactSoundRadius : 20.0f;
// Associate event with vehicle if the shooter is in a vehicle (tank cannon shot, etc)
EntityId ownerId = m_ownerId;
IActor* pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_ownerId);
if (pActor && pActor->GetLinkedVehicle() && pActor->GetLinkedVehicle()->GetEntityId())
//.........这里部分代码省略.........