The purpose of the following code is to create a list of indexes of ammo that matches the requirements of a given weapon (type and caliber and effect)
In the following code, I get require a predicate to get it to work. (at the find index method)
How is this done/ is there a better method?
the code:
/// <summary>
/// Returns ammo matching the given type and prefix
/// </summary>
/// <returns>ammo matching the given type in a list</returns>
/// <param name="theAmmoType">The ammo type enum.</param>
public List<int> FetchAmmo (ammoType theAmmoType, string ammoPrefix)
{
// list to return
List<int> result = new List<int>();
// iterate through whitelisted ammo
foreach (var item in availableAmmo)
{
// sort
if (item.myAmmoType == theAmmoType)
{
// check prefix of string
if (item.name.Contains(ammoPrefix))
// add the item
result.Add(availableAmmo.FindIndex(item));
}
}
// throw back
return result;
}