本文整理汇总了C++中CInventory::GetItemByName方法的典型用法代码示例。如果您正苦于以下问题:C++ CInventory::GetItemByName方法的具体用法?C++ CInventory::GetItemByName怎么用?C++ CInventory::GetItemByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CInventory
的用法示例。
在下文中一共展示了CInventory::GetItemByName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnRecordedGameplayEvent
void CGameStateRecorder::OnRecordedGameplayEvent(IEntity *pEntity, const GameplayEvent &event, int currentFrame, bool bRecording)
{
EntityId id;
m_currentFrame = currentFrame;
int demo_forceGameState = 0;
if(!bRecording)
{
ICVar *pVar = gEnv->pConsole->GetCVar( "demo_force_game_state" );
if(pVar)
demo_forceGameState = pVar->GetIVal();
}
if(!pEntity || !(id = pEntity->GetId()))
return;
if(m_IgnoredEvents.size())
if(event.event == m_IgnoredEvents[0])
{
m_IgnoredEvents.erase(m_IgnoredEvents.begin());
return;
}
TGameStates::iterator itActor = m_GameStates.find(id);
if(itActor == m_GameStates.end())
{
m_GameStates.insert(std::make_pair(id,SActorGameState()));
itActor = m_GameStates.find(id);
}
if(itActor == m_GameStates.end())
{
GameWarning("TimeDemo:GameState: actor %s not found in records",pEntity->GetName());
return;
}
SActorGameState& gstate = itActor->second;
switch(event.event)
{
case eGE_HealthChanged:
{
gstate.health = event.value;
if(!m_bRecording)
{
CActor *pActor = (CActor*)(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(id));
if(pActor)
{
if(m_bLogWarning)
{
if(CHECK_MISMATCH(pActor->GetHealth(), gstate.health,10))
{
if(!gstate.bHealthDifferent)
{
GameWarning("TimeDemo:GameState: Frame %d - Actor %s - HEALTH mismatch (%d, %d)",m_currentFrame,pEntity->GetName(), static_cast<int>(pActor->GetHealth()), static_cast<int>(gstate.health));
gstate.bHealthDifferent = true;
}
}
else
gstate.bHealthDifferent = false;
}
if( demo_forceGameState)
pActor->SetHealth(gstate.health);
}
}
}
break;
case eGE_WeaponFireModeChanged:
{
TItemName sel = (event.description);
if(sel)
{
TItemContainer& Items = gstate.Items;
TItemContainer::iterator iti = Items.find(sel);
uint8 recFireModeIdx = uint8(event.value);
if(iti != Items.end())
iti->second.fireMode = recFireModeIdx;
CActor *pActor = (CActor*)(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(id));
if(pActor && pActor->GetInventory())
{
IItem* pItem = pActor->GetInventory()->GetItemByName(sel);
CWeapon* pWeapon;
if(pItem && (pWeapon = (CWeapon*)(pItem->GetIWeapon())))
{
int fireModeIdx = pWeapon->GetCurrentFireMode();
if(m_bLogWarning)
{
CheckDifference(recFireModeIdx,fireModeIdx,"TimeDemo:GameState: Frame %d - Actor %s - FIRE MODE mismatch for weapon %s (rec:%d, cur:%d)",pEntity,pItem->GetEntity() ? pItem->GetEntity()->GetName() : "(null)");
}
if(demo_forceGameState==2 && fireModeIdx!= recFireModeIdx)
pWeapon->SetCurrentFireMode(recFireModeIdx);
}
}
}
}
//.........这里部分代码省略.........