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


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

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


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

示例1: storeObject

void PetControlDeviceImplementation::storeObject(CreatureObject* player, bool force) {
	ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();

	if (controlledObject == NULL || !controlledObject->isAiAgent())
		return;

	ManagedReference<AiAgent*> pet = cast<AiAgent*>(controlledObject.get());

	assert(pet->isLockedByCurrentThread());

	if (!force && (pet->isInCombat() || player->isInCombat()))
		return;

	if (player->isRidingMount() && player->getParent() == pet) {

		if (!force && !player->checkCooldownRecovery("mount_dismount"))
			return;

		player->executeObjectControllerAction(STRING_HASHCODE("dismount"));

		if (player->isRidingMount())
			return;
	}

	if( player->getCooldownTimerMap() == NULL )
		return;

	// Check cooldown
	if( !player->getCooldownTimerMap()->isPast("petCallOrStoreCooldown") && !force ){
		player->sendSystemMessage("@pet/pet_menu:cant_store_1sec"); //"You cannot STORE for 1 second."
		return;
	}

	// Not training any commands
	trainingCommand = 0;

	Reference<StorePetTask*> task = new StorePetTask(player, pet);

	// Store non-faction pets immediately.  Store faction pets after 60sec delay.
	if( petType != PetManager::FACTIONPET || force || player->getPlayerObject()->isPrivileged()){
		task->execute();
	}
	else{
		if(pet->getPendingTask("store_pet") == NULL) {
			player->sendSystemMessage( "Storing pet in 60 seconds");
			pet->addPendingTask("store_pet", task, 60 * 1000);
		}
		else{
			Time nextExecution;
			Core::getTaskManager()->getNextExecutionTime(pet->getPendingTask("store_pet"), nextExecution);
			int timeLeft = (nextExecution.getMiliTime() / 1000) - System::getTime();
			player->sendSystemMessage( "Pet will store in " + String::valueOf(timeLeft) + " seconds." );
			return;
		}

	}

	// Set cooldown
	player->getCooldownTimerMap()->updateToCurrentAndAddMili("petCallOrStoreCooldown", 1000); // 1 sec
}
开发者ID:angelsounds777,项目名称:Core3-CU,代码行数:60,代码来源:PetControlDeviceImplementation.cpp

示例2: onCall

void DroidHarvestModuleDataComponent::onCall(){
	deactivate();
	ManagedReference<DroidObject*> droid = getDroidObject();
	if( droid == NULL ){
		info( "Droid is null");
		return;
	}
	if (observer == NULL) {
		observer = new DroidHarvestObserver(this);
		observer->deploy();
	}
	Locker dlock( droid );
	// add observer for the droid
	//droid->registerObserver(ObserverEventType::DESTINATIONREACHED, observer);
	Reference<Task*> task = new DroidHarvestTask( this );
	droid->addPendingTask("droid_harvest", task, 1000); // 1 sec
}
开发者ID:duffstone01,项目名称:duffEMU,代码行数:17,代码来源:DroidHarvestModuleDataComponent.cpp

示例3: handleObjectMenuSelect

int DroidDetonationModuleDataComponent::handleObjectMenuSelect(CreatureObject* player, byte selectedID, PetControlDevice* controller) {

	if (selectedID == DETONATE_DROID) {
		ManagedReference<DroidObject*> droid = getDroidObject();
		if (droid == NULL) {
			info("Droid is null");
			return 0;
		}

		Locker dlock(droid, player);

		if (droid->isDead()) {
			player->sendSystemMessage("@pet/droid_modules:droid_bomb_failed");
			return 0;
		}

		// Droid must have power
		if (!droid->hasPower()) {
			droid->showFlyText("npc_reaction/flytext","low_power", 204, 0, 0);  // "*Low Power*"
			return 0;
		}

		// if the droid is already in detonation countdown we need to ignore this command
		if (droid->getPendingTask("droid_detonation") != NULL) {
			if (countdownInProgress())
				player->sendSystemMessage("@pet/droid_modules:countdown_already_started");
			else
				player->sendSystemMessage("@pet/droid_modules:detonation_warmup");
			return 0;
		}

		// droid has power and is not dead we can fire off the task
		Reference<Task*> task = new DroidDetonationTask(this, player);
		droid->addPendingTask("droid_detonation", task, 0); // queue the task for the droid to occur in 0 MS the task will handle init phase
	}

	return 0;
}
开发者ID:JigglyPoofSWG,项目名称:BSS,代码行数:38,代码来源:DroidDetonationModuleDataComponent.cpp

示例4: handleObjectMenuSelect

int DroidStimpackModuleDataComponent::handleObjectMenuSelect(CreatureObject* player, byte selectedID, PetControlDevice* controller) {
	ManagedReference<DroidObject*> droid = getDroidObject();
	DroidComponent* droidComponent = cast<DroidComponent*>(getParent());
	if (droid == NULL || droidComponent == NULL) {
		player->sendSystemMessage("@pet/droid_modules:stimpack_error");
		return 0;
	}
	
	if (selectedID == LOAD_STIMPACK) {
		Locker crossLoker(droid, player);
		
		ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
		if (inventory == NULL) {
			player->sendSystemMessage("@pet/droid_modules:no_stimpacks");
			return 0;
		}

		int foundStims = 0;

		for (int i = 0; i < inventory->getContainerObjectsSize(); ++i) {
			ManagedReference<SceneObject*> item = inventory->getContainerObject(i);

			if (!item->isPharmaceuticalObject())
				continue;

			// check it they have atleast 1 stim pack
			PharmaceuticalObject* pharma = item.castTo<PharmaceuticalObject*>();

			if (pharma->isStimPack()) {
				StimPack* stim = cast<StimPack*>(pharma);

				if (stim->isClassA()) {
					foundStims += 1;
				}
			}
		}

		if (foundStims == 0) {
			player->sendSystemMessage("@pet/droid_modules:no_stimpacks");
			return 0;
		} else {
			sendLoadUI(player);
			return 0;
		}

	} else if (selectedID == REQUEST_STIMPACK) {
		// we need to check cooldown on droid
		if (droid->isDead() || droid->isIncapacitated() || player->isDead()) {
			return 0;
		}

		// Droid must have power
		if (!droid->hasPower()) {
			droid->showFlyText("npc_reaction/flytext","low_power", 204, 0, 0);  // "*Low Power*"
			return 0;
		}

		if (droid->getPendingTask("droid_request_stimpack") != NULL) {
			player->sendSystemMessage("@pet/droid_modules:stimpack_not_ready");
			return 0;
		}

		// Submit stimpack task
		Reference<Task*> task = new DroidStimpackTask( droid,player,controller->getCustomObjectName().toString() );
		droid->addPendingTask("droid_request_stimpack", task, 1); // rte determines when it will fire it
	}

	return 0;
}
开发者ID:JigglyPoofSWG,项目名称:BSS,代码行数:69,代码来源:DroidStimpackModuleDataComponent.cpp


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