本文整理汇总了C++中CGameRules::ClientSimpleHit方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameRules::ClientSimpleHit方法的具体用法?C++ CGameRules::ClientSimpleHit怎么用?C++ CGameRules::ClientSimpleHit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameRules
的用法示例。
在下文中一共展示了CGameRules::ClientSimpleHit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleEvent
void CTacBullet::HandleEvent(const SGameObjectEvent &event)
{
if (m_destroying)
return;
CProjectile::HandleEvent(event);
if (event.event == eGFE_OnCollision)
{
EventPhysCollision *pCollision = reinterpret_cast<EventPhysCollision *>(event.ptr);
if (!pCollision)
return;
IEntity *pTarget = pCollision->iForeignData[1]==PHYS_FOREIGN_ID_ENTITY ? (IEntity*)pCollision->pForeignData[1]:0;
if (pTarget)
{
CGameRules *pGameRules = g_pGame->GetGameRules();
EntityId targetId = pTarget->GetId();
CActor *pActor = (CActor *)gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(targetId);
if(pActor && pActor->CanSleep())
{
if(pActor->GetLinkedVehicle() && !gEnv->bMultiplayer)
{
SleepTargetInVehicle(m_ownerId,pActor);
}
else if(IEntity* pOwnerEntity = gEnv->pEntitySystem->GetEntity(m_ownerId))
{
if (pTarget->GetAI() && !pTarget->GetAI()->IsFriendly(pOwnerEntity->GetAI(), false))
{
float sleepTime = 30.0f;
if(m_pAmmoParams)
sleepTime = m_pAmmoParams->sleepTime;
SimpleHitInfo info(m_ownerId, targetId, m_weaponId, 1, sleepTime); // 0=tag,1=tac
info.remote=IsRemote();
pGameRules->ClientSimpleHit(info);
}
}
}
else
{
Vec3 dir(0, 0, 0);
if (pCollision->vloc[0].GetLengthSquared() > 1e-6f)
dir = pCollision->vloc[0].GetNormalized();
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);
}
}
else if (pCollision->pEntity[0]->GetType() == PE_PARTICLE)
{
float bouncy, friction;
uint32 pierceabilityMat;
gEnv->pPhysicalWorld->GetSurfaceParameters(pCollision->idmat[1], bouncy, friction, pierceabilityMat);
pierceabilityMat&=sf_pierceable_mask;
pe_params_particle params;
if(pCollision->pEntity[0]->GetParams(¶ms)==0)
SetDefaultParticleParams(¶ms);
if (pierceabilityMat>params.iPierceability && pCollision->idCollider!=-1)
return;
}
Destroy();
}
}