diff --git a/Libraries/SPTarkov.Server.Core/Controllers/QuestController.cs b/Libraries/SPTarkov.Server.Core/Controllers/QuestController.cs index 5a57183d..28e3dcf3 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/QuestController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/QuestController.cs @@ -209,7 +209,7 @@ public class QuestController( ) { var quest = questHelper.GetQuestFromDb(request.QuestId, pmcData); - List handoverQuestTypes = ["HandoverItem", "WeaponAssembly"]; + HashSet handoverQuestTypes = ["HandoverItem", "WeaponAssembly"]; var output = eventOutputHolder.GetOutput(sessionID); var isItemHandoverQuest = true; diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotEquipmentModGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotEquipmentModGenerator.cs index aa742b3e..d1cd9fa3 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotEquipmentModGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotEquipmentModGenerator.cs @@ -197,7 +197,8 @@ public class BotEquipmentModGenerator( ); switch (plateSlotFilteringOutcome.Result) { - case Result.UNKNOWN_FAILURE or Result.NO_DEFAULT_FILTER: + case Result.UNKNOWN_FAILURE + or Result.NO_DEFAULT_FILTER: if (logger.IsLogEnabled(LogLevel.Debug)) { logger.Debug( @@ -844,8 +845,8 @@ public class BotEquipmentModGenerator( return item.Properties.Slots is null || !item.Properties.Slots.Any() - && item.Properties.Cartridges?.Count == 0 - && item.Properties.Chambers?.Count == 0; + && !item.Properties.Cartridges.Any() + && !item.Properties.Chambers.Any(); } /// @@ -1342,7 +1343,7 @@ public class BotEquipmentModGenerator( // Filter modpool to only items that appear in parents allowed list preFilteredModPool = preFilteredModPool - .Where(tpl => parentSlot.Props.Filters[0].Filter.Contains(tpl)) + .Where(tpl => parentSlot.Props.Filters.First().Filter.Contains(tpl)) .ToHashSet(); if (preFilteredModPool.Count == 0) { @@ -1554,7 +1555,8 @@ public class BotEquipmentModGenerator( StringComparison.Ordinal ) ) - ?.Props.Filters?[0].Filter; + ?.Props.Filters?.First() + .Filter; // Mod isn't in existing pool, only add if it has no children and exists inside parent filter if ( @@ -1721,7 +1723,7 @@ public class BotEquipmentModGenerator( ) { // Find compatible mods and make an array of them - var allowedItems = parentSlot.Props.Filters[0].Filter; + var allowedItems = parentSlot.Props.Filters.First().Filter; // Find mod item that fits slot from sorted mod array var exhaustableModPool = CreateExhaustableArray(allowedItems); @@ -1964,9 +1966,9 @@ public class BotEquipmentModGenerator( modPool[cylinderMagTemplate.Id] = new Dictionary>(); foreach (var camora in camoraSlots) { - modPool[cylinderMagTemplate.Id][camora.Name] = camora.Props.Filters?[ - 0 - ].Filter.ToHashSet(); + modPool[cylinderMagTemplate.Id][camora.Name] = camora + .Props.Filters.First() + .Filter.ToHashSet(); } itemModPool = modPool[cylinderMagTemplate.Id]; diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs index 784b748a..0bbb4a8a 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs @@ -228,7 +228,7 @@ public class BotWeaponGenerator( // Add cartridge(s) to gun chamber(s) if ( - weaponItemTemplate.Properties?.Chambers?.Count > 0 + (weaponItemTemplate.Properties?.Chambers).Any() && weaponItemTemplate .Properties.Chambers.FirstOrDefault() .Props.Filters.FirstOrDefault() @@ -768,7 +768,8 @@ public class BotWeaponGenerator( var cartridges = weaponTemplate .Properties?.Chambers?.FirstOrDefault() - ?.Props?.Filters?[0].Filter; + ?.Props?.Filters?.First() + .Filter; if (cartridges is not null) { return cartridges; @@ -845,7 +846,10 @@ public class BotWeaponGenerator( if (!string.IsNullOrEmpty(weaponTemplate.Properties.LinkedWeapon)) { var ammoInChamber = itemHelper.GetItem( - weaponTemplate.Properties.Chambers[0].Props.Filters[0].Filter.FirstOrDefault() + weaponTemplate + .Properties.Chambers.First() + .Props.Filters.First() + .Filter.FirstOrDefault() ); return !ammoInChamber.Key ? null : ammoInChamber.Value.Properties.Caliber; } diff --git a/Libraries/SPTarkov.Server.Core/Generators/FenceBaseAssortGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/FenceBaseAssortGenerator.cs index 802c274d..6765a127 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/FenceBaseAssortGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/FenceBaseAssortGenerator.cs @@ -236,8 +236,8 @@ public class FenceBaseAssortGenerator( { // Get the cartridge tpl found inside ammo box var cartridgeTplInBox = rootItemDb - .Properties.StackSlots[0] - .Props.Filters[0] + .Properties.StackSlots.First() + .Props.Filters.First() .Filter.FirstOrDefault(); // Look up cartridge tpl in db @@ -288,9 +288,9 @@ public class FenceBaseAssortGenerator( foreach (var requiredSlot in requiredSlots) { var modItemDbDetails = itemHelper - .GetItem(requiredSlot.Props.Filters[0].Plate.Value) + .GetItem(requiredSlot.Props.Filters.First().Plate.Value) .Value; - var plateTpl = requiredSlot.Props.Filters[0].Plate; // `Plate` property appears to be the 'default' item for slot + var plateTpl = requiredSlot.Props.Filters.First().Plate; // `Plate` property appears to be the 'default' item for slot if (plateTpl is null || plateTpl.Value.IsEmpty()) // Some bsg plate properties are empty, skip mod { @@ -325,7 +325,7 @@ public class FenceBaseAssortGenerator( { foreach (var plateSlot in plateSlots) { - var plateTpl = plateSlot.Props.Filters[0].Plate; + var plateTpl = plateSlot.Props.Filters.First().Plate; if (string.IsNullOrEmpty(plateTpl)) // Bsg data lacks a default plate, skip adding mod { @@ -337,7 +337,7 @@ public class FenceBaseAssortGenerator( new Item { Id = new MongoId(), - Template = plateSlot.Props.Filters[0].Plate.Value, // `Plate` property appears to be the 'default' item for slot + Template = plateSlot.Props.Filters.First().Plate.Value, // `Plate` property appears to be the 'default' item for slot ParentId = armor[0].Id, SlotId = plateSlot.Name, Upd = new Upd diff --git a/Libraries/SPTarkov.Server.Core/Generators/WeaponGen/Implementations/ExternalInventoryMagGen.cs b/Libraries/SPTarkov.Server.Core/Generators/WeaponGen/Implementations/ExternalInventoryMagGen.cs index 3eedc338..58f10c52 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/WeaponGen/Implementations/ExternalInventoryMagGen.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/WeaponGen/Implementations/ExternalInventoryMagGen.cs @@ -190,7 +190,7 @@ public class ExternalInventoryMagGen( // All possible mags that fit into the weapon excluding blacklisted var magazinePool = magSlot - .Props.Filters[0] + .Props.Filters.First() .Filter.Where(x => !magazineBlacklist.Contains(x)) .Select(x => itemHelper.GetItem(x).Value); if (magazinePool is null) diff --git a/Libraries/SPTarkov.Server.Core/Helpers/BotGeneratorHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/BotGeneratorHelper.cs index f07b4f94..fe2cd7a1 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/BotGeneratorHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/BotGeneratorHelper.cs @@ -758,7 +758,7 @@ public class BotGeneratorHelper( var excludedFilter = propFilters?.FirstOrDefault()?.ExcludedFilter ?? []; var filter = propFilters?.FirstOrDefault()?.Filter ?? []; - if (propFilters?.Count == 0) + if (!propFilters.Any()) // no filters, item is fine to add { return true; diff --git a/Libraries/SPTarkov.Server.Core/Helpers/BotWeaponGeneratorHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/BotWeaponGeneratorHelper.cs index 8a3124db..5d73f035 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/BotWeaponGeneratorHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/BotWeaponGeneratorHelper.cs @@ -37,7 +37,7 @@ public class BotWeaponGeneratorHelper( var firstSlotAmmoTpl = magTemplate .Properties.Cartridges.FirstOrDefault() - ?.Props.Filters[0] + ?.Props.Filters.First() .Filter.FirstOrDefault() ?? new MongoId(null); var ammoMaxStackSize = itemHelper.GetItem(firstSlotAmmoTpl).Value?.Properties?.StackMaxSize ?? 1; @@ -53,7 +53,7 @@ public class BotWeaponGeneratorHelper( } else { - chamberBulletCount = magTemplate.Properties.Cartridges?[0].MaxCount; + chamberBulletCount = magTemplate.Properties.Cartridges?.First().MaxCount; } // Get the amount of bullets that would fit in the internal magazine diff --git a/Libraries/SPTarkov.Server.Core/Helpers/ItemHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/ItemHelper.cs index f1a2de5b..7170823f 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/ItemHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/ItemHelper.cs @@ -1387,10 +1387,10 @@ public class ItemHelper( /// Item template from items db public void AddCartridgesToAmmoBox(List ammoBox, TemplateItem ammoBoxDetails) { - var ammoBoxMaxCartridgeCount = ammoBoxDetails.Properties.StackSlots[0].MaxCount; + var ammoBoxMaxCartridgeCount = ammoBoxDetails.Properties.StackSlots.First().MaxCount; var cartridgeTpl = ammoBoxDetails - .Properties.StackSlots[0] - .Props.Filters[0] + .Properties.StackSlots.First() + .Props.Filters.First() .Filter.FirstOrDefault(); var cartridgeDetails = GetItem(cartridgeTpl); var cartridgeMaxStackSize = cartridgeDetails.Value.Properties.StackMaxSize; @@ -1440,10 +1440,11 @@ public class ItemHelper( /// Item template from items db public void AddSingleStackCartridgesToAmmoBox(List ammoBox, TemplateItem ammoBoxDetails) { - var ammoBoxMaxCartridgeCount = ammoBoxDetails.Properties?.StackSlots?[0].MaxCount ?? 0; - var cartridgeTpl = ammoBoxDetails.Properties?.StackSlots?[0].Props?.Filters?[ - 0 - ].Filter?.FirstOrDefault(); + var ammoBoxMaxCartridgeCount = ammoBoxDetails.Properties?.StackSlots?.First().MaxCount ?? 0; + var cartridgeTpl = ammoBoxDetails + .Properties?.StackSlots?.First() + .Props?.Filters?.First() + .Filter?.FirstOrDefault(); ammoBox.Add( CreateCartridges(ammoBox[0].Id, cartridgeTpl.Value, (int)ammoBoxMaxCartridgeCount, 0) ); @@ -1610,7 +1611,7 @@ public class ItemHelper( /// Tpl of cartridge protected string? GetRandomValidCaliber(TemplateItem magTemplate) { - var ammoTpls = magTemplate.Properties.Cartridges[0].Props.Filters[0].Filter; + var ammoTpls = magTemplate.Properties.Cartridges.First().Props.Filters.First().Filter; var calibers = ammoTpls .Where(x => GetItem(x).Key) .Select(x => GetItem(x).Value.Properties.Caliber) diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Globals.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Globals.cs index 711107e5..62449acb 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Globals.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Globals.cs @@ -18,10 +18,10 @@ public record Globals public LocationInfection LocationInfection { get; set; } [JsonPropertyName("bot_presets")] - public List BotPresets { get; set; } + public IEnumerable BotPresets { get; set; } [JsonPropertyName("BotWeaponScatterings")] - public List BotWeaponScatterings { get; set; } + public IEnumerable BotWeaponScatterings { get; set; } [JsonPropertyName("ItemPresets")] public Dictionary ItemPresets { get; set; } @@ -48,7 +48,7 @@ public record PlayerSettings public double MinStepSoundVolumeMultiplier { get; set; } [JsonPropertyName("MovementRolloffMultipliers")] - public List MovementRolloffMultipliers { get; set; } + public IEnumerable MovementRolloffMultipliers { get; set; } [JsonPropertyName("OutdoorRolloffMult")] public double OutdoorRolloffMultiplier { get; set; } @@ -88,7 +88,7 @@ public record RadioBroadcastSettings public bool EnabledBroadcast { get; set; } [JsonPropertyName("RadioStations")] - public List RadioStations { get; set; } + public IEnumerable RadioStations { get; set; } } public record RadioStation @@ -181,10 +181,10 @@ public record ArtilleryMapSettings public double InitCalledShellingTime { get; set; } [JsonPropertyName("ShellingZones")] - public List ShellingZones { get; set; } + public IEnumerable ShellingZones { get; set; } [JsonPropertyName("Brigades")] - public List Brigades { get; set; } + public IEnumerable Brigades { get; set; } [JsonPropertyName("ArtilleryShellingAirDropSettings")] public ArtilleryShellingAirDropSettings ArtilleryShellingAirDropSettings { get; set; } @@ -235,7 +235,7 @@ public record ShellingZone public XYZ ExplosionDistanceRange { get; set; } [JsonPropertyName("AlarmStages")] - public List AlarmStages { get; set; } + public IEnumerable AlarmStages { get; set; } [JsonPropertyName("BeforeShellingSignalTime")] public double BeforeShellingSignalTime { get; set; } @@ -268,7 +268,7 @@ public record Brigade public double Id { get; set; } [JsonPropertyName("ArtilleryGuns")] - public List ArtilleryGuns { get; set; } + public IEnumerable ArtilleryGuns { get; set; } } public record ArtilleryGun @@ -1329,7 +1329,7 @@ public record Exp public Level Level { get; set; } [JsonPropertyName("loot_attempts")] - public List LootAttempts { get; set; } + public IEnumerable LootAttempts { get; set; } // Confirmed in client [JsonPropertyName("expForLevelOneDogtag")] @@ -1408,7 +1408,7 @@ public record MatchEnd public double TransitExperienceReward { get; set; } [JsonPropertyName("transit_mult")] - public List> TransitMultiplier { get; set; } + public IEnumerable> TransitMultiplier { get; set; } } public record Kill @@ -1507,7 +1507,7 @@ public record Armor public Dictionary? ExtensionData { get; set; } [JsonPropertyName("class")] - public List Classes { get; set; } + public IEnumerable Classes { get; set; } } public record Class @@ -1529,7 +1529,7 @@ public record Mastering public string Name { get; set; } [JsonPropertyName("Templates")] - public List Templates { get; set; } + public IEnumerable Templates { get; set; } [JsonPropertyName("Progress")] public double Progress { get; set; } @@ -1558,7 +1558,7 @@ public record Customization public Dictionary Feet { get; set; } [JsonPropertyName("CustomizationVoice")] - public List VoiceOptions { get; set; } + public IEnumerable VoiceOptions { get; set; } [JsonPropertyName("BodyParts")] public BodyParts BodyParts { get; set; } @@ -2281,7 +2281,7 @@ public record Stimulator public double BuffLoopTime { get; set; } - public Dictionary> Buffs { get; set; } + public Dictionary> Buffs { get; set; } } public record Buff @@ -2762,7 +2762,7 @@ public record RagFair public float RenewPricePerHour { get; set; } [JsonPropertyName("maxActiveOfferCount")] - public List MaxActiveOfferCount { get; set; } + public IEnumerable MaxActiveOfferCount { get; set; } [JsonPropertyName("balancerRemovePriceCoefficient")] public float BalancerRemovePriceCoefficient { get; set; } @@ -2810,7 +2810,7 @@ public record RagFair public double ChangePriceCoef { get; set; } [JsonPropertyName("ItemRestrictions")] - public List ItemRestrictions { get; set; } + public IEnumerable ItemRestrictions { get; set; } [JsonPropertyName("balancerUserItemSaleCooldownEnabled")] public bool BalancerUserItemSaleCooldownEnabled { get; set; } @@ -3117,7 +3117,7 @@ public record RequirementReferences public Dictionary? ExtensionData { get; set; } [JsonPropertyName("Alpinist")] - public List Alpinists { get; set; } + public IEnumerable Alpinists { get; set; } } public record Alpinist @@ -3398,7 +3398,7 @@ public record BtrMapConfig public string MapID { get; set; } [JsonPropertyName("pathsConfigurations")] - public List PathsConfigurations { get; set; } + public IEnumerable PathsConfigurations { get; set; } } public record PathConfig @@ -3542,7 +3542,7 @@ public record SkillsSettings public WeaponSkills Revolver { get; set; } [JsonPropertyName("SMG")] - public List SMG { get; set; } + public IEnumerable SMG { get; set; } [JsonPropertyName("Assault")] public WeaponSkills Assault { get; set; } @@ -3554,16 +3554,16 @@ public record SkillsSettings public WeaponSkills Sniper { get; set; } [JsonPropertyName("LMG")] - public List LMG { get; set; } + public IEnumerable LMG { get; set; } [JsonPropertyName("HMG")] - public List HMG { get; set; } + public IEnumerable HMG { get; set; } [JsonPropertyName("Launcher")] - public List Launcher { get; set; } + public IEnumerable Launcher { get; set; } [JsonPropertyName("AttachedLauncher")] - public List AttachedLauncher { get; set; } + public IEnumerable AttachedLauncher { get; set; } [JsonPropertyName("Melee")] public MeleeSkill Melee { get; set; } @@ -3572,58 +3572,58 @@ public record SkillsSettings public WeaponSkills DMR { get; set; } [JsonPropertyName("BearAssaultoperations")] - public List BearAssaultoperations { get; set; } + public IEnumerable BearAssaultoperations { get; set; } [JsonPropertyName("BearAuthority")] - public List BearAuthority { get; set; } + public IEnumerable BearAuthority { get; set; } [JsonPropertyName("BearAksystems")] - public List BearAksystems { get; set; } + public IEnumerable BearAksystems { get; set; } [JsonPropertyName("BearHeavycaliber")] - public List BearHeavycaliber { get; set; } + public IEnumerable BearHeavycaliber { get; set; } [JsonPropertyName("BearRawpower")] - public List BearRawpower { get; set; } + public IEnumerable BearRawpower { get; set; } [JsonPropertyName("BipodErgonomicsBonusPerLevel")] public double BipodErgonomicsBonusPerLevel { get; set; } [JsonPropertyName("UsecArsystems")] - public List UsecArsystems { get; set; } + public IEnumerable UsecArsystems { get; set; } [JsonPropertyName("UsecDeepweaponmodding_Settings")] - public List UsecDeepweaponmodding_Settings { get; set; } + public IEnumerable UsecDeepweaponmodding_Settings { get; set; } [JsonPropertyName("UsecLongrangeoptics_Settings")] - public List UsecLongrangeoptics_Settings { get; set; } + public IEnumerable UsecLongrangeoptics_Settings { get; set; } [JsonPropertyName("UsecNegotiations")] - public List UsecNegotiations { get; set; } + public IEnumerable UsecNegotiations { get; set; } [JsonPropertyName("UsecTactics")] - public List UsecTactics { get; set; } + public IEnumerable UsecTactics { get; set; } [JsonPropertyName("BotReload")] - public List BotReload { get; set; } + public IEnumerable BotReload { get; set; } [JsonPropertyName("CovertMovement")] public CovertMovement CovertMovement { get; set; } [JsonPropertyName("FieldMedicine")] - public List FieldMedicine { get; set; } + public IEnumerable FieldMedicine { get; set; } [JsonPropertyName("Search")] public Search Search { get; set; } [JsonPropertyName("Sniping")] - public List Sniping { get; set; } + public IEnumerable Sniping { get; set; } [JsonPropertyName("ProneMovement")] - public List ProneMovement { get; set; } + public IEnumerable ProneMovement { get; set; } [JsonPropertyName("FirstAid")] - public List FirstAid { get; set; } + public IEnumerable FirstAid { get; set; } [JsonPropertyName("LightVests")] public ArmorSkills LightVests { get; set; } @@ -3632,19 +3632,19 @@ public record SkillsSettings public ArmorSkills HeavyVests { get; set; } [JsonPropertyName("WeaponModding")] - public List WeaponModding { get; set; } + public IEnumerable WeaponModding { get; set; } [JsonPropertyName("AdvancedModding")] - public List AdvancedModding { get; set; } + public IEnumerable AdvancedModding { get; set; } [JsonPropertyName("NightOps")] - public List NightOps { get; set; } + public IEnumerable NightOps { get; set; } [JsonPropertyName("SilentOps")] - public List SilentOps { get; set; } + public IEnumerable SilentOps { get; set; } [JsonPropertyName("Lockpicking")] - public List Lockpicking { get; set; } + public IEnumerable Lockpicking { get; set; } [JsonPropertyName("WeaponTreatment")] public WeaponTreatment WeaponTreatment { get; set; } @@ -3653,22 +3653,22 @@ public record SkillsSettings public MagDrills MagDrills { get; set; } [JsonPropertyName("Freetrading")] - public List Freetrading { get; set; } + public IEnumerable Freetrading { get; set; } [JsonPropertyName("Auctions")] - public List Auctions { get; set; } + public IEnumerable Auctions { get; set; } [JsonPropertyName("Cleanoperations")] - public List Cleanoperations { get; set; } + public IEnumerable Cleanoperations { get; set; } [JsonPropertyName("Barter")] - public List Barter { get; set; } + public IEnumerable Barter { get; set; } [JsonPropertyName("Shadowconnections")] - public List Shadowconnections { get; set; } + public IEnumerable Shadowconnections { get; set; } [JsonPropertyName("Taskperformance")] - public List Taskperformance { get; set; } + public IEnumerable Taskperformance { get; set; } [JsonPropertyName("Perception")] public Perception Perception { get; set; } @@ -3692,7 +3692,7 @@ public record SkillsSettings public AimDrills AimDrills { get; set; } [JsonPropertyName("BotSound")] - public List BotSound { get; set; } + public IEnumerable BotSound { get; set; } [JsonPropertyName("TroubleShooting")] public TroubleShooting TroubleShooting { get; set; } @@ -3823,7 +3823,7 @@ public record Crafting public Dictionary? ExtensionData { get; set; } [JsonPropertyName("DependentSkillRatios")] - public List DependentSkillRatios { get; set; } + public IEnumerable DependentSkillRatios { get; set; } [JsonPropertyName("PointsPerCraftingCycle")] public double PointsPerCraftingCycle { get; set; } @@ -3908,7 +3908,7 @@ public record Endurance public double GainPerFatigueStack { get; set; } [JsonPropertyName("DependentSkillRatios")] - public List DependentSkillRatios { get; set; } + public IEnumerable DependentSkillRatios { get; set; } [JsonPropertyName("QTELevelMultipliers")] public Dictionary> QTELevelMultipliers { get; set; } @@ -3920,7 +3920,7 @@ public record Strength public Dictionary? ExtensionData { get; set; } [JsonPropertyName("DependentSkillRatios")] - public List DependentSkillRatios { get; set; } + public IEnumerable DependentSkillRatios { get; set; } [JsonPropertyName("SprintActionMin")] public double SprintActionMin { get; set; } @@ -3941,7 +3941,7 @@ public record Strength public double PushUpMax { get; set; } [JsonPropertyName("QTELevelMultipliers")] - public List QTELevelMultipliers { get; set; } + public IEnumerable QTELevelMultipliers { get; set; } [JsonPropertyName("FistfightAction")] public double FistfightAction { get; set; } @@ -4088,7 +4088,7 @@ public record WeaponTreatment public double SkillPointsPerRepair { get; set; } [JsonPropertyName("Filter")] - public List Filter { get; set; } + public IEnumerable Filter { get; set; } [JsonPropertyName("WearAmountRepairGunsReducePerLevel")] public double WearAmountRepairGunsReducePerLevel { get; set; } @@ -4151,7 +4151,7 @@ public record Perception public Dictionary? ExtensionData { get; set; } [JsonPropertyName("DependentSkillRatios")] - public List DependentSkillRatios { get; set; } + public IEnumerable DependentSkillRatios { get; set; } [JsonPropertyName("OnlineAction")] public double OnlineAction { get; set; } diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/Quest.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/Quest.cs index 20f42673..20b603e5 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/Quest.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/Quest.cs @@ -361,25 +361,25 @@ public record QuestConditionCounterCondition public object? Value { get; set; } [JsonPropertyName("weapon")] - public List? Weapon { get; set; } + public HashSet? Weapon { get; set; } [JsonPropertyName("distance")] public CounterConditionDistance? Distance { get; set; } [JsonPropertyName("equipmentInclusive")] - public List>? EquipmentInclusive { get; set; } + public IEnumerable>? EquipmentInclusive { get; set; } [JsonPropertyName("weaponModsInclusive")] - public List>? WeaponModsInclusive { get; set; } + public IEnumerable>? WeaponModsInclusive { get; set; } [JsonPropertyName("weaponModsExclusive")] - public List>? WeaponModsExclusive { get; set; } + public IEnumerable>? WeaponModsExclusive { get; set; } [JsonPropertyName("enemyEquipmentInclusive")] - public List>? EnemyEquipmentInclusive { get; set; } + public IEnumerable>? EnemyEquipmentInclusive { get; set; } [JsonPropertyName("enemyEquipmentExclusive")] - public List>? EnemyEquipmentExclusive { get; set; } + public IEnumerable>? EnemyEquipmentExclusive { get; set; } [JsonPropertyName("weaponCaliber")] public List? WeaponCaliber { get; set; } diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/Reward.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/Reward.cs index 0f7c32f1..aec7a18b 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/Reward.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/Reward.cs @@ -49,7 +49,7 @@ public record Reward public bool? FindInRaid { get; set; } [JsonPropertyName("gameMode")] - public List? GameMode { get; set; } + public IEnumerable? GameMode { get; set; } /// /// Game editions whitelisted to get reward diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/TemplateItem.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/TemplateItem.cs index 4f327362..dba88ffd 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/TemplateItem.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/TemplateItem.cs @@ -88,7 +88,7 @@ public record Props private string? _unlootableFromSlot; [JsonPropertyName("AllowSpawnOnLocations")] - public List? AllowSpawnOnLocations { get; set; } + public IEnumerable? AllowSpawnOnLocations { get; set; } [JsonPropertyName("BeltMagazineRefreshCount")] public double? BeltMagazineRefreshCount { get; set; } @@ -257,7 +257,7 @@ public record Props public int? ExtraSizeUp { get; set; } [JsonPropertyName("FlareTypes")] - public List? FlareTypes { get; set; } + public IEnumerable? FlareTypes { get; set; } [JsonPropertyName("ExtraSizeDown")] public int? ExtraSizeDown { get; set; } @@ -313,7 +313,7 @@ public record Props } [JsonPropertyName("UnlootableFromSide")] - public List? UnlootableFromSide { get; set; } + public IEnumerable? UnlootableFromSide { get; set; } // Type confirmed via client [JsonPropertyName("AnimationVariantsNumber")] @@ -362,10 +362,10 @@ public record Props public bool? CanPutIntoDuringTheRaid { get; set; } [JsonPropertyName("CantRemoveFromSlotsDuringRaid")] - public List? CantRemoveFromSlotsDuringRaid { get; set; } + public IEnumerable? CantRemoveFromSlotsDuringRaid { get; set; } [JsonPropertyName("KeyIds")] - public List? KeyIds { get; set; } + public IEnumerable? KeyIds { get; set; } [JsonPropertyName("TagColor")] public double? TagColor { get; set; } @@ -464,7 +464,7 @@ public record Props public double? SightModesCount { get; set; } [JsonPropertyName("OpticCalibrationDistances")] - public List? OpticCalibrationDistances { get; set; } + public IEnumerable? OpticCalibrationDistances { get; set; } [JsonPropertyName("ScopesCount")] public double? ScopesCount { get; set; } @@ -473,10 +473,10 @@ public record Props public object? AimSensitivity { get; set; } // TODO: object here [JsonPropertyName("Zooms")] - public List>? Zooms { get; set; } + public IEnumerable>? Zooms { get; set; } [JsonPropertyName("CalibrationDistances")] - public List>? CalibrationDistances { get; set; } + public IEnumerable>? CalibrationDistances { get; set; } [JsonPropertyName("Intensity")] public double? Intensity { get; set; } @@ -560,7 +560,7 @@ public record Props public double? MagAnimationIndex { get; set; } [JsonPropertyName("Cartridges")] - public List? Cartridges { get; set; } + public IEnumerable? Cartridges { get; set; } [JsonPropertyName("CanFast")] public bool? CanFast { get; set; } @@ -630,10 +630,10 @@ public record Props public double? ContainerSpawnChanceModifier { get; set; } [JsonPropertyName("SpawnFilter")] - public List? SpawnFilter { get; set; } // TODO: object here + public IEnumerable? SpawnFilter { get; set; } // TODO: object here [JsonPropertyName("containType")] - public List? ContainType { get; set; } // TODO: object here + public IEnumerable? ContainType { get; set; } // TODO: object here [JsonPropertyName("sizeWidth")] public double? SizeWidth { get; set; } @@ -648,7 +648,7 @@ public record Props public string? SpawnTypes { get; set; } [JsonPropertyName("lootFilter")] - public List? LootFilter { get; set; } // TODO: object here + public IEnumerable? LootFilter { get; set; } // TODO: object here [JsonPropertyName("spawnRarity")] public string? SpawnRarity { get; set; } @@ -660,7 +660,7 @@ public record Props public double? MaxCountSpawn { get; set; } [JsonPropertyName("openedByKeyID")] - public List? OpenedByKeyID { get; set; } + public IEnumerable? OpenedByKeyID { get; set; } [JsonPropertyName("RigLayoutName")] public string? RigLayoutName { get; set; } @@ -669,7 +669,7 @@ public record Props public double? MaxDurability { get; set; } [JsonPropertyName("armorZone")] - public List? ArmorZone { get; set; } + public IEnumerable? ArmorZone { get; set; } // Type confirmed via client [JsonPropertyName("armorClass")] @@ -677,10 +677,10 @@ public record Props public int? ArmorClass { get; set; } [JsonPropertyName("armorColliders")] - public List? ArmorColliders { get; set; } + public IEnumerable? ArmorColliders { get; set; } [JsonPropertyName("armorPlateColliders")] - public List? ArmorPlateColliders { get; set; } + public IEnumerable? ArmorPlateColliders { get; set; } [JsonPropertyName("bluntDamageReduceFromSoftArmor")] public bool? BluntDamageReduceFromSoftArmor { get; set; } @@ -801,7 +801,7 @@ public record Props public double? shotgunDispersion { get; set; } [JsonPropertyName("Chambers")] - public List? Chambers { get; set; } + public IEnumerable? Chambers { get; set; } [JsonPropertyName("CameraSnap")] public double? CameraSnap { get; set; } @@ -835,7 +835,7 @@ public record Props public XYZ? RotationCenterNoStock { get; set; } [JsonPropertyName("ShotsGroupSettings")] - public List? ShotsGroupSettings { get; set; } + public IEnumerable? ShotsGroupSettings { get; set; } [JsonPropertyName("FoldedSlot")] public string? FoldedSlot { get; set; } @@ -1226,7 +1226,7 @@ public record Props // Confirmed on client - MongoId [JsonPropertyName("TargetItemFilter")] - public List? TargetItemFilter { get; set; } + public IEnumerable? TargetItemFilter { get; set; } [JsonPropertyName("RepairQuality")] public double? RepairQuality { get; set; } @@ -1434,7 +1434,7 @@ public record Props public double? MalfFeedChance { get; set; } [JsonPropertyName("StackSlots")] - public List? StackSlots { get; set; } + public IEnumerable? StackSlots { get; set; } [JsonPropertyName("type")] public string? Type { get; set; } @@ -1497,7 +1497,7 @@ public record Props public bool? RemoveShellAfterFire { get; set; } [JsonPropertyName("RepairStrategyTypes")] - public List? RepairStrategyTypes { get; set; } + public IEnumerable? RepairStrategyTypes { get; set; } [JsonPropertyName("IsEncoded")] public bool? IsEncoded { get; set; } @@ -1539,10 +1539,10 @@ public record Props public bool? AvailableAsDefault { get; set; } [JsonPropertyName("ProfileVersions")] - public List? ProfileVersions { get; set; } + public IEnumerable? ProfileVersions { get; set; } [JsonPropertyName("Side")] - public List? Side { get; set; } + public IEnumerable? Side { get; set; } [JsonPropertyName("BipodCameraSnapMultiplier")] public double? BipodCameraSnapMultiplier { get; set; } @@ -1578,7 +1578,7 @@ public record WeaponRecoilSettings public bool? Enable { get; set; } [JsonPropertyName("Values")] - public List? Values { get; set; } + public IEnumerable? Values { get; set; } } public record WeaponRecoilSettingValues @@ -1623,7 +1623,7 @@ public record WeaponRecoilTransformationCurve public Dictionary? ExtensionData { get; set; } [JsonPropertyName("Keys")] - public List? Keys { get; set; } + public IEnumerable? Keys { get; set; } } public record WeaponRecoilTransformationCurveKey @@ -1695,7 +1695,7 @@ public record GridProps public Dictionary? ExtensionData { get; set; } [JsonPropertyName("filters")] - public List? Filters { get; set; } + public IEnumerable? Filters { get; set; } [JsonPropertyName("cellsH")] public int? CellsH { get; set; } @@ -1779,7 +1779,7 @@ public record SlotProps public Dictionary? ExtensionData { get; set; } [JsonPropertyName("filters")] - public List? Filters { get; set; } + public IEnumerable? Filters { get; set; } [JsonPropertyName("MaxStackCount")] public double? MaxStackCount { get; set; } @@ -1800,10 +1800,10 @@ public record SlotFilter public MongoId? Plate { get; set; } [JsonPropertyName("armorColliders")] - public List? ArmorColliders { get; set; } + public IEnumerable? ArmorColliders { get; set; } [JsonPropertyName("armorPlateColliders")] - public List? ArmorPlateColliders { get; set; } + public IEnumerable? ArmorPlateColliders { get; set; } [JsonPropertyName("Filter")] public HashSet? Filter { get; set; } @@ -1851,7 +1851,7 @@ public record StackSlotProps public Dictionary? ExtensionData { get; set; } [JsonPropertyName("filters")] - public List? Filters { get; set; } + public IEnumerable? Filters { get; set; } } public record RandomLootSettings @@ -1866,13 +1866,13 @@ public record RandomLootSettings public bool? AllowToSpawnQuestItems { get; set; } [JsonPropertyName("countByRarity")] - public List? CountByRarity { get; set; } // TODO: object here + public IEnumerable? CountByRarity { get; set; } // TODO: object here [JsonPropertyName("excluded")] public RandomLootExcluded? Excluded { get; set; } [JsonPropertyName("filters")] - public List? Filters { get; set; } // TODO: object here + public IEnumerable? Filters { get; set; } // TODO: object here [JsonPropertyName("findInRaid")] public bool? FindInRaid { get; set; } @@ -1890,13 +1890,13 @@ public record RandomLootExcluded public Dictionary? ExtensionData { get; set; } [JsonPropertyName("categoryTemplates")] - public List? CategoryTemplates { get; set; } // TODO: object here + public IEnumerable? CategoryTemplates { get; set; } // TODO: object here [JsonPropertyName("rarity")] - public List? Rarity { get; set; } + public IEnumerable? Rarity { get; set; } [JsonPropertyName("templates")] - public List? Templates { get; set; } // TODO: object here + public IEnumerable? Templates { get; set; } // TODO: object here } public record EffectsHealth diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Match/EndLocalRaidRequestData.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Match/EndLocalRaidRequestData.cs index d2592651..5269405f 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Match/EndLocalRaidRequestData.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Match/EndLocalRaidRequestData.cs @@ -25,7 +25,7 @@ public record EndLocalRaidRequestData : IRequestData /// Insured items left in raid by player /// [JsonPropertyName("lostInsuredItems")] - public List? LostInsuredItems { get; set; } + public IEnumerable? LostInsuredItems { get; set; } /// /// Items sent via traders to player, keyed to service e.g. BTRTransferStash diff --git a/Libraries/SPTarkov.Server.Core/Services/FenceService.cs b/Libraries/SPTarkov.Server.Core/Services/FenceService.cs index b17cef34..90917fa5 100644 --- a/Libraries/SPTarkov.Server.Core/Services/FenceService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/FenceService.cs @@ -1282,14 +1282,14 @@ public class FenceService( foreach (var requiredSlot in softInsertSlots) { var modItemDbDetails = itemHelper - .GetItem(requiredSlot.Props.Filters[0].Plate.Value) + .GetItem(requiredSlot.Props.Filters.First().Plate.Value) .Value; var durabilityValues = GetRandomisedArmorDurabilityValues( modItemDbDetails, traderConfig.Fence.ArmorMaxDurabilityPercentMinMax ); - var plateTpl = requiredSlot.Props.Filters[0].Plate ?? string.Empty; // "Plate" property appears to be the 'default' item for slot + var plateTpl = requiredSlot.Props.Filters.First().Plate ?? string.Empty; // "Plate" property appears to be the 'default' item for slot if (plateTpl.IsEmpty()) // Some bsg plate properties are empty, skip mod { @@ -1348,7 +1348,7 @@ public class FenceService( { foreach (var plateSlot in plateSlots) { - var plateTpl = plateSlot.Props.Filters[0].Plate; + var plateTpl = plateSlot.Props.Filters.First().Plate; if (plateTpl == null || plateTpl.Value.IsEmpty()) // Bsg data lacks a default plate, skip randomising for this mod { diff --git a/Libraries/SPTarkov.Server.Core/Services/InsuranceService.cs b/Libraries/SPTarkov.Server.Core/Services/InsuranceService.cs index 3378c663..2fac8c27 100644 --- a/Libraries/SPTarkov.Server.Core/Services/InsuranceService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/InsuranceService.cs @@ -251,7 +251,7 @@ public class InsuranceService( /// InsuranceEquipmentPkg list public List MapInsuredItemsToTrader( MongoId sessionId, - List lostInsuredItems, + IEnumerable lostInsuredItems, PmcData pmcProfile ) { diff --git a/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs b/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs index 0198689d..7ee27d25 100644 --- a/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs @@ -1168,7 +1168,7 @@ public class LocationLifecycleService( string locationName ) { - if (request.LostInsuredItems?.Count > 0) + if (request.LostInsuredItems is not null && request.LostInsuredItems.Any()) { var mappedItems = insuranceService.MapInsuredItemsToTrader( sessionId, diff --git a/Libraries/SPTarkov.Server.Core/Services/Mod/CustomItemService.cs b/Libraries/SPTarkov.Server.Core/Services/Mod/CustomItemService.cs index 3411d6f5..4c6091b0 100644 --- a/Libraries/SPTarkov.Server.Core/Services/Mod/CustomItemService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/Mod/CustomItemService.cs @@ -299,7 +299,7 @@ public class CustomItemService( var wall = itemHelper.GetItem(wallId); if (wall.Key) { - wall.Value.Properties.Grids.First().Props.Filters[0].Filter.Add(newItemId); + wall.Value.Properties.Grids.First().Props.Filters.First().Filter.Add(newItemId); } } } @@ -328,7 +328,7 @@ public class CustomItemService( var weaponSlots = weapon.Value.Properties.Slots; foreach (var slot in weaponSlots) { - baseWeaponModObject[slot.Name] = [.. slot.Props.Filters[0].Filter]; + baseWeaponModObject[slot.Name] = [.. slot.Props.Filters.First().Filter]; } // Get PMCs diff --git a/Libraries/SPTarkov.Server.Core/Services/RagfairLinkedItemService.cs b/Libraries/SPTarkov.Server.Core/Services/RagfairLinkedItemService.cs index 5afbb763..9568b25e 100644 --- a/Libraries/SPTarkov.Server.Core/Services/RagfairLinkedItemService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/RagfairLinkedItemService.cs @@ -130,7 +130,7 @@ public class RagfairLinkedItemService( // Get the first cylinder filter tpl var cylinderTpl = - cylinderMod.Props?.Filters?[0].Filter?.FirstOrDefault() ?? new MongoId(null); + cylinderMod.Props?.Filters?.First().Filter?.FirstOrDefault() ?? new MongoId(null); if (!cylinderTpl.IsValidMongoId()) { @@ -181,7 +181,7 @@ public class RagfairLinkedItemService( var result = new HashSet(); var chambers = item.Properties?.Chambers; - if (chambers is null || chambers.Count == 0) + if (chambers is null || !chambers.Any()) { return result; } @@ -207,7 +207,7 @@ public class RagfairLinkedItemService( var result = new HashSet(); var cartridges = item.Properties?.Cartridges; - if (cartridges is null || cartridges.Count == 0) + if (cartridges is null || !cartridges.Any()) { return result; } diff --git a/Tools/MongoIdTplGenerator/Generators/ItemTplMongoIdGenerator.cs b/Tools/MongoIdTplGenerator/Generators/ItemTplMongoIdGenerator.cs index 7feea8e1..6e01b325 100644 --- a/Tools/MongoIdTplGenerator/Generators/ItemTplMongoIdGenerator.cs +++ b/Tools/MongoIdTplGenerator/Generators/ItemTplMongoIdGenerator.cs @@ -358,12 +358,12 @@ public class ItemTplMongoIdGenerator( // Add mag size for magazines if (itemHelper.IsOfBaseclass(item.Id, BaseClasses.MAGAZINE)) { - suffix = $"{item.Properties?.Cartridges?[0].MaxCount?.ToString()}RND"; + suffix = $"{item.Properties?.Cartridges?.First().MaxCount?.ToString()}RND"; } // Add pack size for ammo boxes else if (itemHelper.IsOfBaseclass(item.Id, BaseClasses.AMMO_BOX)) { - suffix = $"{item.Properties.StackSlots[0]?.MaxCount.ToString()}RND"; + suffix = $"{item.Properties.StackSlots.First()?.MaxCount.ToString()}RND"; } // Add "DAMAGED" for damaged items @@ -404,14 +404,20 @@ public class ItemTplMongoIdGenerator( private string GetAmmoBoxPrefix(TemplateItem item) { - var ammoTpl = item.Properties?.StackSlots?[0]?.Props?.Filters?[0]?.Filter?.FirstOrDefault(); + var ammoTpl = item + .Properties?.StackSlots?.First() + ?.Props?.Filters?.First() + ?.Filter?.FirstOrDefault(); return GetAmmoPrefix(_items[ammoTpl.Value]); } private string GetMagazinePrefix(TemplateItem item) { - var ammoTpl = item.Properties?.Cartridges?[0]?.Props?.Filters?[0]?.Filter?.FirstOrDefault(); + var ammoTpl = item + .Properties?.Cartridges?.First() + ?.Props?.Filters?.First() + ?.Filter?.FirstOrDefault(); return GetAmmoPrefix(_items[ammoTpl.Value]); }