本文整理汇总了C++中TMultiMap::Contains方法的典型用法代码示例。如果您正苦于以下问题:C++ TMultiMap::Contains方法的具体用法?C++ TMultiMap::Contains怎么用?C++ TMultiMap::Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TMultiMap
的用法示例。
在下文中一共展示了TMultiMap::Contains方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalucluateItemDrop
AItem* AMech_RPGCharacter::CalucluateItemDrop(UGroup* inGroup, ItemEnumns::ItemType type) {
TMultiMap<int32, int32> gradeMap;
int32 outputGrade;
int32 outputQuality;
bool upgradeGrade = FMath::RandHelper(100) <= 70;// upgradeGradeChance;
bool upgradeQuality = FMath::RandHelper(100) <= 70; //upgradeQualityChance;
float totalItems = 0;
float lowestGrade = AItem::HighestItemLevel;
float totalGrade = 0;
float meanGrade = 0;
int32 modeGrade = 0;
float lowestQuality = 20;
float totalQuality = 0;
float meanQuality = 0;
int32 modeQuality = 0;
for (AMech_RPGCharacter* member : inGroup->GetMembers()) {
//for (AItem* item : member->GetInventory()->GetItems()) {
AItem* item = member->GetCurrentWeapon();
if (item != nullptr && item->GetType() == type) {
totalItems++;
totalGrade += item->GetGrade();
totalQuality += item->GetQuality();
if (!gradeMap.Contains(item->GetGrade())) {
gradeMap.Add(item->GetGrade(), 1);
}
else {
gradeMap.Add(item->GetGrade(), (int32)(*gradeMap.Find(item->GetGrade()) + 1));
}
if (item->GetQuality() < lowestQuality) {
lowestQuality = item->GetQuality();
}
if (item->GetGrade() < lowestGrade) {
lowestGrade = item->GetGrade();
}
}
//}
}
meanGrade = totalGrade / totalItems;
meanQuality = totalQuality / totalItems;
TPair<int32, int32> heighestValue;
heighestValue.Key = 1;
heighestValue.Value = 0;
for (auto& map : gradeMap) {
// Found a higher quantity
if (map.Value > heighestValue.Value) {
heighestValue = map;
}
// Found the same quantity, only set if the grade is higher
else if (map.Value == heighestValue.Value && map.Key > heighestValue.Key) {
heighestValue = map;
}
}
//if (upgradeGrade)
meanGrade++;
//if (upgradeQuality)
meanQuality++;
outputGrade = FMath::RoundHalfToEven(MAX(meanGrade, heighestValue.Key));
outputQuality = FMath::RoundHalfToEven(meanQuality);
AItem* newItem = AItem::CreateItemByType(type, GetWorld(), outputGrade, outputQuality);
if (newItem != nullptr) {
newItem->SetItemOwner(this);
return newItem;
}
return nullptr;
}