I see the code is quite procedural, why so?

Object Oriented code is great, but not always the fastest solution from a performance standpoint.

This is just like the triangles optimization for mobile: sometimes a little more triangles means less pixels to be rendered, so it's a fair price to pay to have your game running faster.

Basically we have to keep in mind that every function call adds up to the stack, and even having all indexers done by integers values for speed we can't really leave the main thread because we have to interact with GameObject anyway. The full matching algorithm is a time consuming one, so the best way we have to reduce as much as possible the computation is to write the code procedurally, carefully avoiding those techniques that will make the code slower.

We know... the result is heavy to read and maintain, but is a small price to pay once you fully understand how much faster the game can go this way :) Any purist of Object Oriented Programming will tell that this code is horrible, and we do agree indeed, but it's as fast as horrible while in this use case a nice OOP code would become as slow as nice, so we don't really have to think about it, do we? Horrible is good in this case :)

Feedback and Knowledge Base