当前位置: 首页>>代码示例>>C++>>正文


C++ CBaseViewModel::SetPlaybackRate方法代码示例

本文整理汇总了C++中CBaseViewModel::SetPlaybackRate方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseViewModel::SetPlaybackRate方法的具体用法?C++ CBaseViewModel::SetPlaybackRate怎么用?C++ CBaseViewModel::SetPlaybackRate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CBaseViewModel的用法示例。


在下文中一共展示了CBaseViewModel::SetPlaybackRate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Reload

bool CWeaponShotgun::Reload()
{
	CSDKPlayer *pPlayer = GetPlayerOwner();

	if (pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 || m_iClip1 == GetMaxClip1())
		return true;

	// don't reload until recoil is done
	if (m_flNextPrimaryAttack > GetCurrentTime())
		return true;
		
	CBaseViewModel *vm = pPlayer->GetViewModel( m_nViewModelIndex );
	float flSpeedMultiplier = GetSDKWpnData().m_flReloadTimeMultiplier;

	// check to see if we're ready to reload
	if (m_iInSpecialReload == 0)
	{
		pPlayer->SetAnimation( PLAYER_RELOAD );

		float flStartTime = 0.5f * flSpeedMultiplier;

		pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );

		SendWeaponAnim( ACT_SHOTGUN_RELOAD_START );
		m_iInSpecialReload = 1;

		/* this is the only part of the reload sequence that can't be interrupted, seems unnecessary
		pPlayer->m_flNextAttack = GetCurrentTime() + flStartTime;
		m_flNextPrimaryAttack = GetCurrentTime() + flStartTime;
		m_flNextSecondaryAttack = GetCurrentTime() + flStartTime;
		*/

		SetWeaponIdleTime( GetCurrentTime() + flStartTime );

		if (vm)
			vm->SetPlaybackRate( 1/flSpeedMultiplier );

		pPlayer->Instructor_LessonLearned("reload");
		return true;
	}
	else if (m_iInSpecialReload == 1)
	{
		if (m_flTimeWeaponIdle > GetCurrentTime())
			return true;
		// was waiting for gun to move to side
		m_iInSpecialReload = 2;

		float flReloadTime = 0.45 * flSpeedMultiplier;

		SendWeaponAnim( ACT_VM_RELOAD );
		SetWeaponIdleTime( GetCurrentTime() + flReloadTime );

		pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD_LOOP );

		if (vm)
			vm->SetPlaybackRate( 1/flSpeedMultiplier );
	}
	else if ( m_iInSpecialReload == 2 ) // Sanity, make sure it's actually in the right state.
	{
		// Add them to the clip
		m_iClip1 += 1;

#ifdef GAME_DLL
		// Send a message to any clients that have this entity to play the reload.
		CPASFilter filter( pPlayer->GetAbsOrigin() );
		filter.RemoveRecipient( pPlayer );

		UserMessageBegin( filter, "ReloadEffect" );
		WRITE_SHORT( pPlayer->entindex() );
		MessageEnd();
#endif

		if ( pPlayer )
		{
			bool bConsume = true;
			if (pPlayer->IsStyleSkillActive(SKILL_MARKSMAN))
				bConsume = false;

			if (bConsume)
				pPlayer->RemoveAmmo( 1, m_iPrimaryAmmoType );
		}

		if ( pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 || m_iClip1 == GetMaxClip1() )
			pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD_END );

		m_iInSpecialReload = 1;
	}

	return true;
}
开发者ID:jlwitthuhn,项目名称:DoubleAction,代码行数:90,代码来源:weapon_shotgun.cpp


注:本文中的CBaseViewModel::SetPlaybackRate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。