本文整理汇总了C++中PlayerObject::getSampleData方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::getSampleData方法的具体用法?C++ PlayerObject::getSampleData怎么用?C++ PlayerObject::getSampleData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::getSampleData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: handleUIEvent
void ArtisanManager::handleUIEvent(uint32 action,int32 element,std::u16string inputStr,UIWindow* window, std::shared_ptr<WindowAsyncContainerCommand> AsyncContainer)
{
PlayerObject* player = window->getOwner();
std::shared_ptr<SimpleEvent> sample_UI_event = nullptr;
if(!player) {
DLOG(error) << "ArtisanManager::handleUIEvent :: no player";
return;
}
auto equip_service = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::equipment::EquipmentService>("EquipmentService");
auto inventory = dynamic_cast<Inventory*>(equip_service->GetEquippedObject(player->GetCreature(), "inventory"));
if(!inventory) {
DLOG(error) << "ArtisanManager::handleUIEvent :: no inventory";
return;
}
if(!AsyncContainer) {
DLOG(error) << "ArtisanManager::handleUIEvent :: no asynccontainer";
return;
}
switch(window->getWindowType())
{
// Sampling Radioactive Msg Box
case SUI_Window_SmplRadioactive_MsgBox:
{
auto ham = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::ham::HamService>("HamService");
//we stopped the sampling
if(action == 1)
{
player->getSampleData()->mPassRadioactive = false;
player->getSampleData()->mPendingSample = false;
gStateManager.setCurrentPostureState(player->GetCreature(), CreaturePosture_Upright);
return;
}
else
{
player->getSampleData()->mPassRadioactive = true;
player->getSampleData()->mPendingSample = true;
if(ham->checkMainPool(player->GetCreature(), HamBar_Action, mSampleActionCost*2))
{
SurveyTool* tool = dynamic_cast<SurveyTool*>(gWorldManager->getObjectById(AsyncContainer->ToolId));
CurrentResource* resource = (CurrentResource*)AsyncContainer->CurrentResource;
player->getSampleData()->mNextSampleTime = Anh_Utils::Clock::getSingleton()->getStoredTime() + 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:
{
auto ham = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::ham::HamService>("HamService");
//action == 1 is cancel
if(action == 1)
{
player->getSampleData()->mPendingSample = false;
player->getSampleData()->mSampleGambleFlag = false;
gStateManager.setCurrentPostureState(player->GetCreature(), CreaturePosture_Upright);
player->GetCreature()->updateMovementProperties();
gMessageLib->sendUpdateMovementProperties(player);
gMessageLib->sendPostureAndStateUpdate(player->GetCreature());
return;
}
else
{
if(element == 0)
{
player->getSampleData()->mPendingSample = true;
player->getSampleData()->mSampleGambleFlag = false;
SurveyTool* tool = dynamic_cast<SurveyTool*>(gWorldManager->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->checkMainPool(player->GetCreature(), HamBar_Action ,mSampleActionCost*2))
{
//.........这里部分代码省略.........
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
//.........这里部分代码省略.........
示例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;
}