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


C++ CInventory::GetItemByClass方法代码示例

本文整理汇总了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();
}
开发者ID:aronarts,项目名称:FireNET,代码行数:13,代码来源:ScriptBind_Inventory.cpp

示例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;
开发者ID:kitnet,项目名称:project-o,代码行数:66,代码来源:GameStateRecorder.cpp


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