本文整理汇总了C++中CInventory::SetAmmoCount方法的典型用法代码示例。如果您正苦于以下问题:C++ CInventory::SetAmmoCount方法的具体用法?C++ CInventory::SetAmmoCount怎么用?C++ CInventory::SetAmmoCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CInventory
的用法示例。
在下文中一共展示了CInventory::SetAmmoCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetAmmoCount
//------------------------------------------------------------------------
int CScriptBind_Inventory::SetAmmoCount(IFunctionHandler *pH, const char *ammoName, int count)
{
CInventory *pInventory = GetInventory(pH);
CRY_ASSERT(pInventory);
IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(ammoName);
CRY_ASSERT(pClass);
if (pClass)
{
pInventory->SetAmmoCount(pClass, count);
if (gEnv->bServer)
{
pInventory->GetActor()->GetGameObject()->InvokeRMI(CInventory::Cl_SetAmmoCount(),
TRMIInventory_Ammo(ammoName, count),
eRMI_ToRemoteClients);
}
}
else
{
CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "Ammo class %s not found!", ammoName);
}
return pH->EndFunction();
}
示例2: OnRecordedGameplayEvent
//.........这里部分代码省略.........
}
if(demo_forceGameState==2 && fireModeIdx!= recFireModeIdx)
pWeapon->SetCurrentFireMode(recFireModeIdx);
}
}
}
}
break;
case eGE_WeaponReload:
{
const char* ammoType = event.description;
TAmmoContainer& ammoMags = gstate.AmmoMags;
TAmmoContainer::iterator it = ammoMags.find(ammoType);
if(it!=ammoMags.end())
{
it->second -= (uint16)event.value;
CActor *pActor = (CActor*)(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(id));
if(pActor)
{
CInventory* pInventory = (CInventory*)(pActor->GetInventory());
if(pInventory)
{
{
IEntityClass* pAmmoClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(ammoType);
if(pAmmoClass)
{
if(m_bLogWarning)
CheckDifference(it->second,pInventory->GetAmmoCount(pAmmoClass),"TimeDemo:GameState: Frame %d - Actor %s - WEAPON RELOAD, ammo count mismatch for ammo class %s (rec:%d, cur:%d)",pEntity,ammoType);
if(demo_forceGameState == 2)
pInventory->SetAmmoCount(pAmmoClass,it->second);
}
}
}
}
}
}
break;
case eGE_ItemSelected:
{
TItemName itemName = event.description;
gstate.itemSelected = itemName;
if(itemName)
{
if( !bRecording && (event.value > 0 || demo_forceGameState==2)) // EVENT.VALUE > 0 means initialization
{
CActor *pActor = (CActor*)(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(id));
if(pActor && pActor->GetInventory())
{
IItem* pItem = pActor->GetInventory()->GetItemByName(itemName);
if(pItem)
pActor->SelectItem(pItem->GetEntityId(),false);
}
}
}
if(m_bLogWarning)
{
CActor *pActor = (CActor*)(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(id));
if(pActor)
{
IItem* pItem = pActor->GetCurrentItem();