From ac5a0e3f17d757afd2ceb1d1c74edde793d83785 Mon Sep 17 00:00:00 2001 From: Chomp Date: Wed, 25 Aug 2021 19:04:46 +0100 Subject: [PATCH] cleanup of class --- PMCGenerator/Program.cs | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/PMCGenerator/Program.cs b/PMCGenerator/Program.cs index 4c0931b..625d472 100644 --- a/PMCGenerator/Program.cs +++ b/PMCGenerator/Program.cs @@ -43,7 +43,8 @@ namespace PMCGenerator // Get mods types for this gun, top level var uniqueModSlots = flatModList.Where(x => x.ParentId == weapon.Id).Select(x => x.SlotId).Distinct().ToList(); - uniqueModSlots.AddUnique("patron_in_weapon"); // Add bullet in chamber item + var chamberedBulletModItemName = "patron_in_weapon"; + uniqueModSlots.AddUnique(chamberedBulletModItemName); foreach (var modSlotId in uniqueModSlots) { Dictionary> weaponModsToModify = output.mods[weapon.TemplateId]; @@ -55,10 +56,9 @@ namespace PMCGenerator } // Add compatible bullets to weapons gun chamber - var modItemToAddBulletsTo = output.mods[weapon.TemplateId].FirstOrDefault(x=> x.Key == "patron_in_weapon"); - var bulletTemplateIds = GetCompatibileBullets(itemLibrary, weapon); + var modItemToAddBulletsTo = output.mods[weapon.TemplateId].FirstOrDefault(x=> x.Key == chamberedBulletModItemName); - foreach (var bullet in bulletTemplateIds) + foreach (var bullet in GetCompatibileBullets(itemLibrary, weapon)) { if (BulletHelpers.BulletIsOnBlackList(bullet)) { @@ -68,7 +68,6 @@ namespace PMCGenerator modItemToAddBulletsTo.Value.AddUnique(bullet); } - // Add compatabible mods to weapon var modsForWeapon = flatModList.Where(x => x.ParentId == weapon.Id).ToList(); Dictionary> weaponMods = output.mods[weapon.TemplateId]; @@ -76,7 +75,6 @@ namespace PMCGenerator { weaponMods[mod.SlotId].AddUnique(mod.TemplateId); } - } // Get mods where parent is not weapon and add to output @@ -120,9 +118,7 @@ namespace PMCGenerator var workingPath = Directory.GetCurrentDirectory(); var itemsLibraryJson = File.ReadAllText(workingPath + "\\input" + "\\items.json"); - var itemsLibrary = JsonConvert.DeserializeObject>(itemsLibraryJson); - - return itemsLibrary; + return JsonConvert.DeserializeObject>(itemsLibraryJson); } @@ -134,16 +130,11 @@ namespace PMCGenerator // Find the guns chamber and the bullets it can use var bullets = weaponInLibrary._props.Chambers.FirstOrDefault()?._props.filters[0]?.filter.ToList(); - // no chamber found, return default ammo type - if (bullets == null) - { - return new List + // return bullets or return default ammo type + return bullets ?? new List { weaponInLibrary._props.defAmmo }; - } - - return bullets; } private static List ParsePresetJsons(List presetFiles) @@ -227,7 +218,6 @@ namespace PMCGenerator } } - return result; } @@ -243,7 +233,6 @@ namespace PMCGenerator } } - return result; } @@ -287,4 +276,4 @@ namespace PMCGenerator return outputPath; } } -} +} \ No newline at end of file