Easy way is to create a reverse list (what not to include), you hit the reverse list first (CastToC4 did it work, skip, else CastToAmmoBase) as that list will most likely be smaller. Now note, AmmoBase I believe covers arrows as well
I’ve been working on something similar (look through items, does it use durability, is it damaged, repair if yes) I’ve had to skip things like water containers, and paint brushes (they use durability for water amount and paint remaining)
And you are correct PrimalItem is the base class, which everything can be referenced as thanks to parenting, you can take a PrimalItem reference and attempt to cast it to the type you want PrimalItemWeapon_Rifle or PrimalItemAmmo_Arrow
Now I’m not sure if there is a baseclass for resources, but what you can do is follow the parent paths
Search in the content browser for “wood” look at parent or open with reference viewer (Left side is parents, right is children) so travel the left path of the primalitems until you see the base class (you will probably see a bunch on the right because they all child from it)
but I know weapons, food, soups, ammo, armor all have a base class (and some of them have a base base class) just takes some investigating to find what you need.