cleanup of class

This commit is contained in:
Chomp 2021-08-25 19:04:46 +01:00
parent 617cbd196e
commit ac5a0e3f17

View File

@ -43,7 +43,8 @@ namespace PMCGenerator
// Get mods types for this gun, top level // Get mods types for this gun, top level
var uniqueModSlots = flatModList.Where(x => x.ParentId == weapon.Id).Select(x => x.SlotId).Distinct().ToList(); 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) foreach (var modSlotId in uniqueModSlots)
{ {
Dictionary<string, List<string>> weaponModsToModify = output.mods[weapon.TemplateId]; Dictionary<string, List<string>> weaponModsToModify = output.mods[weapon.TemplateId];
@ -55,10 +56,9 @@ namespace PMCGenerator
} }
// Add compatible bullets to weapons gun chamber // Add compatible bullets to weapons gun chamber
var modItemToAddBulletsTo = output.mods[weapon.TemplateId].FirstOrDefault(x=> x.Key == "patron_in_weapon"); var modItemToAddBulletsTo = output.mods[weapon.TemplateId].FirstOrDefault(x=> x.Key == chamberedBulletModItemName);
var bulletTemplateIds = GetCompatibileBullets(itemLibrary, weapon);
foreach (var bullet in bulletTemplateIds) foreach (var bullet in GetCompatibileBullets(itemLibrary, weapon))
{ {
if (BulletHelpers.BulletIsOnBlackList(bullet)) if (BulletHelpers.BulletIsOnBlackList(bullet))
{ {
@ -68,7 +68,6 @@ namespace PMCGenerator
modItemToAddBulletsTo.Value.AddUnique(bullet); modItemToAddBulletsTo.Value.AddUnique(bullet);
} }
// Add compatabible mods to weapon // Add compatabible mods to weapon
var modsForWeapon = flatModList.Where(x => x.ParentId == weapon.Id).ToList(); var modsForWeapon = flatModList.Where(x => x.ParentId == weapon.Id).ToList();
Dictionary<string, List<string>> weaponMods = output.mods[weapon.TemplateId]; Dictionary<string, List<string>> weaponMods = output.mods[weapon.TemplateId];
@ -76,7 +75,6 @@ namespace PMCGenerator
{ {
weaponMods[mod.SlotId].AddUnique(mod.TemplateId); weaponMods[mod.SlotId].AddUnique(mod.TemplateId);
} }
} }
// Get mods where parent is not weapon and add to output // Get mods where parent is not weapon and add to output
@ -120,9 +118,7 @@ namespace PMCGenerator
var workingPath = Directory.GetCurrentDirectory(); var workingPath = Directory.GetCurrentDirectory();
var itemsLibraryJson = File.ReadAllText(workingPath + "\\input" + "\\items.json"); var itemsLibraryJson = File.ReadAllText(workingPath + "\\input" + "\\items.json");
var itemsLibrary = JsonConvert.DeserializeObject<Dictionary<string, Item>>(itemsLibraryJson); return JsonConvert.DeserializeObject<Dictionary<string, Item>>(itemsLibraryJson);
return itemsLibrary;
} }
@ -134,16 +130,11 @@ namespace PMCGenerator
// Find the guns chamber and the bullets it can use // Find the guns chamber and the bullets it can use
var bullets = weaponInLibrary._props.Chambers.FirstOrDefault()?._props.filters[0]?.filter.ToList(); var bullets = weaponInLibrary._props.Chambers.FirstOrDefault()?._props.filters[0]?.filter.ToList();
// no chamber found, return default ammo type // return bullets or return default ammo type
if (bullets == null) return bullets ?? new List<string>
{
return new List<string>
{ {
weaponInLibrary._props.defAmmo weaponInLibrary._props.defAmmo
}; };
}
return bullets;
} }
private static List<Presets> ParsePresetJsons(List<string> presetFiles) private static List<Presets> ParsePresetJsons(List<string> presetFiles)
@ -227,7 +218,6 @@ namespace PMCGenerator
} }
} }
return result; return result;
} }
@ -243,7 +233,6 @@ namespace PMCGenerator
} }
} }
return result; return result;
} }
@ -287,4 +276,4 @@ namespace PMCGenerator
return outputPath; return outputPath;
} }
} }
} }