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


C++ Shuttle::availableInPort方法代码示例

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


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

示例1: handleUIEvent

void TravelMapHandler::handleUIEvent(uint32 action,int32 element,BString inputStr,UIWindow* window)
{
    if(!action && element != -1 )
    {
        uint32					zoneId			= gWorldManager->getZoneId();
        PlayerObject*			playerObject	= window->getOwner();
        UITicketSelectListBox*	listBox			= dynamic_cast<UITicketSelectListBox*>(window);

        if(playerObject->getSurveyState() || playerObject->getSamplingState() || !listBox)
            return;

        Shuttle* shuttle = listBox->getShuttle();

        if(!shuttle)
        {
            return;
        }

        if (!shuttle->availableInPort())
        {
            gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "shuttle_not_available"), playerObject);
            return;
        }

        if((playerObject->getParentId() != shuttle->getParentId()) || (glm::distance(playerObject->mPosition, shuttle->mPosition) > 25.0f))
        {
            gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "boarding_too_far"), playerObject);

            return;
        }

        ObjectIDList*			invObjects		= dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getObjects();
        ObjectIDList::iterator	it				= invObjects->begin();

        while(it != invObjects->end())
        {
            TravelTicket* ticket = dynamic_cast<TravelTicket*>(gWorldManager->getObjectById((*it)));
            if(ticket)
            {
                BString srcPoint		= (int8*)((ticket->getAttribute<std::string>("travel_departure_point")).c_str());
                BString dstPointStr	= (int8*)((ticket->getAttribute<std::string>("travel_arrival_point")).c_str());
                uint16 srcPlanetId	= static_cast<uint8>(gWorldManager->getPlanetIdByName((int8*)((ticket->getAttribute<std::string>("travel_departure_planet")).c_str())));
                uint16 dstPlanetId	= static_cast<uint8>(gWorldManager->getPlanetIdByName((int8*)((ticket->getAttribute<std::string>("travel_arrival_planet")).c_str())));

                BStringVector* items = (dynamic_cast<UIListBox*>(window))->getDataItems();
                BString selectedDst = items->at(element);
                selectedDst.convert(BSTRType_ANSI);

                if(srcPlanetId == zoneId && (strcmp(dstPointStr.getAnsi(),selectedDst.getAnsi()) == 0)&&(strcmp(srcPoint.getAnsi(),listBox->getPort().getAnsi()) == 0))
                {
                    TravelPoint* dstPoint = gTravelMapHandler->getTravelPoint(dstPlanetId,dstPointStr);

                    if(dstPoint != NULL)
                    {
                        glm::vec3 destination;
                        destination.x = dstPoint->spawnX + (gRandom->getRand()%5 - 2);
                        destination.y = dstPoint->spawnY;
                        destination.z = dstPoint->spawnZ + (gRandom->getRand()%5 - 2);

                        // If it's on this planet, then just warp, otherwize zone
                        if(dstPlanetId == zoneId)
                        {
                            // only delete the ticket if we are warping on this planet.
							TangibleObject* tO = dynamic_cast<TangibleObject*>(gWorldManager->getObjectById(ticket->getParentId()));
							gContainerManager->deleteObject(ticket, tO);

							gWorldManager->warpPlanet(playerObject,destination,0);
                        }
                        else
                        {
                            gMessageLib->sendClusterZoneTransferRequestByTicket(playerObject,ticket->getId(), dstPoint->planetId);
                        }
                    }
                    else
                    {
                    }
                    break;
                }
            }
            ++it;
        }
    }
}
开发者ID:gregomy,项目名称:mmoserver,代码行数:83,代码来源:TravelMapHandler.cpp


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