本文整理汇总了C++中CActor::GetImpulseHander方法的典型用法代码示例。如果您正苦于以下问题:C++ CActor::GetImpulseHander方法的具体用法?C++ CActor::GetImpulseHander怎么用?C++ CActor::GetImpulseHander使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActor
的用法示例。
在下文中一共展示了CActor::GetImpulseHander方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Impulse
void CMelee::Impulse(const Vec3 &pt, const Vec3 &dir, const Vec3 &normal, IPhysicalEntity *pCollider, EntityId collidedEntityId, int partId, int ipart, int surfaceIdx, int hitTypeID, int iPrim)
{
if (pCollider && m_pMeleeParams->meleeparams.impulse>0.001f)
{
CActor* pOwnerActor = m_pWeapon->GetOwnerActor();
const SPlayerMelee& meleeCVars = g_pGameCVars->pl_melee;
const SMeleeParams& meleeParams = m_pMeleeParams->meleeparams;
float impulse = meleeParams.impulse;
bool aiShooter = pOwnerActor ? !pOwnerActor->IsPlayer() : true;
bool delayImpulse = false;
float impulseScale = 1.0f;
//[kirill] add impulse to phys proxy - to make sure it's applied to cylinder as well (not only skeleton) - so that entity gets pushed
// if no pEntity - do it old way
IEntity * pEntity = gEnv->pEntitySystem->GetEntity(collidedEntityId);
IGameFramework* pGameFramework = g_pGame->GetIGameFramework();
CActor* pTargetActor = static_cast<CActor*>(pGameFramework->GetIActorSystem()->GetActor(collidedEntityId));
if (pEntity && pTargetActor)
{
//If it's an entity, use the specific impulses if needed, and apply to physics proxy
if ( meleeCVars.impulses_enable != SPlayerMelee::ei_Disabled )
{
impulse = meleeParams.impulse_actor;
bool aiTarget = !pTargetActor->IsPlayer();
if (aiShooter && !aiTarget)
{
float impulse_ai_to_player = GetImpulseAiToPlayer();
if (impulse_ai_to_player != -1.f)
{
impulse = impulse_ai_to_player;
}
}
//Delay a bit on death actors, when switching from alive to death, impulses don't apply
//I schedule an impulse here, to get rid off the ugly .lua code which was calculating impulses on its own
if (pTargetActor->IsDead())
{
if (meleeCVars.impulses_enable != SPlayerMelee::ei_OnlyToAlive)
{
delayImpulse = true;
const float actorCustomScale = 1.0f;
impulseScale *= actorCustomScale;
}
else
{
impulse = 0.0f;
}
}
else if (meleeCVars.impulses_enable == SPlayerMelee::ei_OnlyToDead)
{
// Always allow impulses for melee from AI to local player
// [*DavidR | 27/Oct/2010] Not sure about this
if (!(aiShooter && !aiTarget))
impulse = 0.0f;
}
}
else if (pGameFramework->GetIVehicleSystem()->GetVehicle(collidedEntityId))
{
impulse = m_pMeleeParams->meleeparams.impulse_vehicle;
impulseScale = 1.0f;
}
}
const float fScaledImpulse = impulse * impulseScale;
if (fScaledImpulse > 0.0f)
{
if (!delayImpulse)
{
m_collisionHelper.Impulse(pCollider, pt, dir * fScaledImpulse, partId, ipart, hitTypeID);
}
else
{
//Force up impulse, to make the enemy fly a bit
Vec3 newDir = (dir.z < 0.0f) ? Vec3(dir.x, dir.y, 0.1f) : dir;
newDir.Normalize();
newDir.x *= fScaledImpulse;
newDir.y *= fScaledImpulse;
newDir.z *= impulse;
if( pTargetActor )
{
pe_action_impulse imp;
imp.iApplyTime = 0;
imp.impulse = newDir;
//imp.ipart = ipart;
imp.partid = partId;
imp.point = pt;
pTargetActor->GetImpulseHander()->SetOnRagdollPhysicalizedImpulse( imp );
}
else
{
m_pWeapon->GetScheduler()->TimerAction(100, CSchedulerAction<DelayedImpulse>::Create(DelayedImpulse(*this, collidedEntityId, pt, newDir, partId, ipart, hitTypeID)), true);
}
}
}
//.........这里部分代码省略.........