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


C++ ManagedReference::decreaseUseCount方法代码示例

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


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

示例1: handleObjectMenuSelect

int SkillBuffObjectMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject, CreatureObject* player, byte selectedID) {

	if (!sceneObject->isASubChildOf(player))
		return 0;

	if (selectedID != 20) {
		return TangibleObjectMenuComponent::handleObjectMenuSelect(sceneObject, player, selectedID);
	}

	if (player->isDead() || player->isIncapacitated())
		return 0;

	if(!sceneObject->isTangibleObject())
		return 0;

	ManagedReference<TangibleObject*> tano = cast<TangibleObject*>(sceneObject);

	ManagedReference<SkillBuffTemplate*> skillBuff = cast<SkillBuffTemplate*>(sceneObject->getObjectTemplate());
	if (skillBuff == NULL) {
		error("No SkillBuffTemplate for: " + String::valueOf(sceneObject->getServerObjectCRC()));
		return 1;
	}

	unsigned int buffCRC = skillBuff->getBuffCRC();
	int duration = skillBuff->getDuration();
	VectorMap<String, float>* modifiers = skillBuff->getModifiers();

	// Check if buff of same type is already active
	if ( player->hasBuff(buffCRC) ) {
		player->sendSystemMessage("@skill_buff_n:already_have"); //You already have that skill modifier active.
		return 0;
	}


	// Submit buff
	player->addBuff(buffCRC);

	// Send message to player
	StringIdChatParameter stringId("skill_buff_d", "consume"); // You feel enhanced!
	player->sendSystemMessage(stringId);

	//Consume a charge from the item, destroy it if it reaches 0 charges remaining.
	tano->decreaseUseCount();

	return TangibleObjectMenuComponent::handleObjectMenuSelect(sceneObject, player, selectedID);
}
开发者ID:angelsounds777,项目名称:Core3-CU,代码行数:46,代码来源:SkillBuffObjectMenuComponent.cpp

示例2: rechargeFromBattery

int DroidObjectImplementation::rechargeFromBattery(CreatureObject* player){

	// Find droid battery in player inventory
	ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
	if (inventory == NULL){
		player->sendSystemMessage("Player inventory not found");
		return 0;
	}

	ManagedReference<SceneObject*> batterySceno = NULL;
	for (int i = 0; i < inventory->getContainerObjectsSize(); ++i) {
		ManagedReference<SceneObject*> sceno = inventory->getContainerObject(i);
		if( sceno->getObjectTemplate()->getFullTemplateString() == "object/tangible/droid_battery/battery.iff" ){
			batterySceno = sceno;
		}
	}

	// Battery not found
	if( batterySceno == NULL ){
		showFlyText("npc_reaction/flytext","nobattery", 204, 0, 0); // "You don't have a power storage device."
		return 0;
	}

	// Battery found
	ManagedReference<TangibleObject*> batteryTano = cast<TangibleObject*>(batterySceno.get());
	if( batteryTano == NULL ){
		player->sendSystemMessage("Error with droid battery object");
		return 0;
	}

	// Reset power to max
	power = MAX_POWER;

	// Consume battery
	Locker locker(batteryTano);

	batteryTano->decreaseUseCount();

	showFlyText("npc_reaction/flytext","recharged", 0, 153, 0);  // "*Recharged*"
	doAnimation("power_up");
	return 0;

}
开发者ID:duffstone01,项目名称:duffEMU,代码行数:43,代码来源:DroidObjectImplementation.cpp


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