本文整理汇总了C++中Inventory::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::setName方法的具体用法?C++ Inventory::setName怎么用?C++ Inventory::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::setName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
fstream outInventory("InventoryData.txt",ios::in | ios::out | ios::binary);
char name[25] = "";
int qty = 0;
double perUnit = 0.0;
Inventory invent;
vector<Inventory> inventList;
for (int i = 0; i > 5; i++)
{
cout << "Please enter the name of the product" << endl;
cin >> name;
invent.setName(name);
cout << "Please enter the quantity of the 'NEW' product" << endl;
cin >> qty;
invent.setQty(qty);
cout << "Please enter the price of each " << invent.getName() << endl;
cin >> perUnit;
invent.setPerUnit(perUnit);
inventList.push_back(Inventory(invent.getQty(), invent.getName(), invent.getPerUnit()));
}
for(auto i : inventList)
{
outInventory.write(reinterpret_cast<const char *>(&invent), sizeof(Inventory));
outInventory.close();
}
ifstream inInventory("InventoryData.txt", ios::in);
inInventory.read(reinterpret_cast<char *>(&invent), sizeof(Inventory));
while (inInventory >> name >> qty >> perUnit)
{
invent.outputLine(invent.getQty(), invent.getName(), invent.getPerUnit());
}
system("pause");
return 0;
}
示例2: 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;
//.........这里部分代码省略.........
示例3: handleDatabaseJobComplete
//.........这里部分代码省略.........
// 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 "
"FROM creature_groups "
"WHERE creature_groups.creature_group_id=%u;",lair.mCreatureGroup);
}
break;
case NonPersistentNpcQuery_LairCreatureTemplates:
{
// Get the lair object.
LairObject* npc = dynamic_cast<LairObject*>(gWorldManager->getObjectById(asyncContainer->mId));
assert(npc && "NonPersistentNpcFactory::handleDatabaseJobComplete NonPersistentNpcQuery_LairCreatureTemplates WorldManager unable to find object id");