本文整理汇总了C++中PlayerObject::getNextSampleTime方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::getNextSampleTime方法的具体用法?C++ PlayerObject::getNextSampleTime怎么用?C++ PlayerObject::getNextSampleTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::getNextSampleTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}