Help needed with 2d platformer lights

I like that you have an idea of how this may work, but even after re-reading this message a couple times i am not really sure where to even start to attempt doing what you suggested. I probably need to learn about raycasting and collision masks.