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


C++ CItem::AttachAccessory方法代码示例

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


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

示例1: SetDualSlaveAccessory

//------------------------------------------------------------------------
void CItem::SetDualSlaveAccessory(bool noNetwork)
{
	if(!gEnv->bMultiplayer || (GetOwnerActor() && GetOwnerActor()->IsClient()))
	{
		CItem *pSlave = static_cast<CItem *>(GetDualWieldSlave());
		if (!pSlave)
			return;

		//Detach current accessories of the slave
		TAccessoryMap temp = pSlave->m_accessories;
		for (TAccessoryMap::const_iterator it=temp.begin(); it!=temp.end(); ++it)
		{
			if(m_accessories.find(it->first)==m_accessories.end())
				pSlave->SwitchAccessory(it->first.c_str()); //Only remove if not in the master
		}

		//Attach on the slave same accessories as "parent"
		for (TAccessoryMap::const_iterator it=m_accessories.begin(); it!=m_accessories.end(); ++it)
		{
			if(pSlave->m_accessories.find(it->first)==pSlave->m_accessories.end())
			{
				if(noNetwork)
					pSlave->AttachAccessory(it->first.c_str(), true, true, true);
				else
					pSlave->SwitchAccessory(it->first.c_str()); //Only add if not already attached
			}
		}
	}
}
开发者ID:Arnm7890,项目名称:CryGame,代码行数:30,代码来源:ItemDualWield.cpp

示例2: AttachAccessory

void CItem::AttachAccessory(const ItemString &name, bool attach, bool noanim, bool force, bool initialSetup)
{
	if(!force && IsBusy())
		return;

	bool anim = !noanim && m_stats.fp;
	SAccessoryParams *params = GetAccessoryParams(name);

	if(!params)
		return;

	if(attach)
	{
		if(!IsAccessoryHelperFree(params->attach_helper))
			return;

		if(CItem *pAccessory = AddAccessory(name))
		{
			pAccessory->Physicalize(false, false);
			pAccessory->SetViewMode(m_stats.viewmode);

			if(!initialSetup)
				pAccessory->m_bonusAccessoryAmmo.clear();

			SetCharacterAttachment(eIGS_FirstPerson, params->attach_helper, pAccessory->GetEntity(), eIGS_FirstPerson, 0);
			SetBusy(true);

			AttachAction action(pAccessory, params);

			if(anim)
			{
				PlayAction(params->attach_action, 0, false, eIPAF_Default|eIPAF_NoBlend);
				m_scheduler.TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<AttachAction>::Create(action), false);
			}
			else
				action.execute(this);

		}
	}
	else
	{
		if(CItem *pAccessory = GetAccessory(name))
		{
			DetachAction action(pAccessory, params);

			if(anim)
			{
				StopLayer(params->attach_layer, eIPAF_Default|eIPAF_NoBlend);
				PlayAction(params->detach_action, 0, false, eIPAF_Default|eIPAF_NoBlend);
				m_scheduler.TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<DetachAction>::Create(action), false);
				SetBusy(true);
			}
			else
			{
				SetBusy(true);
				action.execute(this);
			}
		}
	}

	//Skip all this for the offhand
	if(GetEntity()->GetClass()!=CItem::sOffHandClass)
		FixAccessories(params, attach);

	//Attach silencer to 2nd SOCOM
	/////////////////////////////////////////////////////////////
	bool isDualWield = IsDualWieldMaster();
	CItem *dualWield = 0;

	if(isDualWield)
	{
		IItem *slave = GetDualWieldSlave();

		if(slave && slave->GetIWeapon())
			dualWield = static_cast<CItem *>(slave);
		else
			isDualWield = false;
	}

	if(isDualWield)
		dualWield->AttachAccessory(name,attach,noanim);

	//////////////////////////////////////////////////////////////

	//Luciano - send game event
	g_pGame->GetIGameFramework()->GetIGameplayRecorder()->Event(GetOwner(), GameplayEvent(eGE_AttachedAccessory, name, (float)attach, (void *)GetEntityId()));

}
开发者ID:super-nova,项目名称:NovaRepo,代码行数:88,代码来源:ItemAccessory.cpp


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