本文整理汇总了C++中CGameItemPtr::getItemCopy方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameItemPtr::getItemCopy方法的具体用法?C++ CGameItemPtr::getItemCopy怎么用?C++ CGameItemPtr::getItemCopy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameItemPtr
的用法示例。
在下文中一共展示了CGameItemPtr::getItemCopy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createNamedItem
//-----------------------------------------------------------------------------
CGameItemPtr CNamedItems::createNamedItem(const std::string & name, uint32 quantity)
{
if (quantity == 0)
return NULL;
CGameItemPtr itemSrc = getNamedItemRef(name);
if( itemSrc == NULL )
return NULL;
CGameItemPtr item = itemSrc->getItemCopy();
return item;
}
示例2: createInGameItem
//-----------------------------------------------
// createInGameItem
//-----------------------------------------------
CGameItemPtr CGameItemManager::createInGameItem( uint16 quality, uint32 quantity, const NLMISC::CSheetId &sheet, const CEntityId &creatorId , const std::string * phraseId)
{
H_AUTO(GIM_createInGameItem);
static const CSheetId preorderSheetId("pre_order.sitem");
if ( quantity == 0 || quality ==0 )
return NULL;
// static const CSheetId idSheetStack("stack.sitem");
const CStaticItem* form = CSheets::getForm( sheet );
if (!form)
{
nlwarning("<CCharacter::createInGameItem> Cannot find form of item %s", sheet.toString().c_str());
return NULL;
}
CGameItemPtr item;
CGameItemPtr sellingItem;
// if item can be sold, get it in the sold items list
if ( form->Family != ITEMFAMILY::RAW_MATERIAL
&& form->Family != ITEMFAMILY::HARVEST_TOOL
&& form->Family != ITEMFAMILY::CRAFTING_TOOL
&& form->Family != ITEMFAMILY::CRYSTALLIZED_SPELL
&& form->Family != ITEMFAMILY::ITEM_SAP_RECHARGE
&& form->Family != ITEMFAMILY::FOOD
)
{
vector< CGameItemPtr >::const_iterator it;
const vector< CGameItemPtr >::const_iterator itEnd = CStaticItems::getStaticItems().end();
for( it = CStaticItems::getStaticItems().begin(); it != itEnd; ++it )
{
if( (*it)->getSheetId() == sheet )
{
sellingItem = *it;
break;
}
}
}
switch( form->Family )
{
case ITEMFAMILY::CRAFTING_TOOL:
case ITEMFAMILY::HARVEST_TOOL:
case ITEMFAMILY::RAW_MATERIAL:
case ITEMFAMILY::TELEPORT:
case ITEMFAMILY::CRYSTALLIZED_SPELL:
case ITEMFAMILY::ITEM_SAP_RECHARGE:
case ITEMFAMILY::MISSION_ITEM:
case ITEMFAMILY::PET_ANIMAL_TICKET:
case ITEMFAMILY::HANDLED_ITEM:
case ITEMFAMILY::CONSUMABLE:
case ITEMFAMILY::XP_CATALYSER:
case ITEMFAMILY::SCROLL:
case ITEMFAMILY::FOOD:
case ITEMFAMILY::SCROLL_R2:
case ITEMFAMILY::GENERIC_ITEM:
{
item = GameItemManager.createItem( const_cast< CSheetId& > ( sheet ), quality, true, true, creatorId);
}
break;
default:
{
if( sellingItem != NULL )
{
item = sellingItem->getItemCopy();
item->quality( quality );
if ( phraseId )
item->setPhraseId(*phraseId);
}
else if (sheet == preorderSheetId)
{
item = GameItemManager.createItem(sheet, quality, true, form->DropOrSell, creatorId);
}
}
if( item == NULL)
{
nlwarning("<CCharacter::createInGameItem> Error while creating item : NULL pointer");
return NULL;
}
}
quantity = min(quantity, item->getMaxStackSize());
item->setStackSize(quantity);
return item;
} // createInGameItem //