Replace the fancy Linq stuff with a simple loop for a big performance gain.

The mono JIT compiler is probably too stupid to inline it all. Since this is called in FixedUpdate multiple times, it matters.