public AmmoType[] CompatitbleAmmoTypes(WeaponPart.PartType?type) { List <AmmoType> types = new List <AmmoType>(); foreach (AmmoType t in AmmoType.GetValues(typeof(AmmoType))) { types.Add(t); } foreach (Item i in parts) { if (i.Properties.WeaponPart.Type == type) { continue; } for (int j = types.Count - 1; j >= 0; j--) { if (!i.Properties.WeaponPart.AcceptableAmmo.Contains(types[j])) { types.RemoveAt(j); } } } return(types.ToArray()); }