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


C++ Inventory::getObjectById方法代码示例

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


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

示例1:

bool	ArtisanManager::stopSampling(PlayerObject* player, CurrentResource* resource, SurveyTool* tool)
{
    Ham* ham = player->getHam();
    bool stop = false;

    if(!resource || !tool || !player->isConnected() || !player->getSamplingState()||player->getSurveyState())
    {
        stop = true;
    }		 
    // you can't take sample while under attack!
    if(player->states.checkState(CreatureState_Combat))
    {
         gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "sample_cancel_attack"), player);
        return false;
    }
    Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
    if(!inventory)
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "sample_gone"), player);
        stop = true;
    }

    tool		= dynamic_cast<SurveyTool*>(inventory->getObjectById(tool->getId()));
    if(!tool)
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "sample_gone"), player);
        stop = true;
    }

    uint32 actionCost = mSampleActionCost;

    if(!ham->checkMainPools(0,actionCost,0))
    {		
        //return message for sampling cancel based on HAM
        if(ham->mAction.getCurrentHitPoints() < (int32)actionCost)
        {
            gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "sample_mind"), player);
            stop = true;
        }
    }

    if (stop)
    {
        player->setSamplingState(false);
        gStateManager.setCurrentPostureState(player, CreaturePosture_Upright);
    }
    return stop;
}
开发者ID:ANHcRush,项目名称:mmoserver,代码行数:48,代码来源:ArtisanManager.cpp

示例2: handleDatabaseJobComplete

void ObjectFactory::handleDatabaseJobComplete(void* ref,DatabaseResult* result)
{
	OFAsyncContainer* asyncContainer = reinterpret_cast<OFAsyncContainer*>(ref);

	switch(asyncContainer->query)
	{
		case OFQuery_House:
		{
			PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->PlayerId));
			if(!result->getRowCount())
			{
				gLogger->logMsg("ObjFactory::handleDatabaseJobComplete   :  create house failed : no result");
				break;
			}

			uint64 requestId = 0;
			DataBinding* binding = mDatabase->CreateDataBinding(1);
			binding->addField(DFT_uint64,0,8);
			result->GetNextRow(binding,&requestId);
			mDatabase->DestroyDataBinding(binding);

			if(!requestId)
			{
				gLogger->logMsg("ObjFactory::handleDatabaseJobComplete   :  create house failed : result is 0");
			}
			mHouseFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);

			//now we need to update the Owners Lots				
			//cave he might have logged out already - even if thats *very* unlikely (heck of a query that would have been)
			if(player)
			{
				gStructureManager->UpdateCharacterLots(asyncContainer->PlayerId);
				Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
				Deed* deed = dynamic_cast<Deed*>(gWorldManager->getObjectById(asyncContainer->DeedId));
				
				//destroy it in the client
				gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);
	
				//delete it out of the inventory
				inventory->deleteObject(deed);
				
				Datapad* thePad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
				thePad->requestNewWaypoint("Player House",asyncContainer->coords,gWorldManager->getPlanetIdByName(gWorldManager->getPlanetNameThis()),1);

			}
			
			// now we need to link the deed to the factory in the db and remove it out of the inventory in the db
			int8 sql[250];
			sprintf(sql,"UPDATE items SET parent_id = %I64u WHERE id = %"PRIu64"",requestId, asyncContainer->DeedId);
			mDatabase->ExecuteSqlAsync(NULL,NULL,sql);
				
		}
		break;

		case OFQuery_Factory:
		{
			PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->PlayerId));
			if(!result->getRowCount())
			{
				gLogger->logMsg("ObjFactory::handleDatabaseJobComplete   :  create Factory failed : no result");
				break;
			}

			uint64 requestId = 0;
			DataBinding* binding = mDatabase->CreateDataBinding(1);
			binding->addField(DFT_uint64,0,8);
			result->GetNextRow(binding,&requestId);
			mDatabase->DestroyDataBinding(binding);

			if(!requestId)
			{
				gLogger->logMsg("ObjFactory::handleDatabaseJobComplete   :  create Factory failed : result is 0");
			}
			mFactoryFactory->requestObject(asyncContainer->ofCallback,requestId,0,0,asyncContainer->client);

			//now we need to update the Owners Lots
				
			//cave he might have logged out already - even if thats *very* unlikely (heck of a query that would have been)
			if(player)
			{
				gStructureManager->UpdateCharacterLots(asyncContainer->PlayerId);
				Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
				Deed* deed = dynamic_cast<Deed*>(gWorldManager->getObjectById(asyncContainer->DeedId));
				
				//destroy it in the client
				gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);
	
				//delete it out of the inventory
				inventory->deleteObject(deed);

				Datapad* thePad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
				thePad->requestNewWaypoint("Player Factory",asyncContainer->coords,gWorldManager->getPlanetIdByName(gWorldManager->getPlanetNameThis()),1);
			}
			
			// now we need to link the deed to the factory in the db and remove it out of the inventory in the db
			int8 sql[250];
			sprintf(sql,"UPDATE items SET parent_id = %I64u WHERE id = %"PRIu64"",requestId, asyncContainer->DeedId);
			mDatabase->ExecuteSqlAsync(NULL,NULL,sql);
				
		}
