本文整理汇总了C++中Inventory::setId方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::setId方法的具体用法?C++ Inventory::setId怎么用?C++ Inventory::setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::setId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createNonPersistentNpc
NPCObject* NonPersistentNpcFactory::createNonPersistentNpc(DatabaseResult* result, uint64 templateId, uint64 npcNewId, uint32 familyId, uint64 controllingObject)
{
NPCObject* npc;
switch(familyId)
{
case NpcFamily_Trainer:
{
npc = new Trainer();
}
break;
case NpcFamily_Filler:
{
npc = new FillerNPC();
}
break;
case NpcFamily_QuestGiver:
{
npc = new QuestGiver();
}
break;
case NpcFamily_AttackableObject:
{
// Stuff like Debris.
npc = new AttackableStaticNpc();
}
break;
case NpcFamily_AttackableCreatures:
{
// gLogger->logMsgF("NonPersistentNpcFactory::_createNonPersistentNpc() Created a NpcFamily_AttackableCreatures", MSG_NORMAL);
// Stuff like npc's and womp rats :).
npc = new AttackableCreature(templateId);
}
break;
case NpcFamily_NaturalLairs:
{
// First time lairs.
// gLogger->logMsgF("NonPersistentNpcFactory::createNonPersistentNpc() Created a NpcFamily_NaturalLairs", MSG_NORMAL);
//Lairs are not supported here, at least not yet.
assert(false && "NonPersistentNpcFactory::createNonPersistent NpcFamily_NaturalLairs Lairs are not supported here yet.");
npc = new LairObject(templateId);
}
break;
default:
{
gLogger->logMsgF("NonPersistentNpcFactory::createNonPersistent unknown Family %u",MSG_HIGH,familyId);
assert(false && "NonPersistentNpcFactory::createNonPersistent unknown family");
npc = new NPCObject();
}
break;
}
// Set the new temporarily id.
npc->setId(npcNewId);
// Register object with WorldManager.
gWorldManager->addObject(npc, true);
Inventory* npcInventory = new Inventory();
npcInventory->setCapacity(50);//we want to be able to fill something in our inventory
npcInventory->setParent(npc);
uint64 count = result->getRowCount();
result->GetNextRow(mNonPersistentNpcBinding,(void*)npc);
// The template for this creature, in case of a respawn.
npc->mNpcTemplateId = templateId;
// Should bet fetched from attributes, these will do as defaults.
npc->mHam.mHealth.setCurrentHitPoints(500);
npc->mHam.mAction.setCurrentHitPoints(500);
npc->mHam.mMind.setCurrentHitPoints(500);
npc->mHam.calcAllModifiedHitPoints();
// inventory
npcInventory->setId(npc->mId + 1);
npcInventory->setParentId(npc->mId);
npcInventory->setModelString("object/tangible/inventory/shared_creature_inventory.iff");
npcInventory->setName("inventory");
npcInventory->setNameFile("item_n");
npcInventory->setTangibleGroup(TanGroup_Inventory);
npcInventory->setTangibleType(TanType_CreatureInventory);
npc->mEquipManager.addEquippedObject(CreatureEquipSlot_Inventory,npcInventory);
if (npc->getNpcFamily() == NpcFamily_AttackableObject)
{
// Dynamic spawned pve-enabled "static" creatures like debris.
npc->setType(ObjType_Creature);
npc->setCreoGroup(CreoGroup_AttackableObject);
npc->mTypeOptions = 0x0;
//.........这里部分代码省略.........
示例2: handleDatabaseJobComplete
void NonPersistentNpcFactory::handleDatabaseJobComplete(void* ref,DatabaseResult* result)
{
QueryNonPersistentNpcFactory* asyncContainer = reinterpret_cast<QueryNonPersistentNpcFactory*>(ref);
switch(asyncContainer->mQueryType)
{
case NonPersistentNpcQuery_Attributes:
{
// gLogger->logMsgF("NonPersistentNpcFactory::handleDatabaseJobComplete() AT NonPersistentNpcQuery_Attributes:", MSG_NORMAL);
Object* object = gWorldManager->getObjectById(asyncContainer->mId);
if (object)
{
_buildAttributeMap(object,result);
if (object->getLoadState() == LoadState_Loaded && asyncContainer->mOfCallback)
{
// gLogger->logMsgF("NonPersistentNpcFactory::handleDatabaseJobComplete() Invoking mOfCallback->handleObjectReady(npc)", MSG_NORMAL);
asyncContainer->mOfCallback->handleObjectReady(object);
}
else
{
// gLogger->logMsgF("NonPersistentNpcFactory::handleDatabaseJobComplete() Invoking NOTHING", MSG_NORMAL);
}
}
else
{
gLogger->logMsgF("NonPersistentNpcFactory::handleDatabaseJobComplete() Object is GONE", MSG_NORMAL);
}
}
break;
//=============================================================================
//
// Upgrade version for use of the correct DB.
//
//=============================================================================
case NonPersistentNpcQuery_LairTemplate:
{
// gLogger->logMsgF("NonPersistentNpcFactory::handleDatabaseJobComplete() AT NonPersistentNpcQuery_LairTemplate:", MSG_NORMAL);
NpcLairEntityEx lair;
DataBinding* lairSpawnBinding = mDatabase->CreateDataBinding(9);
lairSpawnBinding->addField(DFT_uint64,offsetof(NpcLairEntityEx,mCreatureSpwanRegion),8,0);
lairSpawnBinding->addField(DFT_uint64,offsetof(NpcLairEntityEx,mTemplateId),8,1);
lairSpawnBinding->addField(DFT_uint32,offsetof(NpcLairEntityEx,mCreatureGroup),4,2);
lairSpawnBinding->addField(DFT_uint32,offsetof(NpcLairEntityEx,mNumberOfLairs),4,3);
lairSpawnBinding->addField(DFT_float,offsetof(NpcLairEntityEx,mSpawnPosX),4,4);
lairSpawnBinding->addField(DFT_float,offsetof(NpcLairEntityEx,mSpawnPosZ),4,5);
lairSpawnBinding->addField(DFT_float,offsetof(NpcLairEntityEx,mSpawnDirY),4,6);
lairSpawnBinding->addField(DFT_float,offsetof(NpcLairEntityEx,mSpawnDirW),4,7);
lairSpawnBinding->addField(DFT_uint32,offsetof(NpcLairEntityEx,mFamily),4,8);
DataBinding* lairSpawnNpcBinding = mDatabase->CreateDataBinding(4);
lairSpawnNpcBinding->addField(DFT_bstring,offsetof(NPCObject,mModel),255,9);
lairSpawnNpcBinding->addField(DFT_bstring,offsetof(NPCObject,mSpecies),255,10);
lairSpawnNpcBinding->addField(DFT_bstring,offsetof(NPCObject,mSpeciesGroup),255,11);
lairSpawnNpcBinding->addField(DFT_bstring,offsetof(NPCObject,mFaction),32,12);
uint64 count = result->getRowCount();
result->GetNextRow(lairSpawnBinding,&lair);
// Let's create the lair.
// We save the lairs-type... that's kinda a template for the complete lair.
LairObject* npc = new LairObject(asyncContainer->mTemplateId);
// Set the new if of this temp object.
npc->setId(asyncContainer->mId);
// Register object with WorldManager.
gWorldManager->addObject(npc, true);
// May need the height also, in case of pre set (fixed) spawn position.
npc->mPosition.x = lair.mSpawnPosX;
npc->mPosition.z = lair.mSpawnPosZ;
if (npc->getParentId() == 0)
{
// Heightmap only works outside.
npc->mPosition.y = npc->getHeightAt2DPosition(lair.mSpawnPosX, lair.mSpawnPosZ, true);
}
else
{
// We do not have support for handling creatures inside.
assert(false && "NonPersistentNpcFactory::handleDatabaseJobComplete NonPersistentNpcQuery_LairTemplate No support for handling creatures inside");
npc->mPosition.y = 0;
}
npc->mDirection.y = lair.mSpawnDirY;
npc->mDirection.w = lair.mSpawnDirW;
// Let's get the spawn area.
const Anh_Math::Rectangle spawnArea = gWorldManager->getSpawnArea(lair.mCreatureSpwanRegion);
// lair.mCreatureSpwanRegion
npc->setSpawnArea(spawnArea);
result->ResetRowIndex();
//.........这里部分代码省略.........