Replace various uses of Count() with Any() for ienumerables + remove redundant parenthesis

This commit is contained in:
Chomp
2025-02-24 17:53:42 +00:00
parent eeea8a0000
commit b4c5392f08
7 changed files with 10 additions and 10 deletions
@@ -1136,7 +1136,7 @@ public class BotEquipmentModGenerator(
{
Incompatible = true,
Found = false,
Reason = $"Unable to add mod to {choiceTypeEnum.ToString()} slot: {modSlotName}. All: {modPool.Count()} had conflicts"
Reason = $"Unable to add mod to {choiceTypeEnum.ToString()} slot: {modSlotName}. All: {modPool.Count} had conflicts"
};
}
@@ -181,7 +181,7 @@ public class ExternalInventoryMagGen(
// Non-internal magazines that fit into the weapon
var externalMagazineOnlyPool = magazinePool.Where(x => x.Properties.ReloadMagType != ReloadMode.InternalMagazine);
if (externalMagazineOnlyPool is null || externalMagazineOnlyPool?.Count() == 0)
if (externalMagazineOnlyPool is null || !externalMagazineOnlyPool.Any())
{
return null;
}
+1 -1
View File
@@ -242,7 +242,7 @@ public class HideoutHelper(
protected HideoutProperties GetHideoutProperties(PmcData pmcData)
{
var bitcoinFarm = pmcData.Hideout.Areas.FirstOrDefault(area => area.Type == HideoutAreas.BITCOIN_FARM);
var bitcoinCount = bitcoinFarm?.Slots.Where(slot => slot.Items is not null).Count(); // Get slots with an item property
var bitcoinCount = (bitcoinFarm?.Slots).Count(slot => slot.Items is not null); // Get slots with an item property
var hideoutProperties = new HideoutProperties
{
+2 -2
View File
@@ -584,7 +584,7 @@ public class ItemHelper(
{
if (_databaseService.GetItems().TryGetValue(itemTpl, out var item))
{
return GetItem(itemTpl).Value.Properties?.Slots?.Count() > 0;
return GetItem(itemTpl).Value.Properties?.Slots?.Count > 0;
}
return false;
@@ -1890,7 +1890,7 @@ public class ItemHelper(
if (_logger.IsLogEnabled(LogLevel.Debug))
{
_logger.Debug(
$"Unable to choose a mod for slot: {slot.Name} on item: {itemToAddTemplate.Id} {itemToAddTemplate.Name}, no compatible tpl found in pool of {itemPool.Count()}, skipping"
$"Unable to choose a mod for slot: {slot.Name} on item: {itemToAddTemplate.Id} {itemToAddTemplate.Name}, no compatible tpl found in pool of {itemPool.Count}, skipping"
);
}
+1 -1
View File
@@ -228,7 +228,7 @@ public class RewardHelper(
.ToList();
// More/less than single match, above filtering wasn't strict enough
if (matchingProductions.Count() != 1)
if (matchingProductions.Count != 1)
// Multiple matches were found, last ditch attempt to match by questid (value we add manually to production.json via `gen:productionquests` command)
{
matchingProductions = matchingProductions.Where(
@@ -116,7 +116,7 @@ public class BotWeaponModLimitService(
// Item being added is a mount but the parent item is NOT a mount (Allows red dot sub-mounts on mounts)
// Mount has one slot and its for a mod_scope
if (modLimits.Scope.Count >= modLimits.ScopeMax &&
modTemplate.Properties.Slots?.Count() == 1 &&
modTemplate.Properties.Slots?.Count == 1 &&
_itemHelper.IsOfBaseclass(modTemplate.Id, BaseClasses.MOUNT) &&
!_itemHelper.IsOfBaseclass(modsParent.Id, BaseClasses.MOUNT) &&
modTemplate.Properties.Slots.Any(slot => slot.Name == "mod_scope")
@@ -137,9 +137,9 @@ public class BotWeaponModLimitService(
);
}
// Mod is a mount that can hold only flashlights ad limit is reached (dont want to add empty mounts if limit is reached)
// Mod is a mount that can hold only flashlights ad limit is reached (don't want to add empty mounts if limit is reached)
if (modLimits.Scope.Count >= modLimits.ScopeMax &&
modTemplate.Properties.Slots?.Count() == 1 &&
modTemplate.Properties.Slots?.Count == 1 &&
_itemHelper.IsOfBaseclass(modTemplate.Id, BaseClasses.MOUNT) &&
modTemplate.Properties.Slots.Any(slot => slot.Name == "mod_flashlight")
)
@@ -931,7 +931,7 @@ public class LocationLifecycleService
// Fail if multiple were found
if (matchingQuests.Count != 1)
{
_logger.Error($"Unable to fix quest item: {lostItem}, {matchingQuests.Count()} matching quests found, expected 1");
_logger.Error($"Unable to fix quest item: {lostItem}, {matchingQuests.Count} matching quests found, expected 1");
continue;
}