本文整理汇总了C++中CInventory::GetItemByClass方法的典型用法代码示例。如果您正苦于以下问题:C++ CInventory::GetItemByClass方法的具体用法?C++ CInventory::GetItemByClass怎么用?C++ CInventory::GetItemByClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CInventory
的用法示例。
在下文中一共展示了CInventory::GetItemByClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetGrenadeWeaponByClass
//----------------------------------------------------------------------
int CScriptBind_Inventory::GetGrenadeWeaponByClass(IFunctionHandler *pH, const char *className)
{
CInventory *pInventory = GetInventory(pH);
CRY_ASSERT(pInventory);
IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(className);
EntityId itemId = pInventory->GetItemByClass(pClass,NULL);
if (itemId)
return pH->EndFunction(ScriptHandle(itemId));
return pH->EndFunction();
}
示例2: OnRecordedGameplayEvent
//.........这里部分代码省略.........
GameWarning("TimeDemo:GameState: Frame %d - Actor %s - ACCESSORY PICKEDUP %s not found in current inventory", m_currentFrame, pEntity->GetName(),sel ? sel:"(null)");
if(demo_forceGameState == 2 && pClass)
pInventory->AddAccessory(pClass);// doesn't actually add it if it's there already
}
}
}
break;
case eGE_ItemDropped:
{
TItemName sel = (TItemName)event.description;
//gstate.itemSelected = sel;
TItemContainer& Items = gstate.Items;
TItemContainer::iterator it = Items.find(sel);
if(it != Items.end())
{
it->second.count--;
if(it->second.count<=0)
Items.erase(it);
if(demo_forceGameState == 2)
{
CActor *pActor = (CActor*)(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(id));
if(pActor)
{
CInventory* pInventory = (CInventory*)(pActor->GetInventory());
if(pInventory)
{
IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(sel);
if(pClass)
{
EntityId itemId = pInventory->GetItemByClass(pClass);
if(itemId)
pInventory->RemoveItem(itemId);
}
}
}
}
}
else
GameWarning("TimeDemo:GameState: Frame %d - Actor %s - ITEM DROPPED, wrong item selected (%s)",m_currentFrame,pEntity->GetName(),sel);
}
break;
case eGE_AmmoCount:
{
TItemContainer& Items = gstate.Items;
TItemName itemClassDesc = event.description;
TItemContainer::iterator it = Items.find(itemClassDesc);
if(it != Items.end())
{
SItemProperties& item = it->second;
const char* ammoClassDesc = (const char*)(event.extra);
if(ammoClassDesc)
{
string szAmmoClassDesc(ammoClassDesc);
bool bAmmoMag = IsAmmoGrenade(ammoClassDesc);
TAmmoContainer& itemAmmo = bAmmoMag ? gstate.AmmoMags : item.Ammo;
if(itemAmmo.find(szAmmoClassDesc)==itemAmmo.end())
itemAmmo.insert(std::make_pair(szAmmoClassDesc,int(event.value)));
else
itemAmmo[szAmmoClassDesc] = (uint16)event.value;