本文整理汇总了C++中Inventory::getObjects方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::getObjects方法的具体用法?C++ Inventory::getObjects怎么用?C++ Inventory::getObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::getObjects方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleObjectReady
void InventoryFactory::handleObjectReady(Object* object,DispatchClient* client)
{
//we either have the ID of the inventory or of the player
//the inventory of course is stored under its own Id
InLoadingContainer* ilc = _getObject(object->getParentId());
assert(ilc && "InventoryFactory::handleObjectReady unable to find InLoadingContainer");
if (! ilc) {
return;
}
Inventory* inventory = dynamic_cast<Inventory*>(ilc->mObject);
gWorldManager->addObject(object,true);
//for unequipped items only
inventory->addObjectSecure(object);
if(inventory->getObjectLoadCounter() == (inventory->getObjects())->size())
{
gLogger->logMsgF("InventoryFactory: remove inventory %I64u from loadmap",MSG_HIGH,inventory->getId());
inventory->setLoadState(LoadState_Loaded);
if(!(_removeFromObjectLoadMap(inventory->getId())))
gLogger->logMsg("InventoryFactory: Failed removing object from loadmap");
ilc->mOfCallback->handleObjectReady(inventory,ilc->mClient);
mILCPool.free(ilc);
}
}
示例2: 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;
}
}
示例3: _getInventoryFireworks
ObjectList* FireworkShow::_getInventoryFireworks(PlayerObject* playerObject)
{
ObjectList* returnList = new ObjectList();
Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
ObjectIDList* objList = inventory->getObjects();
ObjectIDList::iterator containerObjectIt = objList->begin();
while (containerObjectIt != objList->end())
{
Object* object = gWorldManager->getObjectById((*containerObjectIt));
if (Item* item = dynamic_cast<Item*>(object))
{
if(item->getItemFamily()==ItemFamily_FireWork && item->getItemType()!= ItemType_Firework_Show)
{
returnList->push_back(item);
}
}
++containerObjectIt;
}
return returnList;
}
示例4: 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);
}
}
}
//.........这里部分代码省略.........
示例5: getCraftingStationTool
// get appropriate crafting tool from selected crafting station
// check inventory for same tool 'type' as crafting station
CraftingTool* CraftingManager::getCraftingStationTool(PlayerObject* playerObject, CraftingStation* station)
{
CraftingTool* tool = NULL;
int32 stationType = station->getItemType();
Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
ObjectIDList::iterator It = inventory->getObjects()->begin();
while(It != inventory->getObjects()->end())
{
Item* item = dynamic_cast<Item*>(gWorldManager->getObjectById((*It)));
if(!item)
{
It++;
continue;
}
int32 itemType = item->getItemType();
switch (stationType)
{
case ItemType_ClothingStation:
case ItemType_ClothingStationPublic:
{
if(itemType == ItemType_ClothingTool)
{
tool = dynamic_cast<CraftingTool*>(item);
}
}
break;
case ItemType_WeaponStation:
case ItemType_WeaponStationPublic:
{
if(itemType == ItemType_WeaponTool)
{
tool = dynamic_cast<CraftingTool*>(item);
}
}
break;
case ItemType_FoodStation:
case ItemType_FoodStationPublic:
{
if(itemType == ItemType_FoodTool)
{
tool = dynamic_cast<CraftingTool*>(item);
}
}
break;
case ItemType_StructureStation:
case ItemType_StructureStationPublic:
{
if(itemType == ItemType_StructureTool)
{
tool = dynamic_cast<CraftingTool*>(item);
}
}
break;
case ItemType_SpaceStation:
case ItemType_SpaceStationPublic:
{
if(itemType == ItemType_SpaceTool)
{
tool = dynamic_cast<CraftingTool*>(item);
}
}
break;
default:
{
break;
}
break;
}
if(tool)
{
// found it now jump out
break;
}
++It;
continue;
}
return tool;
}
示例6: if
void ArtisanManager::finishSampling(PlayerObject* player, CurrentResource* resource, SurveyTool* tool, uint32 sampleAmount)
{
bool foundSameType = false;
//grants 20xp -> 40xp inclusive -- Feature suggestion: Grant less XP for smaller samples, more xp for greater samples. IE: 20 + X*sampleSize
gSkillManager->addExperience(XpType_resource_harvesting_inorganic,(int32)((gRandom->getRand()%20) + 20),player);
// see if we can add it to an existing container
Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
ObjectIDList* invObjects = inventory->getObjects();
ObjectIDList::iterator listIt = invObjects->begin();
while(listIt != invObjects->end())
{
// we are looking for resource containers
ResourceContainer* resCont = dynamic_cast<ResourceContainer*>(gWorldManager->getObjectById((*listIt)));
if(resCont)
{
uint32 targetAmount = resCont->getAmount();
uint32 maxAmount = resCont->getMaxAmount();
uint32 newAmount;
if(resCont->getResourceId() == resource->getId() && targetAmount < maxAmount)
{
foundSameType = true;
if((newAmount = targetAmount + sampleAmount) <= maxAmount)
{
// update target container
resCont->setAmount(newAmount);
gMessageLib->sendResourceContainerUpdateAmount(resCont,player);
gWorldManager->getDatabase()->executeSqlAsync(NULL,NULL,"UPDATE resource_containers SET amount=%u WHERE id=%"PRIu64"",newAmount,resCont->getId());
}
// target container full, put in what fits, create a new one
else if(newAmount > maxAmount)
{
uint32 selectedNewAmount = newAmount - maxAmount;
resCont->setAmount(maxAmount);
gMessageLib->sendResourceContainerUpdateAmount(resCont,player);
gWorldManager->getDatabase()->executeSqlAsync(NULL,NULL,"UPDATE resource_containers SET amount=%u WHERE id=%"PRIu64"",maxAmount,resCont->getId());
gObjectFactory->requestNewResourceContainer(inventory,resource->getId(),inventory->getId(),99,selectedNewAmount);
}
break;
}
}
++listIt;
}
// or need to create a new one
if(!foundSameType)
{
gObjectFactory->requestNewResourceContainer(inventory,resource->getId(),inventory->getId(),99,sampleAmount);
}
// deplete resource
gResourceManager->setResourceDepletion(resource, sampleAmount);
return;
}