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; }
void CActorAnimationActionAimPose::OnInitialise() { CAnimationAction::OnInitialise(); const FragmentID fragmentId = FindFragmentId(*m_context); CRY_ASSERT(fragmentId != FRAGMENT_ID_INVALID); SetFragment(fragmentId); }
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; } }
BUrl::BUrl(const BUrl& base, const BString& location) : fUrlString(), fProtocol(), fUser(), fPassword(), fHost(), fPort(0), fPath(), fRequest(), fAuthorityValid(false), fUserInfoValid(false), fHasUserName(false), fHasPassword(false), fHasHost(false), fHasPort(false), fHasFragment(false) { // This implements the algorithm in RFC3986, Section 5.2. BUrl relative(location); if (relative.HasProtocol()) { SetProtocol(relative.Protocol()); if (relative.HasAuthority()) SetAuthority(relative.Authority()); SetPath(relative.Path()); SetRequest(relative.Request()); } else { if (relative.HasAuthority()) { SetAuthority(relative.Authority()); SetPath(relative.Path()); SetRequest(relative.Request()); } else { if (relative.Path().IsEmpty()) { _SetPathUnsafe(base.Path()); if (relative.HasRequest()) SetRequest(relative.Request()); else SetRequest(base.Request()); } else { if (relative.Path()[0] == '/') SetPath(relative.Path()); else { BString path = base._MergePath(relative.Path()); SetPath(path); } SetRequest(relative.Request()); } if (base.HasAuthority()) SetAuthority(base.Authority()); } SetProtocol(base.Protocol()); } if (relative.HasFragment()) SetFragment(relative.Fragment()); }
void DoSlideKick() { m_slideFragID = m_fragmentID; m_slideFragTags = m_fragTags; SetFragment( PlayerMannequin.fragmentIDs.slidingKick ); m_kicking = 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 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; }
BUrl::BUrl(const BUrl& base, const BString& location) : fUrlString(), fProtocol(), fUser(), fPassword(), fHost(), fPort(0), fPath(), fRequest(), fHasAuthority(false) { // This implements the algorithm in RFC3986, Section 5.2. BUrl relative(location); if (relative.HasProtocol()) { SetProtocol(relative.Protocol()); SetAuthority(relative.Authority()); SetPath(relative.Path()); // TODO _RemoveDotSegments() SetRequest(relative.Request()); } else { if (relative.HasAuthority()) { SetAuthority(relative.Authority()); SetPath(relative.Path()); // TODO _RemoveDotSegments() SetRequest(relative.Request()); } else { if (relative.Path().IsEmpty()) { SetPath(base.Path()); if (relative.HasRequest()) SetRequest(relative.Request()); else SetRequest(Request()); } else { if (relative.Path()[0] == '/') SetPath(relative.Path()); else { BString path = base.Path(); // Remove last part of path (the file, if any) so we get the // "current directory" path.Truncate(path.FindLast('/') + 1); path += relative.Path(); // TODO _RemoveDotSegments() SetPath(path); } SetRequest(relative.Request()); } SetAuthority(base.Authority()); } SetProtocol(base.Protocol()); } SetFragment(relative.Fragment()); }
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); }
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; }
// ---------------------------------------------------------------------------- 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 CAnimActionBlendFromRagdoll::Update(float timePassed) { #ifdef USE_BLEND_FROM_RAGDOLL if( !m_animIds.empty() && !m_bSetAnimationFrag && m_pPoseMatching->GetMatchingAnimation(m_animID) ) #endif { uint optionIdx = 0; for( ; optionIdx<m_animIds.size(); ++optionIdx ) { if( m_animID == m_animIds[optionIdx] ) { break; } } SetFragment( m_fragmentID, m_fragTagsTarget, optionIdx ); m_bSetAnimationFrag = true; } return TBase::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 CAnimActionAILooking::OnInitialise() { const FragmentID fragmentId = FindFragmentId( *m_context ); CRY_ASSERT( fragmentId != FRAGMENT_ID_INVALID ); SetFragment( fragmentId ); }
/* * This function takes a URL in string-form and parses the components of the URL out. */ status_t BUrl::_ExplodeUrlString(const BString& url) { _ResetFields(); // RFC3986, Appendix C; the URL should not contain whitespace or delimiters // by this point. if (_ContainsDelimiter(url)) return B_BAD_VALUE; explode_url_parse_state state = EXPLODE_PROTOCOL; int32 offset = 0; int32 length = url.Length(); const char *url_c = url.String(); // The regexp is provided in RFC3986 (URI generic syntax), Appendix B // ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))? // The ensuing logic attempts to simulate the behaviour of extracting the groups // from the string without requiring a group-capable regex engine. while (offset < length) { switch (state) { case EXPLODE_PROTOCOL: { int32 end_protocol = char_offset_until_fn_false(url_c, length, offset, explode_is_protocol_char); if (end_protocol < length) { SetProtocol(BString(&url_c[offset], end_protocol - offset)); state = EXPLODE_PROTOCOLTERMINATOR; offset = end_protocol; } else { // No protocol was found, try parsing from the string // start, beginning with authority or path SetProtocol(""); offset = 0; state = EXPLODE_AUTHORITYORPATH; } break; } case EXPLODE_PROTOCOLTERMINATOR: { if (url[offset] == ':') { offset++; } else { // No protocol was found, try parsing from the string // start, beginning with authority or path SetProtocol(""); offset = 0; } state = EXPLODE_AUTHORITYORPATH; break; } case EXPLODE_AUTHORITYORPATH: { // The authority must start with //. If it isn't there, skip // to parsing the path. if (strncmp(&url_c[offset], "//", 2) == 0) { state = EXPLODE_AUTHORITY; offset += 2; } else { state = EXPLODE_PATH; } break; } case EXPLODE_AUTHORITY: { int end_authority = char_offset_until_fn_false(url_c, length, offset, explode_is_authority_char); SetAuthority(BString(&url_c[offset], end_authority - offset)); state = EXPLODE_PATH; offset = end_authority; break; } case EXPLODE_PATH: { int end_path = char_offset_until_fn_false(url_c, length, offset, explode_is_path_char); SetPath(BString(&url_c[offset], end_path - offset)); state = EXPLODE_REQUEST; offset = end_path; break; } case EXPLODE_REQUEST: // query { if (url_c[offset] == '?') { offset++; int end_request = char_offset_until_fn_false(url_c, length, offset, explode_is_request_char); SetRequest(BString(&url_c[offset], end_request - offset)); offset = end_request; } state = EXPLODE_FRAGMENT; break; } case EXPLODE_FRAGMENT: { if (url_c[offset] == '#') { offset++; SetFragment(BString(&url_c[offset], length - offset)); offset = length; } state = EXPLODE_COMPLETE; break; } case EXPLODE_COMPLETE: // should never be reached - keeps the compiler happy break; } } return B_OK; }
void IRI::SetContentFragmentIdentifier(const CFI &cfi) { if ( cfi.Empty() ) return; SetFragment(cfi.String()); }