Updated various methods to accept IEnumerable instead of List
This commit is contained in:
@@ -40,13 +40,11 @@ public class CustomizationController(
|
||||
var clothing = databaseService.GetCustomization();
|
||||
var suits = databaseService.GetTrader(traderId).Suits;
|
||||
|
||||
var matchingSuits = suits?.Where(s => clothing.ContainsKey(s.SuiteId)).ToList();
|
||||
matchingSuits = matchingSuits
|
||||
?.Where(s =>
|
||||
var matchingSuits = suits?.Where(s => clothing.ContainsKey(s.SuiteId));
|
||||
matchingSuits = matchingSuits?.Where(s =>
|
||||
clothing[s.SuiteId]?.Properties?.Side?.Contains(pmcData?.Info?.Side ?? string.Empty)
|
||||
?? false
|
||||
)
|
||||
.ToList();
|
||||
);
|
||||
|
||||
if (matchingSuits == null)
|
||||
{
|
||||
@@ -58,7 +56,7 @@ public class CustomizationController(
|
||||
);
|
||||
}
|
||||
|
||||
return matchingSuits;
|
||||
return matchingSuits.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -12,7 +12,10 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
/// </summary>
|
||||
/// <param name="fullProfile">Profile to add clothing to</param>
|
||||
/// <param name="clothingIds">Clothing Ids to add to profile</param>
|
||||
public static void AddSuitsToProfile(this SptProfile fullProfile, List<MongoId> clothingIds)
|
||||
public static void AddSuitsToProfile(
|
||||
this SptProfile fullProfile,
|
||||
IEnumerable<MongoId> clothingIds
|
||||
)
|
||||
{
|
||||
fullProfile.CustomisationUnlocks ??= [];
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
/// Gets the identifier for a child using slotId, locationX and locationY.
|
||||
/// </summary>
|
||||
/// <param name="item">Item.</param>
|
||||
/// <returns>SlotId OR slotid, locationX, locationY.</returns>
|
||||
/// <returns>SlotId OR slotId, locationX, locationY.</returns>
|
||||
public static string GetChildId(this Item item)
|
||||
{
|
||||
if (item.Location is null)
|
||||
@@ -365,7 +365,7 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
/// </summary>
|
||||
/// <param name="items">Inventory items to look for secure container in</param>
|
||||
/// <returns>List of ids</returns>
|
||||
public static List<MongoId> GetSecureContainerItems(this List<Item> items)
|
||||
public static List<MongoId> GetSecureContainerItems(this IEnumerable<Item> items)
|
||||
{
|
||||
var secureContainer = items.First(x => x.SlotId == "SecuredContainer");
|
||||
|
||||
@@ -417,7 +417,7 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
/// <param name="newId">Optional: new id to use</param>
|
||||
/// <returns>New root id</returns>
|
||||
public static MongoId RemapRootItemId(
|
||||
this List<Item> itemWithChildren,
|
||||
this IEnumerable<Item> itemWithChildren,
|
||||
MongoId? newId = null
|
||||
)
|
||||
{
|
||||
@@ -450,7 +450,7 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
/// </summary>
|
||||
/// <param name="inventoryItems">Items to hash</param>
|
||||
/// <returns>InventoryItemHash</returns>
|
||||
public static InventoryItemHash GetInventoryItemHash(this List<Item> inventoryItems)
|
||||
public static InventoryItemHash GetInventoryItemHash(this IEnumerable<Item> inventoryItems)
|
||||
{
|
||||
// Group by parentId + turn value into mongoId as we've filtered out non-mongoId values
|
||||
var byParentId = inventoryItems
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
/// <returns>rouble amount</returns>
|
||||
private static double GetContainerRoubleTotalByLevel(
|
||||
int botLevel,
|
||||
List<MinMaxLootValue> containerLootValuesPool
|
||||
IEnumerable<MinMaxLootValue> containerLootValuesPool
|
||||
)
|
||||
{
|
||||
var matchingValue = containerLootValuesPool.FirstOrDefault(minMaxValue =>
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
/// </summary>
|
||||
/// <param name="profile">Profile to get quest items from</param>
|
||||
/// <returns>List of item objects</returns>
|
||||
public static List<Item> GetQuestItemsInProfile(this PmcData profile)
|
||||
public static IEnumerable<Item> GetQuestItemsInProfile(this PmcData profile)
|
||||
{
|
||||
return profile
|
||||
?.Inventory?.Items.Where(i => i.ParentId == profile.Inventory.QuestRaidItems)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
/// <param name="furtherFilter">OPTIONAL - Additional filter code to run</param>
|
||||
/// <returns></returns>
|
||||
public static List<QuestCondition> GetQuestConditions(
|
||||
this List<QuestCondition> questConditions,
|
||||
this IEnumerable<QuestCondition> questConditions,
|
||||
Func<QuestCondition, List<QuestCondition>>? furtherFilter = null
|
||||
)
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
}
|
||||
|
||||
public static List<QuestCondition> GetLevelConditions(
|
||||
this List<QuestCondition> questConditions,
|
||||
this IEnumerable<QuestCondition> questConditions,
|
||||
Func<QuestCondition, List<QuestCondition>>? furtherFilter = null
|
||||
)
|
||||
{
|
||||
@@ -27,7 +27,7 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
}
|
||||
|
||||
public static List<QuestCondition> GetLoyaltyConditions(
|
||||
this List<QuestCondition> questConditions,
|
||||
this IEnumerable<QuestCondition> questConditions,
|
||||
Func<QuestCondition, List<QuestCondition>>? furtherFilter = null
|
||||
)
|
||||
{
|
||||
@@ -35,7 +35,7 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
}
|
||||
|
||||
public static List<QuestCondition> GetStandingConditions(
|
||||
this List<QuestCondition> questConditions,
|
||||
this IEnumerable<QuestCondition> questConditions,
|
||||
Func<QuestCondition, List<QuestCondition>>? furtherFilter = null
|
||||
)
|
||||
{
|
||||
@@ -43,7 +43,7 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
}
|
||||
|
||||
private static List<QuestCondition> FilterConditions(
|
||||
List<QuestCondition> questConditions,
|
||||
IEnumerable<QuestCondition> questConditions,
|
||||
string questType,
|
||||
Func<QuestCondition, List<QuestCondition>>? furtherFilter = null
|
||||
)
|
||||
|
||||
@@ -631,9 +631,9 @@ public class BotGenerator(
|
||||
/// </summary>
|
||||
/// <param name="bodyParts">Body parts</param>
|
||||
/// <returns>Part with the lowest hp</returns>
|
||||
protected BodyPart? GetLowestHpBodyPart(List<BodyPart> bodyParts)
|
||||
protected BodyPart? GetLowestHpBodyPart(IEnumerable<BodyPart> bodyParts)
|
||||
{
|
||||
if (bodyParts.Count == 0)
|
||||
if (!bodyParts.Any())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ public class BotInventoryGenerator(
|
||||
/// </summary>
|
||||
/// <param name="equipmentChances">Chances bot has certain equipment</param>
|
||||
/// <returns>What slots bot should have weapons generated for</returns>
|
||||
public List<DesiredWeapons> GetDesiredWeaponsForBot(Chances equipmentChances)
|
||||
public IEnumerable<DesiredWeapons> GetDesiredWeaponsForBot(Chances equipmentChances)
|
||||
{
|
||||
var shouldSpawnPrimary = randomUtil.GetChance100(
|
||||
equipmentChances.EquipmentChances["FirstPrimaryWeapon"]
|
||||
|
||||
@@ -667,7 +667,7 @@ public class BotLootGenerator(
|
||||
/// </summary>
|
||||
/// <param name="walletId"> Wallet to add loot to</param>
|
||||
/// <returns>Generated list of currency stacks with the wallet as their parent</returns>
|
||||
public List<List<Item>> CreateWalletLoot(string walletId)
|
||||
public List<List<Item>> CreateWalletLoot(MongoId walletId)
|
||||
{
|
||||
List<List<Item>> result = [];
|
||||
|
||||
|
||||
@@ -161,7 +161,8 @@ public class BotWeaponGenerator(
|
||||
slotName,
|
||||
weaponItemTemplate,
|
||||
botRole
|
||||
);
|
||||
)
|
||||
.ToList();
|
||||
|
||||
// Chance to add randomised weapon enhancement
|
||||
if (isPmc && randomUtil.GetChance100(_pmcConfig.WeaponHasEnhancementChancePercent))
|
||||
@@ -276,7 +277,7 @@ public class BotWeaponGenerator(
|
||||
protected void AddCartridgeToChamber(
|
||||
List<Item> weaponWithModsList,
|
||||
MongoId ammoTemplate,
|
||||
List<string> chamberSlotIds
|
||||
IEnumerable<string> chamberSlotIds
|
||||
)
|
||||
{
|
||||
foreach (var slotId in chamberSlotIds)
|
||||
@@ -315,7 +316,7 @@ public class BotWeaponGenerator(
|
||||
/// <param name="weaponItemTemplate">Database template for weapon</param>
|
||||
/// <param name="botRole">For durability values</param>
|
||||
/// <returns>Base weapon item in a list</returns>
|
||||
protected List<Item> ConstructWeaponBaseList(
|
||||
protected IEnumerable<Item> ConstructWeaponBaseList(
|
||||
MongoId weaponTemplate,
|
||||
string weaponParentId,
|
||||
string equipmentSlot,
|
||||
@@ -405,7 +406,7 @@ public class BotWeaponGenerator(
|
||||
/// <param name="weaponItemList">Weapon + mods</param>
|
||||
/// <param name="botRole">Role of bot weapon is for</param>
|
||||
/// <returns>True if valid</returns>
|
||||
protected bool IsWeaponValid(List<Item> weaponItemList, string botRole)
|
||||
protected bool IsWeaponValid(IEnumerable<Item> weaponItemList, string botRole)
|
||||
{
|
||||
foreach (var mod in weaponItemList)
|
||||
{
|
||||
@@ -878,12 +879,12 @@ public class BotWeaponGenerator(
|
||||
}
|
||||
|
||||
// Magazine, usually
|
||||
var parentItem = itemHelper.GetItem(magazineTemplate.Parent).Value;
|
||||
var parentDbItem = itemHelper.GetItem(magazineTemplate.Parent).Value;
|
||||
|
||||
// Revolver shotgun (MTs-255-12) uses a magazine with chambers, not cartridges ("camora_xxx")
|
||||
// Exchange of the camora ammo is not necessary we could also just check for stackSize > 0 here
|
||||
// and remove the else
|
||||
if (botWeaponGeneratorHelper.MagazineIsCylinderRelated(parentItem.Name))
|
||||
if (botWeaponGeneratorHelper.MagazineIsCylinderRelated(parentDbItem.Name))
|
||||
{
|
||||
FillCamorasWithAmmo(weaponMods, magazine.Id, cartridgeTemplate);
|
||||
}
|
||||
@@ -904,9 +905,9 @@ public class BotWeaponGenerator(
|
||||
/// <param name="weaponMods">Weapon with children.</param>
|
||||
/// <param name="ubglMod">Underbarrrel grenade launcher item.</param>
|
||||
/// <param name="ubglAmmoTpl">Grenade ammo template.</param>
|
||||
protected void FillUbgl(List<Item> weaponMods, Item ubglMod, MongoId ubglAmmoTpl)
|
||||
protected void FillUbgl(IEnumerable<Item> weaponMods, Item ubglMod, MongoId ubglAmmoTpl)
|
||||
{
|
||||
weaponMods.Add(
|
||||
weaponMods.Append(
|
||||
new Item
|
||||
{
|
||||
Id = new MongoId(),
|
||||
@@ -975,7 +976,11 @@ public class BotWeaponGenerator(
|
||||
/// <param name="weaponMods">Weapon mods to find and update camora mod(s) from</param>
|
||||
/// <param name="magazineId">Magazine id to find and add to</param>
|
||||
/// <param name="ammoTpl">Ammo template id to hydrate with</param>
|
||||
protected void FillCamorasWithAmmo(List<Item> weaponMods, MongoId magazineId, MongoId ammoTpl)
|
||||
protected void FillCamorasWithAmmo(
|
||||
IEnumerable<Item> weaponMods,
|
||||
MongoId magazineId,
|
||||
MongoId ammoTpl
|
||||
)
|
||||
{
|
||||
// for CylinderMagazine we exchange the ammo in the "camoras".
|
||||
// This might not be necessary since we already filled the camoras with a random whitelisted and compatible ammo type,
|
||||
|
||||
@@ -318,7 +318,7 @@ public class BotGeneratorHelper(
|
||||
/// <param name="equipmentSlot">Slot the item will be placed into</param>
|
||||
/// <returns>false if no incompatibilities, also has incompatibility reason</returns>
|
||||
public ChooseRandomCompatibleModResult IsItemIncompatibleWithCurrentItems(
|
||||
List<Item> itemsEquipped,
|
||||
IEnumerable<Item> itemsEquipped,
|
||||
MongoId tplToCheck,
|
||||
string equipmentSlot
|
||||
)
|
||||
@@ -335,9 +335,10 @@ public class BotGeneratorHelper(
|
||||
}
|
||||
|
||||
// TODO: Can probably be optimized to cache itemTemplates as items are added to inventory
|
||||
var equippedItemsDb = itemsEquipped
|
||||
.Select(equippedItem => itemHelper.GetItem(equippedItem.Template).Value)
|
||||
.ToList();
|
||||
var equippedItemsDb = itemsEquipped.Select(equippedItem =>
|
||||
itemHelper.GetItem(equippedItem.Template).Value
|
||||
);
|
||||
|
||||
var (itemIsValid, itemToEquip) = itemHelper.GetItem(tplToCheck);
|
||||
|
||||
if (!itemIsValid)
|
||||
@@ -380,7 +381,7 @@ public class BotGeneratorHelper(
|
||||
}
|
||||
|
||||
// Does an equipped item have a property that blocks the desired item - check for prop "BlocksX" .e.g BlocksEarpiece / BlocksFaceCover
|
||||
var templateItems = equippedItemsDb.ToList();
|
||||
var templateItems = equippedItemsDb;
|
||||
var blockingItem = templateItems.FirstOrDefault(item =>
|
||||
HasBlockingProperty(item, equipmentSlot)
|
||||
);
|
||||
@@ -542,7 +543,7 @@ public class BotGeneratorHelper(
|
||||
HashSet<EquipmentSlots> equipmentSlots,
|
||||
MongoId rootItemId,
|
||||
MongoId rootItemTplId,
|
||||
List<Item> itemWithChildren,
|
||||
IEnumerable<Item> itemWithChildren,
|
||||
BotBaseInventory inventory,
|
||||
HashSet<string>? containersIdFull = null
|
||||
)
|
||||
@@ -718,7 +719,7 @@ public class BotGeneratorHelper(
|
||||
/// <returns></returns>
|
||||
protected List<Item> GetContainerItemsWithChildren(
|
||||
IEnumerable<Item> containerRootItems,
|
||||
List<Item> inventoryItems
|
||||
IEnumerable<Item> inventoryItems
|
||||
)
|
||||
{
|
||||
var result = new List<Item>();
|
||||
@@ -729,7 +730,7 @@ public class BotGeneratorHelper(
|
||||
}
|
||||
|
||||
// Filter out all items without location prop, (child items)
|
||||
var itemsWithoutLocation = inventoryItems.Where(item => item.Location is null).ToList();
|
||||
var itemsWithoutLocation = inventoryItems.Where(item => item.Location is null);
|
||||
foreach (var rootItem in containerRootItems)
|
||||
{
|
||||
// Check item in container for children, store for later insertion into `containerItemsToCheck`
|
||||
|
||||
@@ -172,7 +172,7 @@ public class InventoryHelper(
|
||||
/// </summary>
|
||||
/// <param name="itemWithChildren">An item</param>
|
||||
/// <param name="foundInRaid">Item was found in raid</param>
|
||||
protected void SetFindInRaidStatusForItem(List<Item> itemWithChildren, bool foundInRaid)
|
||||
protected void SetFindInRaidStatusForItem(IEnumerable<Item> itemWithChildren, bool foundInRaid)
|
||||
{
|
||||
foreach (var item in itemWithChildren)
|
||||
{
|
||||
@@ -214,7 +214,10 @@ public class InventoryHelper(
|
||||
/// <param name="sessionId">Player id</param>
|
||||
/// <param name="itemsWithChildren">Array of items with children to try and fit</param>
|
||||
/// <returns>True all items fit</returns>
|
||||
public bool CanPlaceItemsInInventory(MongoId sessionId, List<List<Item>> itemsWithChildren)
|
||||
public bool CanPlaceItemsInInventory(
|
||||
MongoId sessionId,
|
||||
IEnumerable<List<Item>> itemsWithChildren
|
||||
)
|
||||
{
|
||||
var pmcData = profileHelper.GetPmcProfile(sessionId);
|
||||
|
||||
@@ -238,7 +241,10 @@ public class InventoryHelper(
|
||||
/// <param name="containerFS2D">Container grid to fit items into</param>
|
||||
/// <param name="itemsWithChildren">Items to try and fit into grid</param>
|
||||
/// <returns>True all fit</returns>
|
||||
public bool CanPlaceItemsInContainer(int[,] containerFS2D, List<List<Item>> itemsWithChildren)
|
||||
public bool CanPlaceItemsInContainer(
|
||||
int[,] containerFS2D,
|
||||
IEnumerable<List<Item>> itemsWithChildren
|
||||
)
|
||||
{
|
||||
return itemsWithChildren.All(itemWithChildren =>
|
||||
CanPlaceItemInContainer(containerFS2D, itemWithChildren)
|
||||
@@ -665,7 +671,7 @@ public class InventoryHelper(
|
||||
/// <param name="itemId">Items id to get size of</param>
|
||||
/// <param name="inventoryItems"></param>
|
||||
/// <returns>[width, height]</returns>
|
||||
public (int, int) GetItemSize(MongoId itemTpl, MongoId itemId, List<Item> inventoryItems)
|
||||
public (int, int) GetItemSize(MongoId itemTpl, MongoId itemId, IEnumerable<Item> inventoryItems)
|
||||
{
|
||||
// -> Prepares item Width and height returns [sizeX, sizeY]
|
||||
return GetSizeByInventoryItemHash(itemTpl, itemId, inventoryItems.GetInventoryItemHash());
|
||||
@@ -859,7 +865,7 @@ public class InventoryHelper(
|
||||
public int[,] GetContainerMap(
|
||||
int containerSizeHorizontalX,
|
||||
int containerSizeVerticalY,
|
||||
List<Item> itemList,
|
||||
IEnumerable<Item> itemList,
|
||||
MongoId containerId
|
||||
)
|
||||
{
|
||||
@@ -1179,7 +1185,7 @@ public class InventoryHelper(
|
||||
/// <returns>True if move was successful</returns>
|
||||
public bool MoveItemInternal(
|
||||
PmcData pmcData,
|
||||
List<Item> inventoryItems,
|
||||
IEnumerable<Item> inventoryItems,
|
||||
InventoryMoveRequestData moveRequest,
|
||||
out string errorMessage
|
||||
)
|
||||
@@ -1193,18 +1199,18 @@ public class InventoryHelper(
|
||||
);
|
||||
if (matchingInventoryItem is null)
|
||||
{
|
||||
var noMatchingItemMesage =
|
||||
var noMatchingItemMessage =
|
||||
$"Unable to move item: {moveRequest.Item}, cannot find in inventory";
|
||||
logger.Error(noMatchingItemMesage);
|
||||
logger.Error(noMatchingItemMessage);
|
||||
|
||||
errorMessage = noMatchingItemMesage;
|
||||
errorMessage = noMatchingItemMessage;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
logger.Debug(
|
||||
$"{moveRequest.Action} item: {moveRequest.Item} from slotid: {matchingInventoryItem.SlotId} to container: {moveRequest.To.Container}"
|
||||
$"{moveRequest.Action} item: {moveRequest.Item} from slotId: {matchingInventoryItem.SlotId} to container: {moveRequest.To.Container}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1291,7 +1297,7 @@ public class InventoryHelper(
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
/// <param name="request"></param>
|
||||
protected void HandleCartridgeMove(List<Item> items, InventoryMoveRequestData request)
|
||||
protected void HandleCartridgeMove(IEnumerable<Item> items, InventoryMoveRequestData request)
|
||||
{
|
||||
// Not moving item into a cartridge slot, skip
|
||||
if (request.To.Container != "cartridges")
|
||||
@@ -1326,7 +1332,7 @@ public class InventoryHelper(
|
||||
return _inventoryConfig;
|
||||
}
|
||||
|
||||
public void ValidateInventoryUsesMongoIds(List<Item> itemsToValidate)
|
||||
public void ValidateInventoryUsesMongoIds(IEnumerable<Item> itemsToValidate)
|
||||
{
|
||||
var errors = itemsToValidate
|
||||
.Where(item => !item.Id.IsValidMongoId())
|
||||
|
||||
@@ -566,13 +566,13 @@ public class ItemHelper(
|
||||
/// <param name="skipArmorItemsWithoutDurability">Skip over armor items without durability</param>
|
||||
/// <returns>% quality modifier between 0 and 1</returns>
|
||||
public double GetItemQualityModifierForItems(
|
||||
List<Item> itemWithChildren,
|
||||
IEnumerable<Item> itemWithChildren,
|
||||
bool skipArmorItemsWithoutDurability = false
|
||||
)
|
||||
{
|
||||
if (IsOfBaseclass(itemWithChildren[0].Template, BaseClasses.WEAPON))
|
||||
if (IsOfBaseclass(itemWithChildren.First().Template, BaseClasses.WEAPON))
|
||||
{
|
||||
return Math.Round(GetItemQualityModifier(itemWithChildren[0]), 5);
|
||||
return Math.Round(GetItemQualityModifier(itemWithChildren.First()), 5);
|
||||
}
|
||||
|
||||
var qualityModifier = 0D;
|
||||
@@ -1712,13 +1712,12 @@ public class ItemHelper(
|
||||
/// </summary>
|
||||
/// <param name="desiredBaseType">Item base type wanted</param>
|
||||
/// <returns>Array of tpls</returns>
|
||||
public List<MongoId> GetItemTplsOfBaseType(string desiredBaseType)
|
||||
public IEnumerable<MongoId> GetItemTplsOfBaseType(string desiredBaseType)
|
||||
{
|
||||
return databaseService
|
||||
.GetItems()
|
||||
.Values.Where(item => item.Parent == desiredBaseType)
|
||||
.Select(item => item.Id)
|
||||
.ToList();
|
||||
.Select(item => item.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -68,7 +68,7 @@ public class BotWeaponModLimitService(
|
||||
TemplateItem modTemplate,
|
||||
BotModLimits modLimits,
|
||||
TemplateItem modsParent,
|
||||
List<Item> weapon
|
||||
IEnumerable<Item> weapon
|
||||
)
|
||||
{
|
||||
// If mod or mods parent is the NcSTAR MPR45 Backup mount, allow it as it looks cool
|
||||
@@ -115,11 +115,11 @@ public class BotWeaponModLimitService(
|
||||
);
|
||||
}
|
||||
|
||||
// Don't allow multple mounts on a weapon (except when mount is on another mount)
|
||||
// Don't allow multiple mounts on a weapon (except when mount is on another mount)
|
||||
// Fail when:
|
||||
// Over or at scope limit on weapon
|
||||
// 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
|
||||
// Mount has one slot and it is for a mod_scope
|
||||
if (
|
||||
modLimits.Scope.Count >= modLimits.ScopeMax
|
||||
&& modTemplate.Properties.Slots?.Count == 1
|
||||
|
||||
@@ -187,7 +187,7 @@ public class FenceService(
|
||||
/// <param name="itemTpl"> The item tpl to calculate the fence price for </param>
|
||||
/// <param name="items"> The items (with its children) to calculate fence price for </param>
|
||||
/// <returns> Price of the item for Fence </returns>
|
||||
public double? GetItemPrice(MongoId itemTpl, List<Item> items)
|
||||
public double? GetItemPrice(MongoId itemTpl, IEnumerable<Item> items)
|
||||
{
|
||||
return itemHelper.IsOfBaseclass(itemTpl, BaseClasses.AMMO_BOX)
|
||||
? GetAmmoBoxPrice(items) * traderConfig.Fence.ItemPriceMult
|
||||
@@ -200,7 +200,7 @@ public class FenceService(
|
||||
/// </summary>
|
||||
/// <param name="items"> The ammo box (and all its children ammo items) </param>
|
||||
/// <returns> The price of the ammo box </returns>
|
||||
protected double? GetAmmoBoxPrice(List<Item> items)
|
||||
protected double? GetAmmoBoxPrice(IEnumerable<Item> items)
|
||||
{
|
||||
double? total = 0D;
|
||||
foreach (var item in items)
|
||||
@@ -478,7 +478,7 @@ public class FenceService(
|
||||
/// <param name="generationValues"> Base counts assorts should be adjusted to </param>
|
||||
/// <returns> GenerationAssortValues object with adjustments needed to reach desired state </returns>
|
||||
protected GenerationAssortValues GetItemCountsToGenerate(
|
||||
List<Item> assortItems,
|
||||
IEnumerable<Item> assortItems,
|
||||
GenerationAssortValues generationValues
|
||||
)
|
||||
{
|
||||
@@ -546,7 +546,7 @@ public class FenceService(
|
||||
/// </summary>
|
||||
/// <param name="assort"> Trader assort to remove item from </param>
|
||||
/// <param name="rootItems"> Pool of root items to pick from to remove </param>
|
||||
protected void RemoveRandomItemFromAssorts(TraderAssort assort, List<Item> rootItems)
|
||||
protected void RemoveRandomItemFromAssorts(TraderAssort assort, IEnumerable<Item> rootItems)
|
||||
{
|
||||
// Pick a random root item to remove from Fence
|
||||
var rootItemToAdjust = randomUtil.GetArrayValue(rootItems);
|
||||
@@ -923,7 +923,7 @@ public class FenceService(
|
||||
protected Item? GetMatchingItem(
|
||||
Item rootItemBeingAdded,
|
||||
TemplateItem itemDbDetails,
|
||||
List<List<Item>> itemsWithChildren
|
||||
IEnumerable<List<Item>> itemsWithChildren
|
||||
)
|
||||
{
|
||||
// Get matching root items
|
||||
@@ -967,7 +967,7 @@ public class FenceService(
|
||||
&& rootItemBeingAdded.Upd?.MedKit?.HpResource == item.Upd?.MedKit?.HpResource
|
||||
)
|
||||
// e.g. bandages with multiple use
|
||||
// Both undefined === both max resoruce left
|
||||
// Both undefined === both max resource left
|
||||
{
|
||||
return item;
|
||||
}
|
||||
@@ -1243,7 +1243,7 @@ public class FenceService(
|
||||
/// </summary>
|
||||
/// <param name="armor"> Armor item array to add mods into </param>
|
||||
/// <param name="itemDbDetails"> Armor items db template </param>
|
||||
protected void RandomiseArmorModDurability(List<Item> armor, TemplateItem itemDbDetails)
|
||||
protected void RandomiseArmorModDurability(IEnumerable<Item> armor, TemplateItem itemDbDetails)
|
||||
{
|
||||
// Armor has no mods, nothing to randomise
|
||||
if (itemDbDetails.Properties.Slots == null)
|
||||
@@ -1251,20 +1251,18 @@ public class FenceService(
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for and adjust soft insert durability values
|
||||
var requiredSlots = itemDbDetails
|
||||
.Properties.Slots?.Where(slot => slot.Required ?? false)
|
||||
.ToList();
|
||||
if ((requiredSlots?.Count ?? 0) > 1)
|
||||
var requiredSlots = itemDbDetails.Properties.Slots?.Where(slot => slot.Required ?? false);
|
||||
if (requiredSlots is not null && requiredSlots.Any())
|
||||
{
|
||||
// Has soft inserts, randomise
|
||||
RandomiseArmorSoftInsertDurabilities(requiredSlots, armor);
|
||||
}
|
||||
|
||||
// Check for and adjust plate durability values
|
||||
var plateSlots = itemDbDetails
|
||||
.Properties.Slots?.Where(slot => itemHelper.IsRemovablePlateSlot(slot.Name))
|
||||
.ToList();
|
||||
if ((plateSlots?.Count ?? 0) > 1)
|
||||
var plateSlots = itemDbDetails.Properties.Slots?.Where(slot =>
|
||||
itemHelper.IsRemovablePlateSlot(slot.Name)
|
||||
);
|
||||
if (plateSlots is not null && plateSlots.Any())
|
||||
{
|
||||
RandomiseArmorInsertsDurabilities(plateSlots, armor);
|
||||
}
|
||||
@@ -1276,8 +1274,8 @@ public class FenceService(
|
||||
/// <param name="softInsertSlots"> Slots of items to randomise </param>
|
||||
/// <param name="armorItemAndMods"> Array of armor + inserts to get items from </param>
|
||||
protected void RandomiseArmorSoftInsertDurabilities(
|
||||
List<Slot> softInsertSlots,
|
||||
List<Item> armorItemAndMods
|
||||
IEnumerable<Slot> softInsertSlots,
|
||||
IEnumerable<Item> armorItemAndMods
|
||||
)
|
||||
{
|
||||
foreach (var requiredSlot in softInsertSlots)
|
||||
@@ -1308,7 +1306,7 @@ public class FenceService(
|
||||
|
||||
itemHelper.AddUpdObjectToItem(modItemToAdjust);
|
||||
|
||||
// Ensure property isn't null
|
||||
// Fence assorts can be null, ensure they have defaults
|
||||
modItemToAdjust.Upd.Repairable ??= new UpdRepairable
|
||||
{
|
||||
Durability = modItemDbDetails.Properties.MaxDurability,
|
||||
@@ -1343,8 +1341,8 @@ public class FenceService(
|
||||
/// <param name="plateSlots"> Slots of items to randomise </param>
|
||||
/// <param name="armorItemAndMods"> Array of armor + inserts to get items from </param>
|
||||
protected void RandomiseArmorInsertsDurabilities(
|
||||
List<Slot> plateSlots,
|
||||
List<Item> armorItemAndMods
|
||||
IEnumerable<Slot> plateSlots,
|
||||
IEnumerable<Item> armorItemAndMods
|
||||
)
|
||||
{
|
||||
foreach (var plateSlot in plateSlots)
|
||||
@@ -1356,8 +1354,6 @@ public class FenceService(
|
||||
continue;
|
||||
}
|
||||
|
||||
var armorWithMods = armorItemAndMods;
|
||||
|
||||
var modItemDbDetails = itemHelper.GetItem(plateTpl.Value).Value;
|
||||
|
||||
// Chance to remove plate
|
||||
@@ -1386,14 +1382,14 @@ public class FenceService(
|
||||
);
|
||||
|
||||
// Find items mod to apply durability changes to
|
||||
var modItemToAdjust = armorWithMods.FirstOrDefault(mod =>
|
||||
var modItemToAdjust = armorItemAndMods.FirstOrDefault(mod =>
|
||||
string.Equals(mod.SlotId, plateSlot.Name, StringComparison.OrdinalIgnoreCase)
|
||||
);
|
||||
|
||||
if (modItemToAdjust == null)
|
||||
{
|
||||
logger.Warning(
|
||||
$"Unable to randomise armor items {armorWithMods[0].Template} {plateSlot.Name} slot as it cannot be found, skipping"
|
||||
$"Unable to randomise armor items {armorItemAndMods.First().Template} {plateSlot.Name} slot as it cannot be found, skipping"
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -926,7 +926,7 @@ public class LocationLifecycleService(
|
||||
|
||||
if (isDead)
|
||||
{
|
||||
if (lostQuestItems.Count > 0)
|
||||
if (lostQuestItems.Any())
|
||||
// MUST occur AFTER quests have post raid quest data has been merged "processPostRaidQuests()"
|
||||
// Player is dead + had quest items, check and fix any broken find item quests
|
||||
{
|
||||
@@ -981,8 +981,8 @@ public class LocationLifecycleService(
|
||||
/// <param name="profileQuests"> Quest status data from player profile </param>
|
||||
protected void CheckForAndFixPickupQuestsAfterDeath(
|
||||
MongoId sessionId,
|
||||
List<Item> lostQuestItems,
|
||||
List<QuestStatus> profileQuests
|
||||
IEnumerable<Item> lostQuestItems,
|
||||
IEnumerable<QuestStatus> profileQuests
|
||||
)
|
||||
{
|
||||
// Exclude completed quests
|
||||
|
||||
@@ -117,7 +117,7 @@ public class MailSendService(
|
||||
MongoId? trader,
|
||||
MessageType messageType,
|
||||
string messageLocaleId,
|
||||
List<Item>? items,
|
||||
IEnumerable<Item>? items,
|
||||
long? maxStorageTimeSeconds = 172800,
|
||||
SystemData? systemData = null,
|
||||
MessageContentRagfair? ragfair = null
|
||||
@@ -145,9 +145,8 @@ public class MailSendService(
|
||||
Items = [],
|
||||
};
|
||||
|
||||
// add items to message
|
||||
|
||||
if (items?.Count > 0)
|
||||
// Add items to message
|
||||
if (items is not null && items.Any())
|
||||
{
|
||||
details.Items.AddRange(items);
|
||||
details.ItemsMaxStorageLifetimeSeconds =
|
||||
|
||||
Reference in New Issue
Block a user