//.........这里部分代码省略.........
开发者ID:Arnold47525,项目名称:mmoserver,代码行数:101,代码来源:ObjectFactory.cpp

示例3: handleUIEvent

void ArtisanManager::handleUIEvent(uint32 action,int32 element,BString inputStr,UIWindow* window)
{
    PlayerObject* player = window->getOwner();
    std::shared_ptr<SimpleEvent> sample_UI_event = nullptr;
    if(!player)
    {
        return;
    }

    Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));			
    if(!inventory)
    {
        return;
    }
    
    WindowAsyncContainerCommand* asyncContainer = (WindowAsyncContainerCommand*)window->getAsyncContainer();
    if(!asyncContainer)
        return;

    Ham* ham = player->getHam();
    
    switch(window->getWindowType())
    {
        // Sampling Radioactive Msg Box
        case SUI_Window_SmplRadioactive_MsgBox:
        {
            //we stopped the sampling
            if(action == 1)
            {
                player->getSampleData()->mPassRadioactive = false;
                player->getSampleData()->mPendingSample = false;
                gStateManager.setCurrentPostureState(player, CreaturePosture_Upright);
                return;
            }
            else
            {    
                player->getSampleData()->mPassRadioactive = true;
                player->getSampleData()->mPendingSample = true;
                
                if(ham->checkMainPools(0,mSampleActionCost*2,0))
                {

                    SurveyTool*			tool					= dynamic_cast<SurveyTool*>(inventory->getObjectById(asyncContainer->ToolId));
                    CurrentResource*	resource				= (CurrentResource*)asyncContainer->CurrentResource;
                    player->getSampleData()->mNextSampleTime	= Anh_Utils::Clock::getSingleton()->getLocalTime() + 4000;

                    sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_radioactive"),0, 4000, 
                        std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool));

                }
                else
                {
                    gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_no_action"), player);
                    return;
                }
            }
        }
        break;

        case SUI_Window_SmplGamble_ListBox:
        {
            //action == 1 is cancel
            if(action == 1)
            {
                player->getSampleData()->mPendingSample = false;
                player->getSampleData()->mSampleGambleFlag = false;
                gStateManager.setCurrentPostureState(player, CreaturePosture_Upright);
                player->updateMovementProperties();
                gMessageLib->sendUpdateMovementProperties(player);
                gMessageLib->sendPostureAndStateUpdate(player);
                gMessageLib->sendSelfPostureUpdate(player);
                return;

            }
            else
            {
                if(element == 0)
                {
                    player->getSampleData()->mPendingSample = true;
                    player->getSampleData()->mSampleGambleFlag = false;

                    SurveyTool*			tool		= dynamic_cast<SurveyTool*>(inventory->getObjectById(asyncContainer->ToolId));
                    CurrentResource*	resource	= (CurrentResource*)asyncContainer->CurrentResource;
                    player->getSampleData()->mNextSampleTime = Anh_Utils::Clock::getSingleton()->getLocalTime() + 1000;
                
                    sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_gamble"),0, 1000, 
                        std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool));
                    
                }
                else
                {
                    //action costs
                    if(!ham->checkMainPools(0,mSampleActionCost*2,0))
                    {
                        gStateManager.setCurrentPostureState(player, CreaturePosture_Upright);
                        player->getSampleData()->mSampleEventFlag = false;
                        player->getSampleData()->mSampleGambleFlag = false;
                        gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_no_action"), player);
                        return;
                    }
//.........这里部分代码省略.........
开发者ID:ANHcRush,项目名称:mmoserver,代码行数:101,代码来源:ArtisanManager.cpp


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