本文整理汇总了C++中IWeapon::StopFire方法的典型用法代码示例。如果您正苦于以下问题:C++ IWeapon::StopFire方法的具体用法?C++ IWeapon::StopFire怎么用?C++ IWeapon::StopFire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWeapon
的用法示例。
在下文中一共展示了IWeapon::StopFire方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessEvent
void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
IWeapon* pWeapon = GetWeapon(pActInfo);
if (!pWeapon)
return;
switch (event)
{
case eFE_Initialize:
{
m_isFiring = false;
m_numShots = GetPortInt( pActInfo, IN_NUMBEROFSHOTS );
m_actInfo = *pActInfo;
m_numShotsDone = 0;
pWeapon->StopFire();
if (pActInfo->pEntity->GetId() != m_weapId)
RemoveListener(m_weapId, this);
m_weapId = pActInfo->pEntity->GetId();
pWeapon->AddEventListener(this, __FUNCTION__);
#ifdef DEBUG_NODEFIREWEAPON
pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
#endif
break;
}
case eFE_Activate:
{
m_actInfo = *pActInfo;
if (IsPortActive(pActInfo, IN_NUMBEROFSHOTS))
m_numShots = GetPortBool( pActInfo, IN_NUMBEROFSHOTS );
if (IsPortActive(pActInfo, IN_STOPFIRE))
{
StopFiring( pActInfo, pWeapon );
}
if (IsPortActive(pActInfo, IN_STARTFIRE))
{
m_numShotsDone = 0;
ReplenishAmmo( pWeapon );
pWeapon->StopFire();
StartFiring( pActInfo, pWeapon );
}
break;
}
case eFE_Update:
{
// this fixes the problem when the entity is being externally moved/rotated, in the interval of time between when the weapon is aimed an the actual shot happens
if (m_isFiring && GetPortBool( pActInfo, IN_ALIGNTOTARGET ))
if (pActInfo->pEntity->GetWorldPos()!=m_lastPos || pActInfo->pEntity->GetWorldRotation()!=m_lastRotation)
CalcFiringPosition( pActInfo, pWeapon );
#ifdef DEBUG_NODEFIREWEAPON
ColorB colorRed( 255,0,0 );
ColorB colorGreen( 0,255,0 );
gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine( posOrig, colorRed, posTarget, colorRed );
gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine( posTarget, colorGreen, posShot, colorGreen );
#endif
break;
}
}
}
示例2: StartOnTarget
//-----------------------------------------------------------------------
bool CSpectacularKill::StartOnTarget(CActor* pTargetActor)
{
FUNCTION_PROFILER(gEnv->pSystem, PROFILE_GAME);
CRY_ASSERT(pTargetActor);
CRY_ASSERT_MESSAGE(!IsBusy(), "spectacular kill should not be initiated while a spectacular kill is already in progress");
SSpectacularKillAnimation anim;
if (!IsBusy() && pTargetActor && GetValidAnim(pTargetActor, anim) && CanExecuteOnTarget(pTargetActor, anim))
{
// Disable AI
if (!pTargetActor->IsPlayer() && pTargetActor->GetEntity()->GetAI())
pTargetActor->GetEntity()->GetAI()->Event(AIEVENT_DISABLE, 0);
if (!m_pOwner->IsPlayer() && m_pOwner->GetEntity()->GetAI())
m_pOwner->GetEntity()->GetAI()->Event(AIEVENT_DISABLE, 0);
// make sure they aren't firing when the anim starts
{
IItem* pItem = pTargetActor->GetCurrentItem();
IWeapon* pWeapon = pItem ? pItem->GetIWeapon() : NULL;
if (pWeapon)
pWeapon->StopFire();
}
{
IItem* pItem = m_pOwner->GetCurrentItem();
IWeapon* pWeapon = pItem ? pItem->GetIWeapon() : NULL;
if (pWeapon)
pWeapon->StopFire();
}
SActorStats* pStats = m_pOwner->GetActorStats();
if(pStats)
{
pStats->spectacularKillPartner = pTargetActor->GetEntityId();
}
SActorStats* pTargetStats = pTargetActor->GetActorStats();
if(pTargetStats)
{
pTargetStats->spectacularKillPartner = m_pOwner->GetEntityId();
}
const float slideTime = 0.2f;
const char* pKillerAnim = anim.killerAnimation.c_str();
const char* pVictimAnim = anim.victimAnimation.c_str();
SCharacterParams killerParams(m_pOwner->GetAnimatedCharacter(), pKillerAnim, /*allowHPhysics*/false, slideTime);
SCharacterParams targetParams(pTargetActor->GetAnimatedCharacter(), pVictimAnim, /*allowHPhysics*/false, slideTime);
SCooperativeAnimParams animParams(/*forceStart*/true, /*looping*/ false, /*alignment*/ /*eAF_FirstActorNoRot*/eAF_FirstActor);
animParams.bIgnoreCharacterDeath = true;
animParams.bPreventFallingThroughTerrain = false;
animParams.bNoCollisionsBetweenFirstActorAndRest = true;
ICooperativeAnimationManager* pCooperativeAnimationManager = gEnv->pGame->GetIGameFramework()->GetICooperativeAnimationManager();
bool bStarted = pCooperativeAnimationManager->StartNewCooperativeAnimation(killerParams, targetParams, animParams);
if (bStarted)
{
m_targetId = pTargetActor->GetEntityId();
m_isBusy = true;
// Register the killing
s_lastKillInfo.killerAnim = pKillerAnim;
s_lastKillInfo.timeStamp = gEnv->pTimer->GetFrameStartTime().GetSeconds();
#ifndef _RELEASE
// Clean persistant debug information
IPersistantDebug* pPersistantDebug = BeginPersistantDebug();
// Send telemetry event
CStatsRecordingMgr* pRecordingMgr = g_pGame->GetStatsRecorder();
IStatsTracker* pTracker = pRecordingMgr ? pRecordingMgr->GetStatsTracker(m_pOwner) : NULL;
if (pTracker)
{
EGameStatisticEvent eventType = eGSE_SpectacularKill;
if(pRecordingMgr->ShouldRecordEvent(eventType, m_pOwner))
{
pTracker->Event(eventType, (anim.killerAnimation + " -> " + anim.victimAnimation).c_str());
}
}
#endif
return true;
}
}
return false;
}