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


C++ CGameItemPtr::setPhraseId方法代码示例

本文整理汇总了C++中CGameItemPtr::setPhraseId方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameItemPtr::setPhraseId方法的具体用法?C++ CGameItemPtr::setPhraseId怎么用?C++ CGameItemPtr::setPhraseId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGameItemPtr的用法示例。


在下文中一共展示了CGameItemPtr::setPhraseId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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 //
开发者ID:mixxit,项目名称:solinia,代码行数:88,代码来源:game_item_manager.cpp


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