本文整理汇总了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
}
}
}
}
示例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()));
}