本文整理汇总了C++中PlayerObject::getController方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::getController方法的具体用法?C++ PlayerObject::getController怎么用?C++ PlayerObject::getController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::getController方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _handlePlayerMovementUpdateTimers
bool WorldManager::_handlePlayerMovementUpdateTimers(uint64 callTime, void* ref)
{
PlayerMovementUpdateMap::iterator it = mPlayerMovementUpdateMap.begin();
while (it != mPlayerMovementUpdateMap.end())
{
PlayerObject* player = dynamic_cast<PlayerObject*>(getObjectById((*it).first));
if (player)
{
if (player->isConnected())
{
// The timer has expired?
if (callTime >= ((*it).second))
{
// Yes, handle it.
ObjectController* ObjCtl = player->getController();
uint64 next = ObjCtl->playerWorldUpdate(false);
mPlayerMovementUpdateMap.erase(it++);
if (next)
{
// Add next scheduled update.
addPlayerMovementUpdateTime(player, next);
}
}
else
{
++it;
}
}
else
{
// Remove the disconnected...
mPlayerMovementUpdateMap.erase(it++);
}
}
else
{
// Remove the disconnected...
mPlayerMovementUpdateMap.erase(it++);
}
}
return (true);
}
示例2: handleFoodUse
void Food::handleFoodUse(Object* srcObject)
{
toDelete = true;
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(srcObject);
if(!playerObject)
{
return;
}
if(playerObject->isDead() || playerObject->isIncapacitated())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), playerObject);
return;
}
//we need to start by checking whether our stomach isnt full
//we need to update our stomach
float filling = 0;
if(this->hasInternalAttribute("food_icon"))
{
mIcon = 0;
mIcon = this->getInternalAttribute<uint32>("food_icon");
} else {
LOG(WARNING) << "Food/Drink found with no buff icon";
}
if(this->hasAttribute("counter_uses_remaining"))
{
_handleUses_Remaining(playerObject);
}
bool drink = (this->hasAttribute("stomach_drink"));
bool food = (this->hasAttribute("stomach_food"));
if(food)
{
filling = this->getAttribute<float>("stomach_food");
//do we still have place for it ?
if(!playerObject->getStomach()->checkFood(filling))
{
gMessageLib->SendSystemMessage(OutOfBand("error_message", "full_food"), playerObject);
return;
}
gMessageLib->SendSystemMessage(OutOfBand("base_player", "prose_consume_item", 0, this->getId(), 0), playerObject);
playerObject->getStomach()->incFood(filling);
}
if(drink)
{
float filling = 0;
filling = this->getAttribute<float>("stomach_drink");
//do we still have place for it ?
if(!playerObject->getStomach()->checkDrink(filling))
{
gMessageLib->SendSystemMessage(OutOfBand("error_message","full_drink"), playerObject);
return;
}
gMessageLib->SendSystemMessage(OutOfBand("base_player", "prose_consume_item", 0, this->getId(), 0), playerObject);
playerObject->getStomach()->incDrink(filling);
}
if(this->hasAttribute("duration"))
{
mDuration= static_cast<uint32>(this->getAttribute<float>("duration"));
}
if(mDuration >0)
{
_handleBuff(playerObject);
} else {
_handleInstant(playerObject);
}
// play sounds
playerObject->playFoodSound(food, drink);
//when empty delete
if(toDelete)
{
//the db
gObjectFactory->deleteObjectFromDB(this);
//destroy it in the client
gMessageLib->sendDestroyObject(this->getId(),playerObject);
//delete it out of the inventory
uint64 now = Anh_Utils::Clock::getSingleton()->getLocalTime();
playerObject->getController()->addEvent(new ItemDeleteEvent(now+100,this->getId()),100);
return;
}
return;
}
示例3: _handleTransferItemMisc
void ObjectController::_handleTransferItemMisc(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
//we need to make sure that ONLY equipped items are contained by the player
//all other items are contained by the inventory!!!!!!!!
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
Object* itemObject = gWorldManager->getObjectById(targetId);
Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
BString dataStr;
uint64 targetContainerId;
uint32 linkType;
float x,y,z;
CellObject* cell;
message->getStringUnicode16(dataStr);
if(swscanf(dataStr.getUnicode16(),L"%" WidePRIu64 L" %u %f %f %f",&targetContainerId,&linkType,&x,&y,&z) != 5)
{
DLOG(info) << "ObjController::_handleTransferItemMisc: Error in parameters";
return;
}
if (!itemObject)
{
DLOG(warning) << "ObjController::_handleTransferItemMisc: No Object to transfer :(";
return;
}
TangibleObject* tangible = dynamic_cast<TangibleObject*>(itemObject);
if(!tangible)
{
//no tagible - get out of here
DLOG(warning) << "ObjController::_handleTransferItemMisc: No tangible to transfer :(";
return;
}
//get our containers
Object* newContainer = gWorldManager->getObjectById(targetContainerId);
Object* oldContainer = gWorldManager->getObjectById(tangible->getParentId());
DLOG(info) << "ObjController::_handleTransferItemMisc: parameters";
DLOG(info) << "ObjController::_handleTransferItemMisc: newcontainer : " << targetContainerId;
DLOG(info) << "ObjController::_handleTransferItemMisc: oldcontainer : " << tangible->getParentId();
DLOG(info) << "ObjController::_handleTransferItemMisc: linktype : " << linkType;
// We may want to transfer other things than items...basically tangibleObjects!
// resourcecontainers / factory crates
// first check whether its an instrument with persistant copy - thats a special case!
Item* item = dynamic_cast<Item*>(itemObject);
if (item)
{
//check if its only temporarily placed
if(item->getItemFamily() == ItemFamily_Instrument)
{
if(item->getPersistantCopy())
{
// gMessageLib->sendSystemMessage(playerObject,L"you cannot pick this up");
// You bet, I can! Remove the temp instrument from the world.
// Do I have access to this instrument?
if (item->getOwner() == playerObject->getId())
{
playerObject->getController()->destroyObject(targetId);
}
return;
}
}
}
// A FYI: When we drop items, we use player pos.
itemObject->mPosition = glm::vec3(x,y,z);
if (!targetContainerId)
{
DLOG(info) << "ObjController::_handleTransferItemMisc:TargetContainer is 0 :(";
//return;
}
//ok how to tackle this ... :
//basically I want to use ObjectContainer as standard access point for item handling!
//so far we have different accesses for Objects on the player and for the inventory and for ContainerObjects and for cells ...
//lets begin by getting the target Object
if(!checkTargetContainer(targetContainerId,itemObject))
{
DLOG(info) << "ObjController::_handleTransferItemMisc:TargetContainer is not valid :(";
return;
}
if(!checkContainingContainer(tangible->getParentId(), playerObject->getId()))
{
DLOG(info) << "ObjController::_handleTransferItemMisc:ContainingContainer is not allowing the transfer :(";
//.........这里部分代码省略.........