Please, help with Prime Pathing

I have encountered a tricky problem - nearest moving point is beyond the wall. So how I can … filter only visible points, maybe?

@Dmithry My original solution for this was rather extensive. I believe I detected all of the traps and manually identified a path through so that I looked at those traps first.

Looking at the code again. The isPathClear() function might help.