本文整理汇总了C++中PlayerObject::getWorldPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::getWorldPosition方法的具体用法?C++ PlayerObject::getWorldPosition怎么用?C++ PlayerObject::getWorldPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::getWorldPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _processIsmGroupInviteInRangeRequest
void GroupManager::_processIsmGroupInviteInRangeRequest(Message *message)
{
PlayerObject* sender = gWorldManager->getPlayerByAccId(message->getUint32());
PlayerObject* target = gWorldManager->getPlayerByAccId(message->getUint32());
Message* newMessage = new Message();
if( sender == NULL || target == NULL )
{
gLogger->logMsg("GroupManager::_processIsmInviteInRangeRequest player not found");
return;
}
if (glm::distance(sender->getWorldPosition(), target->getWorldPosition()) < 90)
{
gMessageLib->sendIsmGroupInviteInRangeResponse(sender, target, true);
}
else
{
gMessageLib->sendIsmGroupInviteInRangeResponse(sender, target, false);
}
}
示例2: _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);
}
示例3: _handleNPCConversationStart
void ObjectController::_handleNPCConversationStart(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
NPCObject* npc = dynamic_cast<NPCObject*>(gWorldManager->getObjectById(targetId));
if(!npc)
{
DLOG(info) << "ObjController::_handleNPCConversationStart: Couldn't find object " << targetId;
return;
}
// in range check
uint64 playerParentId = player->getParentId();
uint64 npcParentId = npc->getParentId();
bool inRange = true;
uint64 playerBuildingId = 0;
uint64 npcBuildingId = 0;
//get building Ids if they are in buildings
if(playerParentId)
{
playerBuildingId = gWorldManager->getObjectById(playerParentId)->getParentId();
}
if(npcParentId)
{
npcBuildingId = gWorldManager->getObjectById(npcParentId)->getParentId();
}
// not inside same parent, or out of range
float distance = glm::distance(player->getWorldPosition(), npc->getWorldPosition());
if ((npcBuildingId != playerParentId) || distance > 10.0f)
{
inRange = false;
}
// we are out of range
if(!inRange)
{
float distance = glm::distance(player->mPosition, npc->mPosition);
char buffer[100];
sprintf(buffer, "You are out of range (%f m).", distance);
BString msg(buffer);
msg.convert(BSTRType_Unicode16);
gMessageLib->SendSystemMessage(msg.getUnicode16(), player);
// gMessageLib->sendSystemMessage(player,L"","system_msg","out_of_range");
return;
}
//check to see if he is part of a mission
/*if(gMissionManager->checkDeliverMission(player,npc) ||
gMissionManager->checkCraftingMission(player,npc)
) return;*/
// we don't want him to talk
if(npc->hasInternalAttribute("no_chat"))
return;
// initiate a conversation dialog
if(npc->hasInternalAttribute("base_conversation"))
{
// Let the npc have your attention, and some npc-movement.
npc->prepareConversation(player);
gConversationManager->startConversation(npc,player);
}
// say some chatter
else
{
// spam protection
uint64 localTime = Anh_Utils::Clock::getSingleton()->getLocalTime();
if(npc->getLastConversationTarget() == player->getId())
{
if(localTime - npc->getLastConversationRequest() < NPC_CHAT_SPAM_PROTECTION_TIME)
{
return;
}
else
{
npc->setLastConversationRequest(localTime);
}
}
else
{
npc->setLastConversationRequest(localTime);
npc->setLastConversationTarget(player->getId());
}
// Let the npc have your attention, and some npc-movement.
// Nope... npc->prepareConversation(player);
std::wstring npc_chat;
uint32_t animation = 0;
// say a specific preset sentence
if(npc->hasInternalAttribute("npc_chat")) {
std::string tmp = npc->getInternalAttribute<std::string>("npc_chat");
npc_chat = std::wstring(tmp.begin(), tmp.end());
} else {
std::pair<std::wstring,uint32> chat = gWorldManager->getRandNpcChatter();
//.........这里部分代码省略.........
示例4: _handleOpenContainer
//=============================================================================
//
// open container
//
void ObjectController::_handleOpenContainer(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
Object* itemObject = gWorldManager->getObjectById(targetId);
if (itemObject)
{
if(glm::distance(playerObject->getWorldPosition(), itemObject->getWorldPosition()) > 10)
{
gMessageLib->SendSystemMessage(L"", playerObject, "system_msg", "out_of_range");
return;
}
bool aContainer = false;
if (gWorldConfig->isTutorial())
{
playerObject->getTutorial()->containerOpen(targetId);
}
if (itemObject->getType() == ObjType_Tangible)
{
TangibleObject* tangObj = dynamic_cast<TangibleObject*>(itemObject);
if (tangObj->getTangibleGroup() == TanGroup_Container)
{
// Request container contents.
gContainerFactory->requestObject(this,targetId,TanGroup_Container,0,playerObject->getClient());
aContainer = true;
}
//this might be a backpack
//or a chest - it needs to have a capacity to be a container!
if (tangObj->getCapacity())
{
//checkContainingContainer checks the permission
if(checkContainingContainer(tangObj->getId(),playerObject->getId()))
{
aContainer = true;
//register the player to the container and create the content
gContainerManager->registerPlayerToContainer(tangObj,playerObject);
}
}
}
//its not a Container* Object however in theory it still can be a backpack for example
if (!aContainer)
{
// STF: container_error_message Key: container8 does not seem to be working, using this custom string temperary.
gMessageLib->SendSystemMessage(L"You do not have permission to access that container.", playerObject);
}
else
{
gMessageLib->sendOpenedContainer(targetId, playerObject);
}
}
else
{
DLOG(info) << "ObjectController::_handleOpenContainer: INVALID Object id " << targetId;
}
}