void CWeaponHL2MPBase::OnDataChanged( DataUpdateType_t type ) { BaseClass::OnDataChanged( type ); if ( GetPredictable() && !ShouldPredict() ) ShutdownPredictable(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CBasePlasmaProjectile::ClientThink( void ) { BaseClass::ClientThink(); // Don't mess with origin if it's being forward simulated on the client if ( GetPredictable() || IsClientCreated() ) return; Assert( !GetMoveParent() ); Vector pNewPosition, pNewVelocity; QAngle pNewAngles, pNewAngVelocity; RecalculatePositions( &pNewPosition, &pNewVelocity, &pNewAngles, &pNewAngVelocity ); }
bool C_BaseViewModel::Interpolate( float currentTime ) { CStudioHdr *pStudioHdr = GetModelPtr(); // Make sure we reset our animation information if we've switch sequences UpdateAnimationParity(); bool bret = BaseClass::Interpolate( currentTime ); // Hack to extrapolate cycle counter for view model float elapsed_time = currentTime - m_flAnimTime; C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); // Predicted viewmodels have fixed up interval if ( GetPredictable() || IsClientCreated() ) { Assert( pPlayer ); float curtime = pPlayer ? pPlayer->GetFinalPredictedTime() : gpGlobals->curtime; elapsed_time = curtime - m_flAnimTime; // Adjust for interpolated partial frame if ( !engine->IsPaused() ) { elapsed_time += ( gpGlobals->interpolation_amount * TICK_INTERVAL ); } } // Prediction errors? if ( elapsed_time < 0 ) { elapsed_time = 0; } float dt = elapsed_time * GetSequenceCycleRate( pStudioHdr, GetSequence() ) * GetPlaybackRate(); if ( dt >= 1.0f ) { if ( !IsSequenceLooping( GetSequence() ) ) { dt = 0.999f; } else { dt = fmod( dt, 1.0f ); } } SetCycle( dt ); return bret; }
//----------------------------------------------------------------------------- // Purpose: If the animation parity of the weapon has changed, we reset cycle to avoid popping //----------------------------------------------------------------------------- void C_BaseViewModel::UpdateAnimationParity( void ) { C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); // If we're predicting, then we don't use animation parity because we change the animations on the clientside // while predicting. When not predicting, only the server changes the animations, so a parity mismatch // tells us if we need to reset the animation. if ( m_nOldAnimationParity != m_nAnimationParity && !GetPredictable() ) { float curtime = (pPlayer && IsIntermediateDataAllocated()) ? pPlayer->GetFinalPredictedTime() : gpGlobals->curtime; // FIXME: this is bad // Simulate a networked m_flAnimTime and m_flCycle // FIXME: Do we need the magic 0.1? SetCycle( 0.0f ); // GetSequenceCycleRate( GetSequence() ) * 0.1; m_flAnimTime = curtime; } }
void CWeaponDODBase::OnDataChanged( DataUpdateType_t type ) { if ( m_iState == WEAPON_NOT_CARRIED && m_iOldState != WEAPON_NOT_CARRIED ) { // we are being notified of the weapon being dropped // add an interpolation history so the movement is smoother // Now stick our initial velocity into the interpolation history CInterpolatedVar< Vector > &interpolator = GetOriginInterpolator(); interpolator.ClearHistory(); float changeTime = GetLastChangeTime( LATCH_SIMULATION_VAR ); // Add a sample 1 second back. Vector vCurOrigin = GetLocalOrigin() - m_vInitialDropVelocity; interpolator.AddToHead( changeTime - 1.0, &vCurOrigin, false ); // Add the current sample. vCurOrigin = GetLocalOrigin(); interpolator.AddToHead( changeTime, &vCurOrigin, false ); Vector estVel; EstimateAbsVelocity( estVel ); /*Msg( "estimated velocity ( %.1f %.1f %.1f ) initial velocity ( %.1f %.1f %.1f )\n", estVel.x, estVel.y, estVel.z, m_vInitialDropVelocity.m_Value.x, m_vInitialDropVelocity.m_Value.y, m_vInitialDropVelocity.m_Value.z );*/ OnWeaponDropped(); } BaseClass::OnDataChanged( type ); if ( GetPredictable() && !ShouldPredict() ) ShutdownPredictable(); }
void C_ASW_Hack::PostDataUpdate( DataUpdateType_t updateType ) { bool bPredict = ShouldPredict(); if ( bPredict ) { SetSimulatedEveryTick( true ); SetPredictionEligible( true ); } else { SetSimulatedEveryTick( false ); SetPredictionEligible( false ); } BaseClass::PostDataUpdate( updateType ); if ( GetPredictable() && !bPredict ) { MDLCACHE_CRITICAL_SECTION(); ShutdownPredictable(); } }