本文整理汇总了C++中Inventory::setParent方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::setParent方法的具体用法?C++ Inventory::setParent怎么用?C++ Inventory::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::setParent方法的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
//.........这里部分代码省略.........
// 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();
result->GetNextRow(lairSpawnNpcBinding,(void*)npc );
mDatabase->DestroyDataBinding(lairSpawnBinding);
mDatabase->DestroyDataBinding(lairSpawnNpcBinding);
Inventory* npcInventory = new Inventory();
npcInventory->setParent(npc);
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);
npc->setType(ObjType_Creature);
// This will ensure the use of the single H(am) bar.
npc->setCreoGroup(CreoGroup_AttackableObject);
npc->mTypeOptions = 0x0;
npc->togglePvPStateOn((CreaturePvPStatus)(CreaturePvPStatus_Attackable));
// gLogger->logMsgF("NonPersistentNpcFactory::handleDatabaseJobComplete() Attempting to get the creature templates for group %u used by this lair.", MSG_NORMAL, lair.mCreatureGroup);
QueryNonPersistentNpcFactory* asContainer = new QueryNonPersistentNpcFactory(asyncContainer->mOfCallback, NonPersistentNpcQuery_LairCreatureTemplates, asyncContainer->mTemplateId, asyncContainer->mId);
// Do not transfer object refs, use the handle, i.e. asyncContainer->mId
// asContainer->mObject = npc;
mDatabase->ExecuteSqlAsync(this, asContainer,
"SELECT creature_groups.creature_id "