public static IReadOnlyCollection <Mod> AllMods(WeaponClass pWeaponClass, bool pIncludeHeavyCaliber, IReadOnlyCollection <string> pAugments) { var key = new Tuple <WeaponClass, bool, string>(pWeaponClass, pIncludeHeavyCaliber, string.Join("|", pAugments)); if (!_FilteredMods.ContainsKey(key)) { if (pIncludeHeavyCaliber && !pWeaponClass.HasFlag(WeaponClass.Rifle)) { throw new NotImplementedException("Heavy Caliber on non rifle?"); } var result = new List <Mod>(); foreach (var mod in _AllMods) { if (mod == HeavyCaliber && !pIncludeHeavyCaliber) { continue; } if (mod.WeaponClass == WeaponClass.All || pWeaponClass.HasFlag(mod.WeaponClass) || pAugments.Contains(mod.Name)) { result.Add(mod); } } _FilteredMods.Add(key, result); } return(_FilteredMods[key]); }
public static IReadOnlyCollection <string> FromClass(WeaponClass p, bool pAllowHeavyCaliber) { if (p.HasFlag(WeaponClass.Rifle)) { if (pAllowHeavyCaliber) { return(RifleHC); } return(RifleNoHC); } if (p.HasFlag(WeaponClass.Shotgun)) { return(Shotgun); } if (p.HasFlag(WeaponClass.Secondary)) { return(Secondary); } if (p.HasFlag(WeaponClass.Melee)) { return(Melee); } throw new NotImplementedException(); }