本文整理汇总了C++中PlayerObject::getSurveyState方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::getSurveyState方法的具体用法?C++ PlayerObject::getSurveyState怎么用?C++ PlayerObject::getSurveyState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::getSurveyState方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleUIEvent
void TicketCollector::handleUIEvent(uint32 action,int32 element,BString inputStr,UIWindow* window)
{
if (!action && element != -1 && mShuttle != NULL && mShuttle->availableInPort())
{
uint32 zoneId = gWorldManager->getZoneId();
PlayerObject* playerObject = window->getOwner();
if(playerObject->getSurveyState() || playerObject->getSamplingState() || playerObject->isIncapacitated() || playerObject->isDead())
{
return;
}
// in range check
if(playerObject->getParentId() != mParentId || (glm::distance(playerObject->mPosition, this->mPosition) > 10.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())
{
if(TravelTicket* ticket = dynamic_cast<TravelTicket*>(gWorldManager->getObjectById((*it))))
{
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<uint16>(gWorldManager->getPlanetIdByName((int8*)((ticket->getAttribute<std::string>("travel_departure_planet")).c_str())));
uint16 dstPlanetId = static_cast<uint16>(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(srcPoint.getAnsi(),mPortDescriptor.getAnsi()) == 0)
&& (strcmp(dstPointStr.getAnsi(),selectedDst.getAnsi()) == 0))
{
if(TravelPoint* dstPoint = gTravelMapHandler->getTravelPoint(dstPlanetId,dstPointStr))
{
glm::vec3 destination;
// getRand(5) return 0-4, then sub 2, and you get equal of random values at both sides of zero. (-2, -1, 0, 1, 2)
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
{
DLOG(info) << "TicketCollector: Error getting TravelPoint";
}
break;
}
}
++it;
}
}
}
示例2: 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;
}
}
}
示例3: handleRequestSurvey
bool ArtisanManager::handleRequestSurvey(Object* playerObject,Object* target,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(playerObject);
std::shared_ptr<SimpleEvent> start_survey_event = nullptr;
if(cmdProperties)
mSurveyMindCost = cmdProperties->mMindCost;
// don't allow survey in buildings
if(player->getParentId())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_in_structure"), player);
return false;
}
if(player->GetCreature()->getPerformingState() != PlayerPerformance_None)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), player);
return false;
}
if(player->getSurveyState())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_cant"), player);
return false;
}
if(player->getSamplingState())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_sample"), player);
return false;
}
// checks if we are in combat, dead or incapacitated
if (player->GetCreature()->states.checkState(CreatureState_Combat) || player->GetCreature()->states.checkPosture(CreaturePosture_Dead) || player->GetCreature()->states.checkLocomotion(CreatureLocomotion_Incapacitated))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), player);
return false;
}
SurveyTool* tool = dynamic_cast<SurveyTool*>(target);
CurrentResource* resource = NULL;
BString resourceName;
message->getStringUnicode16(resourceName);
resourceName.convert(BSTRType_ANSI);
resource = reinterpret_cast<CurrentResource*>(gResourceManager->getResourceByNameCRC(resourceName.getCrc()));
if(tool && resource)
{
player->setSurveyState(true);
// play effect
std::string effect = gWorldManager->getClientEffect(tool->getInternalAttribute<uint32>("survey_effect"));
gMessageLib->sendPlayClientEffectLocMessage(effect,player->mPosition,player);
gContainerManager->sendToRegisteredWatchers(player, [effect, player] (PlayerObject* const recipient) {
gMessageLib->sendPlayClientEffectLocMessage(effect, player->mPosition, recipient);
});
auto ham = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::ham::HamService>("HamService");
uint32 survey_cost = mSurveyMindCost;
//are we able to sample in the first place ??
if(!ham->ApplyModifiedHamCosts(player->GetCreature(), 0, 0, survey_cost)) {
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "sample_mind"), player);
//message for stop sampling
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "sample_cancel"), player);
player->getSampleData()->mPendingSurvey = false;
player->GetCreature()->updateMovementProperties();
return false;
}
// send system message
resourceName.convert(BSTRType_Unicode16);
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "start_survey", L"", L"", resourceName.getUnicode16()), player);
// schedule execution
start_survey_event = std::make_shared<SimpleEvent>(EventType("start_survey"),0, 5000,
std::bind(&ArtisanManager::surveyEvent, this, player, resource, tool));
}
else
{
gMessageLib->SendSystemMessage(::common::OutOfBand("ui","survey_nothingfound"));
return false;
}
// notify any listeners
if (start_survey_event)
gEventDispatcher.Notify(start_survey_event);
return true;
}
示例4: handleRequestCoreSample
bool ArtisanManager::handleRequestCoreSample(Object* player,Object* target, Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(player);
if(cmdProperties)
// unfortunately it's not in this opcode
// hardcode for now
//mSampleActionCost = cmdProperties->mActionCost;
mSampleActionCost = 150;
if(playerObject->GetCreature()->getPerformingState() != PlayerPerformance_None || playerObject->checkIfMounted() || playerObject->GetCreature()->isDead() || playerObject->GetCreature()->states.checkState(CreatureState_Combat))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), playerObject);
return false;
}
// can't sample while surveying
if(playerObject->getSurveyState())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "sample_survey"), playerObject);
return false;
}
// don't allow sampling in buildings
if(playerObject->getParentId())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_in_structure"), playerObject);
return false;
}
uint64 localTime = Anh_Utils::Clock::getSingleton()->getLocalTime();
// don't allow more than one sample at a time
if(playerObject->getSamplingState())
{
playerObject->getSampleData()->mPendingSample = false;
playerObject->setNextSampleTime(localTime + 18000);
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "tool_recharge_time", 0, 0, 0, (int32)(playerObject->getNextSampleTime() - localTime) / 1000), playerObject);
return false;
}
if(!playerObject->getNextSampleTime() || (int32)(playerObject->getNextSampleTime() - localTime) <= 0)
{
playerObject->getSampleData()->mPendingSample = false;
playerObject->setNextSampleTime(localTime + 18000);
}
else
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "tool_recharge_time", 0, 0, 0, (int32)(playerObject->getNextSampleTime() - localTime) / 1000), playerObject);
return false;
}
SurveyTool* tool = dynamic_cast<SurveyTool*>(target);
CurrentResource* resource = NULL;
BString resourceName;
message->getStringUnicode16(resourceName);
resourceName.convert(BSTRType_ANSI);
resource = reinterpret_cast<CurrentResource*>(gResourceManager->getResourceByNameCRC(resourceName.getCrc()));
if(resource == NULL || tool == NULL)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("ui","survey_noresource"), playerObject);
return false;
}
if((resource->getType()->getCategoryId() == 903)||(resource->getType()->getCategoryId() == 904))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "must_have_harvester"), playerObject);
return false;
}
playerObject->setSamplingState(true);
auto terrain = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::terrain::TerrainService>("TerrainService");
if(terrain->IsWater(gWorldManager->getZoneId(), playerObject->mPosition.x, playerObject->mPosition.z))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_swimming"), playerObject);
return false;
}
resourceName.convert(BSTRType_Unicode16);
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "start_sampling", L"", L"", resourceName.getUnicode16()), playerObject);
// change posture
gStateManager.setCurrentPostureState(playerObject->GetCreature(), CreaturePosture_Crouched);
// play animation
gWorldManager->getClientEffect(tool->getInternalAttribute<uint32>("sample_effect"));
// schedule execution
std::shared_ptr<SimpleEvent> start_sample_event = nullptr;
start_sample_event = std::make_shared<SimpleEvent>(EventType("start_sample"), 0, 2000,
std::bind(&ArtisanManager::sampleEvent,this, playerObject, resource, tool));
// notify any listeners
gEventDispatcher.Notify(start_sample_event);
return true;
}
示例5: handleRequestSurvey
bool ArtisanManager::handleRequestSurvey(Object* playerObject,Object* target,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(playerObject);
std::shared_ptr<SimpleEvent> start_survey_event = nullptr;
if(cmdProperties)
mSurveyMindCost = cmdProperties->mMindCost;
// don't allow survey in buildings
if(player->getParentId())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_in_structure"), player);
return false;
}
if(player->getPerformingState() != PlayerPerformance_None)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), player);
return false;
}
if(player->getSurveyState())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_cant"), player);
return false;
}
if(player->getSamplingState())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_sample"), player);
return false;
}
SurveyTool* tool = dynamic_cast<SurveyTool*>(target);
CurrentResource* resource = NULL;
BString resourceName;
message->getStringUnicode16(resourceName);
resourceName.convert(BSTRType_ANSI);
resource = reinterpret_cast<CurrentResource*>(gResourceManager->getResourceByNameCRC(resourceName.getCrc()));
if(tool && resource)
{
player->setSurveyState(true);
// play effect
std::string effect = gWorldManager->getClientEffect(tool->getInternalAttribute<uint32>("survey_effect"));
gMessageLib->sendPlayClientEffectLocMessage(effect,player->mPosition,player);
PlayerObjectSet* playerList = player->getKnownPlayers();
PlayerObjectSet::iterator it = playerList->begin();
while(it != playerList->end())
{
gMessageLib->sendPlayClientEffectLocMessage(effect,player->mPosition,(*it));
++it;
}
uint32 mindCost = mSurveyMindCost;
Ham* hamz = player->getHam();
//are we able to sample in the first place ??
if(!hamz->checkMainPools(0,0,mindCost))
{
int32 myMind = hamz->mAction.getCurrentHitPoints();
//return message for sampling cancel based on HAM
if(myMind < (int32)mindCost)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "sample_mind"), player);
}
//message for stop sampling
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "sample_cancel"), player);
player->getSampleData()->mPendingSurvey = false;
hamz->updateRegenRates();
player->updateMovementProperties();
return false;
}
hamz->performSpecialAction(0,0,(float)mindCost,HamProperty_CurrentHitpoints);
// send system message
resourceName.convert(BSTRType_Unicode16);
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "start_survey", L"", L"", resourceName.getUnicode16()), player);
// schedule execution
start_survey_event = std::make_shared<SimpleEvent>(EventType("start_survey"),0, 5000,
std::bind(&ArtisanManager::surveyEvent, this, player, resource, tool));
}
else
{
gMessageLib->SendSystemMessage(::common::OutOfBand("ui","survey_nothingfound"));
return false;
}
// notify any listeners
if (start_survey_event)
gEventDispatcher.Notify(start_survey_event);
return true;
}
示例6: handleRequestCoreSample
bool ArtisanManager::handleRequestCoreSample(Object* player,Object* target, Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(player);
if(cmdProperties)
// unfortunately it's not in this opcode
// hardcode for now
//mSampleActionCost = cmdProperties->mActionCost;
mSampleActionCost = 150;
if(playerObject->getPerformingState() != PlayerPerformance_None || playerObject->checkIfMounted() || playerObject->isDead())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), playerObject);
return false;
}
// can't sample while surveying
if(playerObject->getSurveyState())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "sample_survey"), playerObject);
return false;
}
// don't allow sampling in buildings
if(playerObject->getParentId())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_in_structure"), playerObject);
return false;
}
uint64 localTime = Anh_Utils::Clock::getSingleton()->getLocalTime();
// don't allow more than one sample at a time
if(playerObject->getSamplingState())
{
playerObject->getSampleData()->mPendingSample = false;
playerObject->setNextSampleTime(localTime + 18000);
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "tool_recharge_time", 0, 0, 0, (int32)(playerObject->getNextSampleTime() - localTime) / 1000), playerObject);
return false;
}
if(!playerObject->getNextSampleTime() || (int32)(playerObject->getNextSampleTime() - localTime) <= 0)
{
playerObject->getSampleData()->mPendingSample = false;
playerObject->setNextSampleTime(localTime + 18000);
}
else
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "tool_recharge_time", 0, 0, 0, (int32)(playerObject->getNextSampleTime() - localTime) / 1000), playerObject);
return false;
}
SurveyTool* tool = dynamic_cast<SurveyTool*>(target);
CurrentResource* resource = NULL;
BString resourceName;
message->getStringUnicode16(resourceName);
resourceName.convert(BSTRType_ANSI);
resource = reinterpret_cast<CurrentResource*>(gResourceManager->getResourceByNameCRC(resourceName.getCrc()));
if(resource == NULL || tool == NULL)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("ui","survey_noresource"), playerObject);
return false;
}
if((resource->getType()->getCategoryId() == 903)||(resource->getType()->getCategoryId() == 904))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "must_have_harvester"), playerObject);
return false;
}
playerObject->setSamplingState(true);
ArtisanHeightmapAsyncContainer* container = new ArtisanHeightmapAsyncContainer(this, HeightmapCallback_ArtisanSurvey);
container->addToBatch(playerObject->mPosition.x,playerObject->mPosition.z);
container->playerObject = playerObject;
container->resource = resource;
container->resourceName = resourceName;
container->tool = tool;
gHeightmap->addNewHeightMapJob(container);
return true;
}