virtual void OnFragmentStarted() { m_cachedMotionParameters = m_animChar.GetOverriddenMotionParameters(); FillMotionParameters(&m_cachedMotionParameters, *m_animChar.GetEntity(), m_pTransition->transitionType, m_future); m_animChar.SetOverriddenMotionParameters(m_cachedMotionParameters); m_animChar.SetMovementControlMethods(eMCM_AnimationHCollision, eMCM_Entity); // Request Detail { const EntityId rootEntityId = GetRootScope().GetEntityId(); CPlayer &player = *static_cast<CPlayer*>(g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(rootEntityId)); CAIAnimationComponent* pAIAnimationComponent = player.GetAIAnimationComponent(); CRY_ASSERT(pAIAnimationComponent); switch(m_pTransition->transitionType) { case eTT_Start: case eTT_DirectionChange: pAIAnimationComponent->RequestAIMovementDetail(CAnimActionAIDetail::Move); break; case eTT_Stop: pAIAnimationComponent->RequestAIMovementDetail(CAnimActionAIDetail::Idle); break; default: pAIAnimationComponent->RequestAIMovementDetail(CAnimActionAIDetail::None); break; } } }
void OnSequenceFinished(int layer, uint32 scopeID) { if( GetRootScope().GetID() == scopeID && layer == 0 && m_kicking && ((m_flags & IAction::BlendOut) == 0 ) ) { SetFragment( m_slideFragID, m_slideFragTags ); m_kicking = false; } }
void CActionItemIdle::OnSequenceFinished(int layer, uint32 scopeID) { if (GetRootScope().GetID() == scopeID && m_playingIdleBreak && (layer == 0)) { m_playingIdleBreak = false; m_lastIdleBreakTime = gEnv->pTimer->GetAsyncCurTime(); } }
IAction::EStatus CActorAnimationActionAimPose::Update(float timePassed) { CAnimationAction::Update(timePassed); // Update the fragments and tags if they are different. const IScope& rootScope = GetRootScope(); if (rootScope.IsDifferent(m_fragmentID, m_fragTags)) SetFragment(m_fragmentID, m_fragTags); return m_eStatus; }
EStatus Update(float timePassed) { if (IsTransitioningOut()) { const float ROTATION_LERP_SPEED = 10.0f; //--- Blend body rotation to match current view Ang3 targetViewDir = m_player.GetAngles(); Quat targetRotation = Quat::CreateRotationZ(targetViewDir.z); Quat newRotation = Quat::CreateNlerp(m_player.GetEntity()->GetRotation(), targetRotation, timePassed*ROTATION_LERP_SPEED); m_player.GetEntity()->SetRotation(newRotation); } else { static uint32 leanParamCRC = gEnv->pSystem->GetCrc32Gen()->GetCRC32Lowercase("SlideFactor"); const Matrix34 &worldTM = m_player.GetEntity()->GetWorldTM(); const Vec3 baseRgt = worldTM.GetColumn0(); const Vec3 baseFwd = worldTM.GetColumn1(); const Vec3 lookFwd = m_player.GetViewQuatFinal().GetColumn1(); const float leanAngle = cry_acosf(baseFwd.Dot(lookFwd)); float targetLeanFactor = clamp(leanAngle / MAX_LEAN_ANGLE, 0.0f, 1.0f); if (baseRgt.Dot(lookFwd) < 0.0f) { targetLeanFactor *= -1.0f; } CWeapon *pWeapon = m_player.GetWeapon(m_player.GetCurrentItemId()); if (pWeapon) { IFireMode *pFiremode = pWeapon->GetFireMode(pWeapon->GetCurrentFireMode()); if (pFiremode && (pFiremode->GetNextShotTime() > 0.0f)) { targetLeanFactor = 0.0f; } } const float delta = targetLeanFactor - m_leanFactor; const float step = LEAN_RATE * timePassed; const float newLeanFactor = (float)__fsel(delta, min(m_leanFactor + step, targetLeanFactor), max(m_leanFactor - step, targetLeanFactor)); SWeightData weightData; weightData.weights[0] = newLeanFactor; SetParam(leanParamCRC, weightData); m_leanFactor = newLeanFactor; if (GetRootScope().IsDifferent(m_fragmentID, m_fragTags)) { SetFragment(m_fragmentID, m_fragTags); } } return TPlayerAction::Update(timePassed); }
// ---------------------------------------------------------------------------- void CAnimActionTriState::OnSequenceFinished( int layer, uint32 scopeID ) { #ifndef _RELEASE CRY_ASSERT( m_entered ); #endif if ( layer != 0 || GetRootScope().GetID() != scopeID ) { return; } TransitionToNextSubState(); }
IAction::EStatus CAnimActionAILooking::Update( float timePassed ) { TBase::Update( timePassed ); const IScope& rootScope = GetRootScope(); const bool foundNewBestMatchingFragment = rootScope.IsDifferent( m_fragmentID, m_fragTags ); if ( foundNewBestMatchingFragment ) { SetFragment( m_fragmentID, m_fragTags ); } return m_eStatus; }
virtual void Exit() { const EntityId rootEntityId = GetRootScope().GetEntityId(); CPlayer &player = *static_cast<CPlayer*>(g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(rootEntityId)); CAIAnimationComponent* pAIAnimationComponent = player.GetAIAnimationComponent(); CRY_ASSERT(pAIAnimationComponent); pAIAnimationComponent->RequestAIMovementDetail(CAnimActionAIDetail::None); m_animChar.SetMovementControlMethods(eMCM_Entity, eMCM_Entity); DoExplicitStanceChange(player, pAIAnimationComponent); TBase::Exit(); }
void UpdateCameraAnimFactor() { if (GetStatus() == IAction::Installed) { const IScope & rootScope = GetRootScope(); const float timeLeft = rootScope.CalculateFragmentTimeRemaining(); const float duration = max(m_duration, timeLeft); float fractionComplete = 1.f; if (duration > 0.0f) { fractionComplete = 1.f - (timeLeft / duration); } m_duration = duration; m_player.BlendPartialCameraAnim(LERP (m_cameraAnimFactorAtStart, m_cameraAnimFactorAtEnd, fractionComplete), 0.1f); } }
IAction::EStatus CAnimActionAIStance::Update( float elapsedSeconds ) { TBase::Update( elapsedSeconds ); const IScope& rootScope = GetRootScope(); const float fragmentDuration = rootScope.GetFragmentDuration(); const float fragmentTime = rootScope.GetFragmentTime(); const float fragmentNormalisedTime = fragmentDuration ? ( fragmentTime / fragmentDuration ) : 0.0f; if ( 0.7f < fragmentNormalisedTime ) { SetPlayerAnimationStanceOnce(); ForceFinish(); } return m_eStatus; }
// ---------------------------------------------------------------------------- bool CAnimActionTriState::TrySetTransitionFragment( uint32 fragTagCRC ) { const IScope& rootScope = GetRootScope(); const IAnimationDatabase& database = rootScope.GetDatabase(); const TagState globalTagState = GetContext().state.GetMask(); TagState fragTags = TAG_STATE_EMPTY; if ( fragTagCRC ) { const CTagDefinition* pFragTagDef = GetContext().controllerDef.GetFragmentTagDef( m_fragmentID ); if ( !pFragTagDef ) { return false; } const TagID fragTagID = pFragTagDef->Find( fragTagCRC ); if ( fragTagID == TAG_ID_INVALID ) { return false; } pFragTagDef->Set( fragTags, fragTagID, true ); } const TagState scopeAdditionalTags = rootScope.GetAdditionalTags(); const TagState combinedGlobalTagState = GetContext().controllerDef.m_tags.GetUnion( globalTagState, scopeAdditionalTags ); const SFragTagState fragTagState( combinedGlobalTagState, fragTags ); SFragTagState matchingTagState; const uint32 optionCount = database.FindBestMatchingTag( SFragmentQuery(m_fragmentID, fragTagState), &matchingTagState ); if ( optionCount == 0 || matchingTagState.fragmentTags != fragTagState.fragmentTags ) { return false; } if ( m_fragTags != fragTags ) { SetFragment( m_fragmentID, fragTags ); } return true; }
IAction::EStatus CActionItemIdle::Update(float timePassed) { UpdateFragmentTags(); CWeapon *weapon = m_ownerPlayer.GetWeapon(m_ownerPlayer.GetCurrentItemId()); bool canPlayIdleBreak = !weapon || !(weapon->IsZoomed() || weapon->IsZoomingInOrOut()); if (m_playingIdleBreak) { if (!canPlayIdleBreak) { m_playingIdleBreak = false; } } else if (canPlayIdleBreak) { const float currentTime = gEnv->pTimer->GetAsyncCurTime(); IPlayerInput* pClientInput = m_ownerPlayer.GetPlayerInput(); if (pClientInput) { const float idleBreakDelay = g_pGameCVars->cl_idleBreaksDelayTime; const float lastInputTime = pClientInput->GetLastRegisteredInputTime(); const float referenceTime = (float)__fsel((lastInputTime - m_lastIdleBreakTime), lastInputTime, m_lastIdleBreakTime); if ((currentTime - referenceTime) > idleBreakDelay) { m_playingIdleBreak = true; SetFragment(m_fragmentIdleBreak, m_fragTags); m_lastIdleBreakTime = currentTime; } } } if (!m_playingIdleBreak) { if (GetRootScope().IsDifferent(m_fragmentIdle, m_fragTags)) { SetFragment(m_fragmentIdle, m_fragTags); } } return BaseClass::Update(timePassed); }
IAction::EStatus CRapidFireAction::Update(float timePassed) { if(!m_pFireMode || !m_pFireMode->IsFiring()) { m_eStatus = Finished; } else { m_animWeight = m_pFireMode->GetFireAnimationWeight(); float param = 0.f; param = m_pFireMode->GetAmmoSoundParam(); SetParam(CItem::sActionParamCRCs.ammoLeft, param); SetParam(CItem::sActionParamCRCs.fired, m_pFireMode->Fired()); SetParam(CItem::sActionParamCRCs.firstFire, m_pFireMode->FirstFire()); if (GetRootScope().IsDifferent(m_fragmentID, m_fragTags, m_subContext)) { SetFragment(m_fragmentID, m_fragTags); } } return BaseClass::Update(timePassed); }
void CAnimActionAIAimPose::InitialiseAimPoseBlender() { IScope& rootScope = GetRootScope(); ICharacterInstance* pCharacterInstance = rootScope.GetCharInst(); CRY_ASSERT( pCharacterInstance ); if ( ! pCharacterInstance ) { return; } ISkeletonPose* pSkeletonPose = pCharacterInstance->GetISkeletonPose(); CRY_ASSERT( pSkeletonPose ); IAnimationPoseBlenderDir* pPoseBlenderAim = pSkeletonPose->GetIPoseBlenderAim(); CRY_ASSERT( pPoseBlenderAim ); if ( ! pPoseBlenderAim ) { return; } const uint32 aimPoseAnimationLayer = rootScope.GetBaseLayer(); pPoseBlenderAim->SetLayer( aimPoseAnimationLayer ); }
void CMelee::CMeleeAction::OnHitResult( CActor* pOwnerActor, bool hit ) { CRY_ASSERT(pOwnerActor); const SMannequinPlayerParams::Fragments::Smelee_multipart& meleeFragment = PlayerMannequin.fragments.melee_multipart; const CTagDefinition* pFragTagDef = meleeFragment.pTagDefinition; if(pFragTagDef) { pFragTagDef->Set(m_fragTags, hit ? meleeFragment.fragmentTagIDs.hit : meleeFragment.fragmentTagIDs.miss, true); // In TP, force record the tag change so that the FP KillCam replay looks correct. if(pOwnerActor->IsThirdPerson() && GetStatus()==Installed) { if(CRecordingSystem* pRecSys = g_pGame->GetRecordingSystem()) { uint32 optionIdx = GetOptionIdx(); if (optionIdx == OPTION_IDX_RANDOM) { SetOptionIdx(GetContext().randGenerator.GenerateUint32()); } pRecSys->OnMannequinRecordHistoryItem( SMannHistoryItem(GetForcedScopeMask(), PlayerMannequin.fragmentIDs.melee_multipart, m_fragTags, GetOptionIdx(), false), GetRootScope().GetActionController(), GetRootScope().GetEntityId() ); } } } SetFragment(PlayerMannequin.fragmentIDs.melee_multipart, m_fragTags, m_optionIdx, m_userToken, false); m_FinalStage = true; m_flags &= ~IAction::NoAutoBlendOut; }