本文整理汇总了C++中PlayerObject::getDataPad方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::getDataPad方法的具体用法?C++ PlayerObject::getDataPad怎么用?C++ PlayerObject::getDataPad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::getDataPad方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _handleRequestWaypointAtPosition
void ObjectController::_handleRequestWaypointAtPosition(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
Datapad* datapad = player->getDataPad();
//if(!datapad->getCapacity())
//{
// gMessageLib->sendSystemMessage(player,L"","base_player","too_many_waypoints");
// return;
//}
BStringVector dataElements;
BString dataStr;
std::string nameStr;
message->getStringUnicode16(dataStr);
// Have to convert BEFORE using split, since the conversion done there is removed It will assert().. evil grin...
// Either do the conversion HERE, or better fix the split so it handles unicoe also.
dataStr.convert(BSTRType_ANSI);
uint32 elementCount = dataStr.split(dataElements,' ');
if(elementCount < 5)
{
if(elementCount < 4)
{
return;
}
else
{
nameStr = gWorldManager->getPlanetNameThis();
std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), &tolower);
}
}
else
{
for(uint i = 4; i < elementCount; i++)
{
nameStr.append(dataElements[i].getAnsi());
if(i + 1 < elementCount)
nameStr.append(" ");
}
}
BString planetStr = dataElements[0].getAnsi();
//gLogger->log(LogManager::DEBUG,"ObjController::handleCreateWaypointAtPosition: planet %s",planetStr.getAnsi());
float x = static_cast<float>(atof(dataElements[1].getAnsi()));
float y = static_cast<float>(atof(dataElements[2].getAnsi()));
float z = static_cast<float>(atof(dataElements[3].getAnsi()));
int32 planetId = gWorldManager->getPlanetIdByName(planetStr);
if(planetId == -1)
{
return;
}
datapad->requestNewWaypoint(nameStr.c_str(), glm::vec3(x,y,z),static_cast<uint16>(planetId),Waypoint_blue);
}
示例2: _handleSetWaypointName
void ObjectController::_handleSetWaypointName(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
BString name;
Datapad* datapad = player->getDataPad();
WaypointObject* waypoint = datapad->getWaypointById(targetId);
int8 sql[1024],restStr[64],*sqlPointer;
if(waypoint == NULL)
{
DLOG(info) << "ObjController::handlesetwaypointname: could not find waypoint "<< targetId;
return;
}
message->getStringUnicode16(name);
if(!(name.getLength()))
return;
waypoint->setName(name);
name.convert(BSTRType_ANSI);
sprintf(sql,"UPDATE %s.waypoints SET name='",mDatabase->galaxy());
sqlPointer = sql + strlen(sql);
sqlPointer += mDatabase->escapeString(sqlPointer,name.getAnsi(),name.getLength());
sprintf(restStr,"' WHERE waypoint_id=%" PRIu64 "",targetId);
strcat(sql,restStr);
mDatabase->executeSqlAsync(NULL,NULL,sql);
gMessageLib->sendUpdateWaypoint(waypoint,ObjectUpdateChange,player);
}
示例3: _handleWaypoint
void ObjectController::_handleWaypoint(uint64 targetId, Message* message, ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
Datapad* datapad = player->getDataPad();
BString waypoint_data;
glm::vec3 waypoint_position;
// Before anything else verify the datapad can hold another waypoint.
if(! datapad->getCapacity()) {
gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "too_many_waypoints"), player);
return;
}
// Read in any waypoint data that may have been sent:
// [SYNTAX] /waypoint <x> <z> or /waypoint <x> <y> <z>
message->getStringUnicode16(waypoint_data);
// Check and see if any parameters were passed to the /waypoint command. For
// immediate purposes the length can be used to tell if anything or nothing was passed.
if (waypoint_data.getLength()) {
int count = swscanf(waypoint_data.getUnicode16(), L"%f %f %f", &waypoint_position.x, &waypoint_position.y, &waypoint_position.z);
// If there are an invalid number of items then disregard and notify the player of the correct
// format for the /waypoint command.
if (count < 2 || count > 3) {
gMessageLib->SendSystemMessage(L"[SYNTAX] /waypoint <x> <z> or /waypoint <x> <y> <z>", player);
return;
}
// If the item count is 2 it means no y value was set in the /waypoint command so
// update the waypoint_position data values accordingly.
if (count == 2) {
waypoint_position.z = waypoint_position.y;
waypoint_position.y = 0;
}
// Validate the position values.
if (waypoint_position.x < -8192 || waypoint_position.x > 8192 ||
waypoint_position.y < -500 || waypoint_position.y > 500 ||
waypoint_position.z < -8192 || waypoint_position.z > 8192) {
gMessageLib->SendSystemMessage( L"[SYNTAX] Invalid range for /waypoint. x = -8192/8192 y = -500/500 z = -8192/8192", player);
return;
}
} else {
// If no parameters were passed to the /waypoint command use the current world position.
waypoint_position = player->getWorldPosition();
}
datapad->requestNewWaypoint("Waypoint", waypoint_position, static_cast<uint16>(gWorldManager->getZoneId()), Waypoint_blue);
}
示例4: _handleSetWaypointActiveStatus
void ObjectController::_handleSetWaypointActiveStatus(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
WaypointObject* waypoint = NULL;
Datapad* datapad = player->getDataPad();
waypoint = datapad->getWaypointById(targetId);
if(waypoint)
{
waypoint->toggleActive();
mDatabase->executeSqlAsync(0,0,"UPDATE %s.waypoints set active=%u WHERE waypoint_id=%" PRIu64 "",mDatabase->galaxy(),(uint8)waypoint->getActive(),targetId);
}
else
{
DLOG(info) << "ObjController::handleSetWaypointStatus: could not find waypoint " << targetId;
}
}
示例5: handleDatabaseJobComplete
void DatapadFactory::handleDatabaseJobComplete(void* ref,DatabaseResult* result)
{
QueryContainerBase* asyncContainer = reinterpret_cast<QueryContainerBase*>(ref);
switch(asyncContainer->mQueryType)
{
case DPFQuery_MainDatapadData:
{
//get the count of all Waypoints and Schematics
Datapad* datapad = _createDatapad(result);
QueryContainerBase* asContainer = new(mQueryContainerPool.ordered_malloc()) QueryContainerBase(asyncContainer->mOfCallback,DPFQuery_ObjectCount,asyncContainer->mClient);
asContainer->mObject = datapad;
mDatabase->executeSqlAsync(this,asContainer,"SELECT %s.sf_getDatapadObjectCount(%" PRIu64 ")",mDatabase->galaxy(),datapad->getId());
}
break;
case DPFQuery_ObjectCount:
{
Datapad* datapad = dynamic_cast<Datapad*>(asyncContainer->mObject);
uint32 objectCount;
DataBinding* binding = mDatabase->createDataBinding(1);
binding->addField(DFT_uint32,0,4);
result->getNextRow(binding,&objectCount);
datapad->setObjectLoadCounter(objectCount);
if(objectCount != 0)
{
uint64 dtpId = datapad->getId();
datapad->setLoadState(LoadState_Loading);
// query contents
QueryContainerBase* asContainer = new(mQueryContainerPool.ordered_malloc()) QueryContainerBase(asyncContainer->mOfCallback,DPFQuery_Objects,asyncContainer->mClient);
asContainer->mObject = datapad;
mDatabase->executeSqlAsync(this,asContainer,
"(SELECT \'waypoints\',waypoints.waypoint_id FROM %s.waypoints WHERE owner_id = %" PRIu64 ")"
" UNION (SELECT \'manschematics\',items.id FROM %s.items WHERE (parent_id=%" PRIu64 "))"
" UNION (SELECT \'vehicles\',vehicles.id FROM %s.vehicles WHERE (parent=%" PRIu64 "))",
mDatabase->galaxy(),dtpId-3,
mDatabase->galaxy(),dtpId,
mDatabase->galaxy(),dtpId);
}
else
{
datapad->setLoadState(LoadState_Loaded);
asyncContainer->mOfCallback->handleObjectReady(datapad,asyncContainer->mClient);
}
mDatabase->destroyDataBinding(binding);
}
break;
case DPFQuery_ItemId:
{
uint64 id;
DataBinding* binding = mDatabase->createDataBinding(1);
binding->addField(DFT_uint64,0,8);
result->getNextRow(binding,&id);
gTangibleFactory->requestObject(this,id,TanGroup_Item,0,asyncContainer->mClient);
mDatabase->destroyDataBinding(binding);
}
break;
case DPFQuery_MSParent:
{
uint64 id;
DataBinding* binding = mDatabase->createDataBinding(1);
binding->addField(DFT_uint64,0,8);
result->getNextRow(binding,&id);
PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(id-3));
if(!player)
{
//factoryPanic!!!!!!!!
LOG(warning) << "Failed getting player to create MS";
return;
}
Datapad* datapad = player->getDataPad();
if(!datapad)
{
//factoryPanic!!!!!!!!
LOG(error) << "Failed getting datapad to create MS";
return;
}
mObjectLoadMap.insert(std::make_pair(datapad->getId(),new(mILCPool.ordered_malloc()) InLoadingContainer(datapad,datapad,NULL,1)));
gTangibleFactory->requestObject(this,asyncContainer->mId,TanGroup_Item,0,NULL);
//.........这里部分代码省略.........
示例6: 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())
{
LOG(ERROR) << "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)
{
LOG(ERROR) << "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);
Deed* deed = dynamic_cast<Deed*>(gWorldManager->getObjectById(asyncContainer->DeedId));
ObjectContainer* tO = dynamic_cast<ObjectContainer*>(gWorldManager->getObjectById(deed->getParentId()));
//destroy it in the client
gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);
//delete it out of the inventory
tO->deleteObject(deed);
Datapad* datapad = player->getDataPad();
datapad->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 = %"PRIu64" 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())
{
LOG(ERROR) << "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)
{
LOG(ERROR) << "Create factor 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);
Deed* deed = dynamic_cast<Deed*>(gWorldManager->getObjectById(asyncContainer->DeedId));
//destroy it in the client
gMessageLib->sendDestroyObject(asyncContainer->DeedId,player);
//delete it out of the container
ObjectContainer* tO = dynamic_cast<ObjectContainer*>(gWorldManager->getObjectById(deed->getParentId()));
tO->deleteObject(deed);
Datapad* datapad = player->getDataPad();
datapad->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 = %"PRIu64" WHERE id = %"PRIu64"",requestId, asyncContainer->DeedId);
mDatabase->executeSqlAsync(NULL,NULL,sql);
//.........这里部分代码省略.........
示例7: handleDatabaseJobComplete
void Tutorial::handleDatabaseJobComplete(void* ref,swganh::database::DatabaseResult* result)
{
TutorialQueryContainer* asyncContainer = reinterpret_cast<TutorialQueryContainer*>(ref);
switch(asyncContainer->mQueryType)
{
case TutorialQuery_MainData:
{
swganh::database::DataBinding* binding = gWorldManager->getKernel()->GetDatabase()->createDataBinding(3);
binding->addField(swganh::database::DFT_uint32,offsetof(Tutorial,mState),4,0);
binding->addField(swganh::database::DFT_int32,offsetof(Tutorial,mSubState),4,1);
binding->addField(swganh::database::DFT_bstring,offsetof(Tutorial,mStartingProfession),64,2);
uint64 count = result->getRowCount();
if (count == 1)
{
result->getNextRow(binding,this);
}
else if (count == 0)
{
// First time, no tutorial data saved.
mSubState = 1;
mState = 1;
// Save the state.
(gWorldManager->getKernel()->GetDatabase())->executeSqlAsync(0,0,"INSERT INTO %s.character_tutorial VALUES (%"PRIu64",%u,%u)",gWorldManager->getKernel()->GetDatabase()->galaxy(),asyncContainer->mId,mState, mSubState);
}
gWorldManager->getKernel()->GetDatabase()->destroyDataBinding(binding);
// Here we go...
this->startScript();
}
break;
case TutorialQuery_PlanetLocation:
{
PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asyncContainer->mId));
if (player)
{
swganh::database::DataBinding* binding = gWorldManager->getKernel()->GetDatabase()->createDataBinding(4);
TutorialStartingLocation startingLocation;
binding->addField(swganh::database::DFT_uint32, offsetof(TutorialStartingLocation, destinationPlanet), 4, 0);
binding->addField(swganh::database::DFT_float, offsetof(TutorialStartingLocation, destX), 4, 1);
binding->addField(swganh::database::DFT_float, offsetof(TutorialStartingLocation, destY), 4, 2);
binding->addField(swganh::database::DFT_float, offsetof(TutorialStartingLocation, destZ), 4, 3);
result->getNextRow(binding, &startingLocation);
startingLocation.destX += (gRandom->getRand()%5 - 2);
startingLocation.destZ += (gRandom->getRand()%5 - 2);
gMessageLib->sendClusterZoneTransferRequestByPosition(player,
glm::vec3(startingLocation.destX, startingLocation.destY, startingLocation.destZ),
startingLocation.destinationPlanet);
// create waypoint at starting location.
glm::vec3 position;
position.x = startingLocation.destX;
position.z = startingLocation.destZ;
Datapad* datapad = player->getDataPad();
std::string name("@ui:cpt_avatar_location");
std::u16string name_u16(name.begin(), name.end());
std::shared_ptr<WaypointObject> wp = datapad->getWaypointByName(name_u16);
if(wp)
{
datapad->RemoveWaypoint(wp->getId());
}
datapad->requestNewWaypoint(name_u16, position, startingLocation.destinationPlanet, Waypoint_blue);
//send starting emails
sendStartingMails();
}
else
{
}
}
break;
default:
{
}
break;
}
delete asyncContainer;
}
示例8: _handleGetAttributesBatch
void ObjectController::_handleGetAttributesBatch(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
BString requestStr;
BStringVector dataElements;
BStringVector dataElements2;
uint16 elementCount;
message->getStringUnicode16(requestStr);
requestStr.convert(BSTRType_ANSI);
requestStr.getRawData()[requestStr.getLength()] = 0;
elementCount = requestStr.split(dataElements,' ');
if(!elementCount)
{
return;
}
Message* newMessage;
for(uint16 i = 0; i < elementCount; i++)
{
uint64 itemId = boost::lexical_cast<uint64>(dataElements[i].getAnsi());
Object* object = gWorldManager->getObjectById(itemId);
if(object == NULL)
{
// could be a resource
Resource* resource = gResourceManager->getResourceById(itemId);
if(resource != NULL)
{
resource->sendAttributes(playerObject);
continue;
}
//could be a schematic!
Datapad* datapad = playerObject->getDataPad();
ManufacturingSchematic* schem = datapad->getManufacturingSchematicById(itemId);
if(schem != NULL)
{
schem->sendAttributes(playerObject);
continue;
}
MissionObject* mission = datapad->getMissionById(itemId);
if(mission != NULL)
{
mission->sendAttributes(playerObject);
continue;
}
IntangibleObject* data = datapad->getDataById(itemId);
if(data != NULL)
{
data->sendAttributes(playerObject);
continue;
}
// TODO: check our datapad items
if(playerObject->isConnected())
{
// default reply for schematics
gMessageFactory->StartMessage();
gMessageFactory->addUint32(opAttributeListMessage);
gMessageFactory->addUint64(itemId);
gMessageFactory->addUint32(0);
//gMessageFactory->addUint16(0);
//gMessageFactory->addUint32(40);
newMessage = gMessageFactory->EndMessage();
(playerObject->getClient())->SendChannelAUnreliable(newMessage, playerObject->getAccountId(), CR_Client, 8);
}
//finally, when we are crafting this could be the new item, not yet added to the worldmanager??
if(playerObject->getCraftingSession())
{
if(playerObject->getCraftingSession()->getItem()&&playerObject->getCraftingSession()->getItem()->getId() == itemId)
{
playerObject->getCraftingSession()->getItem()->sendAttributes(playerObject);
}
}
}
else
{
// Tutorial: I (Eru) have to do some hacks here, since I don't know how to get the info of what object the client has selected (by single click) in the Inventory.
if (gWorldConfig->isTutorial())
{
// Let's see if the actual object is the food item "Melon" in our inventory.
if (dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getId() == object->getParentId())
{
//uint64 id = object->getId();
// Is it an Item?
Item* item = dynamic_cast<Item*>(object);
//.........这里部分代码省略.........
示例9: destroyObject
void ObjectController::destroyObject(uint64 objectId)
{
CreatureObject* creature = dynamic_cast<CreatureObject*>(mObject); PlayerObject* playerObject = creature->GetGhost();
Datapad* datapad = playerObject->getDataPad();
Object* object = gWorldManager->getObjectById(objectId);
auto equip_service = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::equipment::EquipmentService>("EquipmentService");
auto inventory = dynamic_cast<Inventory*>(equip_service->GetEquippedObject(playerObject->GetCreature(), "inventory"));
//could be a schematic!
ManufacturingSchematic* schem = datapad->getManufacturingSchematicById(objectId);
if(schem != NULL)
{
//delete schematic
datapad->removeManufacturingSchematic(objectId);
//delete schematic object
gObjectFactory->deleteObjectFromDB(schem);
gMessageLib->sendDestroyObject(objectId,playerObject);
return;
}
// or something else
if(object == NULL)
{
DLOG(info) << "ObjController::destroyObject: could not find object " << objectId;
return;
}
// waypoint
if(object->getType() == ObjType_Waypoint)
{
// delete from db
gObjectFactory->deleteObjectFromDB(object);
if(!datapad) {
LOG(error) << "ObjectController::destroyObject cant get datapad to destroy waypoint : " << object->getId();
return;
}
datapad->RemoveWaypoint(object->getId());
//remove from grid and/or container
gWorldManager->destroyObject(object);
}
//Inangible Objects
if(object->getType() == ObjType_Intangible)
{
gObjectFactory->deleteObjectFromDB(object);
//remove from grid and/or container
gWorldManager->destroyObject(object);
}
// tangible
else if(object->getType() == ObjType_Tangible)
{
TangibleObject* tangibleObject = dynamic_cast<TangibleObject*>(object);
auto equip_service = gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::equipment::EquipmentService>("EquipmentService");
auto inventory = dynamic_cast<Inventory*>(equip_service->GetEquippedObject(playerObject->GetCreature(), "inventory"));
// items
if(Item* item = dynamic_cast<Item*>(tangibleObject))
{
// handle any family specifics
switch(item->getItemFamily())
{
case ItemFamily_CraftingTools: _handleDestroyCraftingTool(dynamic_cast<CraftingTool*>(item)); break;
case ItemFamily_Instrument: _handleDestroyInstrument(item); break;
default:break;
}
}
// reset pending ui callbacks
playerObject->resetUICallbacks(object);
// delete from db CAVE :: mark if its an Object saved in the db!!!!
// temporary placed instruments are not saved in the db
gObjectFactory->deleteObjectFromDB(object);
//remove from grid and/or container and/or World
gWorldManager->destroyObject(object);
}
//.........这里部分代码省略.........
示例10: handleUIEvent
//.........这里部分代码省略.........
{
//action costs
if(!ham->checkMainPool(player->GetCreature(), HamBar_Action ,mSampleActionCost*2))
{
gStateManager.setCurrentPostureState(player->GetCreature(), CreaturePosture_Upright);
player->getSampleData()->mSampleEventFlag = false;
player->getSampleData()->mSampleGambleFlag = false;
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_no_action"), player);
return;
}
player->getSampleData()->mPendingSample = true;
//determine whether gamble is good or not
int32 gambleRoll = int(gRandom->getRand()%2) + 1;
if(gambleRoll == 1)
{
player->getSampleData()->mSampleEventFlag = true;
player->getSampleData()->mSampleGambleFlag = true;
}
else
{
player->getSampleData()->mSampleEventFlag = false;
player->getSampleData()->mSampleGambleFlag = false;
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_fail"), player);
}
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));
}
}
}
break;
case SUI_Window_SmplWaypNode_ListBox:
{
if(action == 0)
{
//we hit ok and went for the wp
if(element == 1)
{
player->getSampleData()->mPendingSample = false;
player->getSampleData()->mSampleNodeFlag = true;
player->getSampleData()->Position.x = player->mPosition.x +(((gRandom->getRand()%50)+1));
player->getSampleData()->Position.z = player->mPosition.z +(((gRandom->getRand()%50)+1));
player->getSampleData()->zone = gWorldManager->getZoneId();
player->getSampleData()->resource = (CurrentResource*)AsyncContainer->CurrentResource;
Datapad* datapad = player->getDataPad();
std::string name("Resource Node");
std::u16string name_u16 (name.begin(), name.end());
datapad->requestNewWaypoint(name_u16, player->getSampleData()->Position ,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "node_waypoint"), player);
gStateManager.setCurrentPostureState(player->GetCreature(), CreaturePosture_Upright);
return;
}
//we ignored the node - so continue sampling
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() + 10000;
sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_continue"),0, 10000,
std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool));
}
}
else
{
player->getSampleData()->mPendingSample = false;
player->getSampleData()->mSampleNodeFlag = false;
player->getSampleData()->Position.x = 0;
player->getSampleData()->Position.z = 0;
player->getSampleData()->resource = NULL;
player->getSampleData()->zone = 0;
gStateManager.setCurrentPostureState(player->GetCreature(), CreaturePosture_Upright);
return;
}
}
break;
}
//notify the listeners
if (sample_UI_event)
gEventDispatcher.Notify(sample_UI_event);
}
示例11: handleUIEvent
//.........这里部分代码省略.........
}
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;
}
player->getSampleData()->mPendingSample = true;
//determine whether gamble is good or not
int32 gambleRoll = int(gRandom->getRand()%2) + 1;
if(gambleRoll == 1)
{
player->getSampleData()->mSampleEventFlag = true;
player->getSampleData()->mSampleGambleFlag = true;
}
else
{
player->getSampleData()->mSampleEventFlag = false;
player->getSampleData()->mSampleGambleFlag = false;
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_fail"), player);
}
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));
}
}
}
break;
case SUI_Window_SmplWaypNode_ListBox:
{
if(action == 0)
{
//we hit ok and went for the wp
if(element == 1)
{
player->getSampleData()->mPendingSample = false;
player->getSampleData()->mSampleNodeFlag = true;
player->getSampleData()->Position.x = player->mPosition.x +(((gRandom->getRand()%50)+1));
player->getSampleData()->Position.z = player->mPosition.z +(((gRandom->getRand()%50)+1));
player->getSampleData()->zone = gWorldManager->getZoneId();
player->getSampleData()->resource = (CurrentResource*)asyncContainer->CurrentResource;
Datapad* datapad = player->getDataPad();
datapad->requestNewWaypoint("Resource Node", player->getSampleData()->Position ,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "node_waypoint"), player);
gStateManager.setCurrentPostureState(player, CreaturePosture_Upright);
return;
}
//we ignored the node - so continue sampling
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() + 10000;
sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_continue"),0, 10000,
std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool));
}
}
else
{
player->getSampleData()->mPendingSample = false;
player->getSampleData()->mSampleNodeFlag = false;
player->getSampleData()->Position.x = 0;
player->getSampleData()->Position.z = 0;
player->getSampleData()->resource = NULL;
player->getSampleData()->zone = 0;
gStateManager.setCurrentPostureState(player, CreaturePosture_Upright);
return;
}
}
break;
}
//notify the listeners
if (sample_UI_event)
gEventDispatcher.Notify(sample_UI_event);
SAFE_DELETE(asyncContainer);
}