本文整理汇总了C++中Inventory::removeObject方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::removeObject方法的具体用法?C++ Inventory::removeObject怎么用?C++ Inventory::removeObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::removeObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleObjectMenuSelect
void Deed::handleObjectMenuSelect(uint8 messageType,Object* srcObject)
{
if(PlayerObject* player = dynamic_cast<PlayerObject*>(srcObject))
{
switch(messageType)
{
case radId_itemUse:
{
if(this->getItemType() >= ItemType_Deed_X34 && this->getItemType() <= ItemType_Deed_Swoop) //landspeeder x34, speederbike, swoop
{
// create the vehicle and put in datapad
Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
if(datapad->getCapacity())
{
gVehicleFactory->createVehicle(this->getItemType(),player);
Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
inventory->removeObject(this);
gMessageLib->sendDestroyObject(this->getId(),player);
gObjectFactory->deleteObjectFromDB(this);
gWorldManager->destroyObject(this);
}
else
{
gMessageLib->sendSystemMessage(player,L"Error datapad at max capacity. Couldn't create the vehicle.");
}
}
else
{
//enter deed placement mode
StructureDeedLink* data = gStructureManager->getDeedData(this->getItemType());
if(!data)
{
return;
}
if(player->getParentId())
{
gMessageLib->sendSystemMessage(player,L"","player_structure","not_inside");
return;
}
//check available Lots and remove ... grml
if(!player->useLots(data->requiredLots))
{
gMessageLib->sendSystemMessage(player, L"","player_structure","not_enough_lots","","",L"",data->requiredLots);
return;
}
//TODO
//check for city boundaries
//check if were allowed to build that structure on this planet
if((data->placementMask&gWorldManager->getZoneId()) == gWorldManager->getZoneId())
{
//sadly the client wont inform us when the player hit escape
gMessageLib->sendEnterStructurePlacement(this,data->structureObjectString,player);
gStructureManager->UpdateCharacterLots(player->getId());
}
else
{
//we cannot differ whether its a no build planet
//or just the house type isnt permitted here
//wrong_planet
//not_permitted
gMessageLib->sendSystemMessage(player, L"","player_structure","wrong_planet","","",L"",data->requiredLots);
gStructureManager->UpdateCharacterLots(player->getId());
return;
}
}
}
break;
default: break;
}
}
}
示例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);
}
}
}
//.........这里部分代码省略.........