本文整理汇总了C++中Inventory::getParentId方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::getParentId方法的具体用法?C++ Inventory::getParentId怎么用?C++ Inventory::getParentId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::getParentId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendInventory
//======================================================================================================================
//
// create the inventory contents for its owner
//
void MessageLib::sendInventory(PlayerObject* playerObject)
{
if(!_checkPlayer(playerObject))
return;
Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
//uint64 parentId = inventory->getParentId();
//to stop the server from crashing.
if(!inventory)
{
assert(false && "MessageLib::sendInventory - Player has no inventory ???? :(");
return;
}
inventory->setTypeOptions(256);
//todo - just use sendcreate tangible and have it send the children, too!!!!
// create the inventory
sendCreateObjectByCRC(inventory,playerObject,false);
sendContainmentMessage(inventory->getId(),inventory->getParentId(),4,playerObject);
sendBaselinesTANO_3(inventory,playerObject);
sendBaselinesTANO_6(inventory,playerObject);
// create objects contained
ObjectIDList* invObjects = inventory->getObjects();
ObjectIDList::iterator objIt = invObjects->begin();
while(objIt != invObjects->end())
{
Object* object = gWorldManager->getObjectById((*objIt));
sendCreateObject(object,playerObject,false);
++objIt;
}
sendEndBaselines(inventory->getId(),playerObject);
ObjectList* invEquippedObjects = playerObject->getEquipManager()->getEquippedObjects();
ObjectList::iterator objEIt = invEquippedObjects->begin();
while(objEIt != invEquippedObjects->end())
{
if(TangibleObject* tangible = dynamic_cast<TangibleObject*>(*objEIt))
{
sendCreateTangible(tangible,playerObject);
}
++objEIt;
}
}
示例2: removeFromContainer
bool ObjectController::removeFromContainer(uint64 targetContainerId, uint64 targetId)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
Object* itemObject = gWorldManager->getObjectById(targetId);
Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
TangibleObject* targetContainer = dynamic_cast<TangibleObject*>(gWorldManager->getObjectById(targetContainerId));
TangibleObject* tangible = dynamic_cast<TangibleObject*>(itemObject);
Item* item = dynamic_cast<Item*>(itemObject);
// its us
if (tangible->getParentId() == playerObject->getId())
{
// unequip it
return playerObject->getEquipManager()->unEquipItem(itemObject);
}
//the containerObject is the container used in the tutorial or some random dungeon container
Container* container = dynamic_cast<Container*>(gWorldManager->getObjectById(tangible->getParentId()));
if (container)
{
container->removeObject(itemObject);
//gContainerManager->destroyObjectToRegisteredPlayers(container, tangible->getId());
if (gWorldConfig->isTutorial())
{
playerObject->getTutorial()->transferedItemFromContainer(targetId, tangible->getParentId());
// If object is owned by player (private owned for instancing), we remove the owner from the object.
// what is this used for ???
if (itemObject->getPrivateOwner() == playerObject->getId())
{
itemObject->setPrivateOwner(0);
}
}
return true;
}
//creature inventories are a special case - their items are temporary!!! we cannot loot them directly
CreatureObject* unknownCreature;
Inventory* creatureInventory;
if (itemObject->getParentId() &&
(unknownCreature = dynamic_cast<CreatureObject*>(gWorldManager->getObjectById(itemObject->getParentId() - INVENTORY_OFFSET))) &&
(creatureInventory = dynamic_cast<Inventory*>(unknownCreature->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))) &&
(creatureInventory->getId() == itemObject->getParentId()) && (creatureInventory->getId() != inventory->getId()))
{
if(!creatureInventory->removeObject(itemObject))
{
LOG(warning) << "ObjectController::removeFromContainer: Internal Error could not remove " << itemObject->getId() << " from creature inventory " << creatureInventory->getId();
return false;
}
// we destroy the item in this case as its a temporary!!
// we do not want to clog the db with unlooted items
gContainerManager->destroyObjectToRegisteredPlayers(creatureInventory, tangible->getId());
ObjectIDList* invObjList = creatureInventory->getObjects();
if (invObjList->size() == 0)
{
// Put this creature in the pool of delayed destruction and remove the corpse from scene.
gWorldManager->addCreatureObjectForTimedDeletion(creatureInventory->getParentId(), LootedCorpseTimeout);
}
if (gWorldConfig->isTutorial())
{
// TODO: Update tutorial about the loot.
playerObject->getTutorial()->transferedItemFromContainer(targetId, creatureInventory->getId());
}
//bail out here and request the item over the db - as the item in the NPC has a temporary id and we dont want that in the db
// This ensure that we do not use/store any of the temp id's in the database.
gObjectFactory->requestNewDefaultItem(inventory, item->getItemFamily(), item->getItemType(), inventory->getId(), 99, glm::vec3(), "");
return false;
}
//cells are NOT tangibles - thei are static Objects
CellObject* cell;
if(cell = dynamic_cast<CellObject*>(gWorldManager->getObjectById(itemObject->getParentId())))
{
// Stop playing if we pick up the (permanently placed) instrument we are playing
if (item && (item->getItemFamily() == ItemFamily_Instrument))
{
uint32 instrumentType = item->getItemType();
if ((instrumentType == ItemType_Nalargon) || (instrumentType == ItemType_omni_box) || (instrumentType == ItemType_nalargon_max_reebo))
{
// It's a placeable original instrument.
// Are we targeting the instrument we actually play on?
if (playerObject->getActiveInstrumentId() == item->getId())
{
gEntertainerManager->stopEntertaining(playerObject);
}
}
}
//.........这里部分代码省略.........