本文整理汇总了C++中CShipClass::AddTypesUsed方法的典型用法代码示例。如果您正苦于以下问题:C++ CShipClass::AddTypesUsed方法的具体用法?C++ CShipClass::AddTypesUsed怎么用?C++ CShipClass::AddTypesUsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CShipClass
的用法示例。
在下文中一共展示了CShipClass::AddTypesUsed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OutputByShipClass
void OutputByShipClass (SItemTableCtx &Ctx, const SItemTypeList &ItemList, bool bShowUsage)
{
int i, j;
// Make a map of ship classes for each item
TSortMap<DWORD, TArray<CShipClass *>> ItemToShipClass;
for (i = 0; i < g_pUniverse->GetShipClassCount(); i++)
{
CShipClass *pClass = g_pUniverse->GetShipClass(i);
// Skip non-generic ones
if (!pClass->HasLiteralAttribute(CONSTLIT("genericClass")))
continue;
// Add the list of types used by the ship
TSortMap<DWORD, bool> TypesUsed;
pClass->AddTypesUsed(&TypesUsed);
// For each item type, add it to the map
for (j = 0; j < TypesUsed.GetCount(); j++)
{
CDesignType *pType = g_pUniverse->FindDesignType(TypesUsed.GetKey(j));
if (pType && pType->GetType() == designItemType)
{
TArray<CShipClass *> *pList = ItemToShipClass.SetAt(pType->GetUNID());
pList->Insert(pClass);
}
}
}
// If we want to show usage, then we print each item along with the
// ship classes using each item.
if (bShowUsage)
{
for (i = 0; i < ItemList.GetCount(); i++)
{
CItemType *pType = ItemList[i];
printf("%s\n", (LPSTR)pType->GetNounPhrase());
TArray<CShipClass *> *pList = ItemToShipClass.SetAt(pType->GetUNID());
for (j = 0; j < pList->GetCount(); j++)
printf("\t%s\n", (LPSTR)pList->GetAt(j)->GetName());
if (pList->GetCount() == 0)
printf("\t(none)\n");
printf("\n");
}
}
// Otherwise we categorize by ship class
else
{
// Now make a list of all ship classes that have our items
SByShipClassTypeList ByShipClassTable;
for (i = 0; i < ItemList.GetCount(); i++)
{
const CString &sKey = ItemList.GetKey(i);
CItemType *pType = ItemList[i];
// Loop over all ship classes
TArray<CShipClass *> *pList = ItemToShipClass.SetAt(pType->GetUNID());
for (j = 0; j < pList->GetCount(); j++)
{
CString sClassName = pList->GetAt(j)->GetName();
bool bNew;
SShipClassEntry *pEntry = ByShipClassTable.SetAt(sClassName, &bNew);
if (bNew)
pEntry->sShipClassName = sClassName;
pEntry->ItemTable.Insert(sKey, pType);
}
// If no ship class
if (pList->GetCount() == 0)
{
bool bNew;
SShipClassEntry *pEntry = ByShipClassTable.SetAt(CONSTLIT("(none)"), &bNew);
if (bNew)
pEntry->sShipClassName = CONSTLIT("(none)");
pEntry->ItemTable.Insert(sKey, pType);
}
}
// Now loop over all attributes
for (i = 0; i < ByShipClassTable.GetCount(); i++)
{
const SShipClassEntry &Entry = ByShipClassTable[i];
//.........这里部分代码省略.........